Retire the legacy /v1/* key-injection proxy (PORTAL_SECRET can spend as any member) #8

Closed
opened 2026-11-19 20:24:27 +00:00 by activeinference · 2 comments

From a static review at 1f1d555125 (no live systems probed).

inject_key (app/main.py L4522, @app.api_route("/v1/{path:path}")) is the OpenWebUI-era key-injection path. No repo on this Gitea sends X-Portal-Secret any more. LibreChat talks to the gateway directly with per-user keys, and the README's LibreChat wiring section (baseURL: https://portal.inference.coop/v1) is stale.

The route is still live, and it:

  • lets anyone holding PORTAL_SECRET spend as any member just by naming their email in X-User-Email;
  • proxies any path with any method (GET/POST/PUT/DELETE/PATCH) to LiteLLM under that member's key, not just chat completions;
  • forwards every inbound header upstream (headers = dict(request.headers), L4554), including X-Portal-Secret itself, so the secret can end up in gateway-side logs.

The ops docs (operator-token-runbook.md, reference/env-manifest.md) describe PORTAL_SECRET as "session signing", which understates what it can do.

Suggestion: delete the route and retire PORTAL_SECRET. If something still needs it, restrict it to POST /v1/chat/completions and forward only an allowlist of headers. Also update the README and ops docs.


Filed by Daniel Ari Friedman (member) in a personal capacity. The activeinference username is my personal co-op account, not the Active Inference Institute.

From a static review at `1f1d555125` (no live systems probed). `inject_key` (`app/main.py` L4522, `@app.api_route("/v1/{path:path}")`) is the OpenWebUI-era key-injection path. No repo on this Gitea sends `X-Portal-Secret` any more. LibreChat talks to the gateway directly with per-user keys, and the README's LibreChat wiring section (`baseURL: https://portal.inference.coop/v1`) is stale. The route is still live, and it: - lets anyone holding `PORTAL_SECRET` spend as **any** member just by naming their email in `X-User-Email`; - proxies **any path with any method** (GET/POST/PUT/DELETE/PATCH) to LiteLLM under that member's key, not just chat completions; - forwards **every inbound header** upstream (`headers = dict(request.headers)`, L4554), including `X-Portal-Secret` itself, so the secret can end up in gateway-side logs. The ops docs (`operator-token-runbook.md`, `reference/env-manifest.md`) describe `PORTAL_SECRET` as "session signing", which understates what it can do. **Suggestion:** delete the route and retire `PORTAL_SECRET`. If something still needs it, restrict it to `POST /v1/chat/completions` and forward only an allowlist of headers. Also update the README and ops docs. --- *Filed by Daniel Ari Friedman (member) in a personal capacity. The `activeinference` username is my personal co-op account, not the Active Inference Institute.*
Owner

Done in 5f3519d (image 20261119-5f3519d).

  • The /v1/{path:path} key-injection route and _verify_portal_secret are deleted from app/main.py.
  • PORTAL_SECRET is unset from the portal env and the app restarted; the variable is gone from the container (0 matches).
  • Verified on the wire: GET/POST/PUT/DELETE /v1/chat/completions all return 404; /health returns 200.
  • README's LibreChat wiring section now says the chat talks to https://gateway.inference.coop/v1 directly; the stale portal.inference.coop/v1 + X-User-Email example is removed.
  • ops-docs credential inventory (operator-token-runbook.md, reference/env-manifest.md) no longer lists PORTAL_SECRET.

Nothing consumed the route: librechat.yaml points the custom endpoint at the gateway, the chat app has no KEENABLE/portal-proxy env wiring, and the portal access log had no /v1/ requests. member-portal-cancel still contains the old route but is not deployed.

One adjacent item worth a separate decision: the inventory still lists OWUI_API_KEY / OWUI_JWT_SECRET as “confirm whether still needed” — the Open WebUI integration is retired, so those look like the next credentials to drop.

Done in `5f3519d` (image `20261119-5f3519d`). - The `/v1/{path:path}` key-injection route and `_verify_portal_secret` are deleted from `app/main.py`. - `PORTAL_SECRET` is unset from the portal env and the app restarted; the variable is gone from the container (`0` matches). - Verified on the wire: `GET/POST/PUT/DELETE /v1/chat/completions` all return **404**; `/health` returns 200. - README's LibreChat wiring section now says the chat talks to `https://gateway.inference.coop/v1` directly; the stale `portal.inference.coop/v1` + `X-User-Email` example is removed. - `ops-docs` credential inventory (`operator-token-runbook.md`, `reference/env-manifest.md`) no longer lists `PORTAL_SECRET`. Nothing consumed the route: `librechat.yaml` points the custom endpoint at the gateway, the chat app has no `KEENABLE`/portal-proxy env wiring, and the portal access log had no `/v1/` requests. `member-portal-cancel` still contains the old route but is not deployed. One adjacent item worth a separate decision: the inventory still lists `OWUI_API_KEY` / `OWUI_JWT_SECRET` as “confirm whether still needed” — the Open WebUI integration is retired, so those look like the next credentials to drop.
Owner

Retired and verified. The legacy /v1/* key-injection proxy and _verify_portal_secret/PORTAL_SECRET were removed; live probe: GET/POST/PUT/DELETE /v1/chat/completions all return 404, /health returns 200. Closing.

Retired and verified. The legacy `/v1/*` key-injection proxy and `_verify_portal_secret`/`PORTAL_SECRET` were removed; live probe: GET/POST/PUT/DELETE `/v1/chat/completions` all return 404, `/health` returns 200. Closing.
Sign in to join this conversation.
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: code/member-portal#8