Hardening checklist: session cookies, CSRF on JSON routes, token comparisons, image-MCP key fallback, member-created MCP servers #60

Closed
opened 2026-11-19 20:24:44 +00:00 by activeinference · 3 comments

From a static review of the public repos (no live systems probed). These are small hardening items across several repos, collected in one place. None of them is an exploit on its own.

member-dashboard / admin-panel

  • Session cookies (member_oidc_session, the admin-panel session) are set without secure=True.
  • State-changing routes rely on SameSite=Lax alone. This covers dashboard /api/keys, /api/guests, /api/matrix-mxid and /api/cancel-guest, plus the admin-panel write routes. Lax does not cover sibling *.inference.coop origins, because they are same-site. Starlette's request.json() also parses text/plain bodies, so a plain form POST from any XSS on a sibling app would carry the session. Suggestion: require Content-Type: application/json and/or check Origin against the app's own host.
  • Dashboard DELETE /api/keys/{name} forwards an unvalidated name into the portal URL path. Apply the same [A-Za-z0-9._-]{1,64} check used on create.
  • Admin panel renders d.error into innerHTML without esc() (app/main.py ~L814, in loadMetrics).

member-portal

  • Four /admin/* routes compare the admin token with != instead of secrets.compare_digest (L4724, L4736, L5098, L5113). Route them through _verify_admin_token.
  • ADMIN_TOKEN_LEGACY defaults to on when the env var is unset (L258). Now that the cutover is complete, default it to off.

librechat-custom

  • mcp/image_server.py L45-47 falls back to the shared SYSTEM_IMAGE_KEY whenever the per-user IC_API_KEY is empty. It should fail closed, so image spend can never land on the co-op account because a member's key is missing. Consider not passing the system key into per-user MCP processes at all.
  • Verify: interface.mcpServers.create: true lets every USER-role account, guests included, register MCP servers that the LibreChat server itself connects to. Confirm that LibreChat 0.8.8 blocks private and internal addresses for user-created servers. If it doesn't, add an mcpSettings domain allowlist, or limit create to members.

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 of the public repos (no live systems probed). These are small hardening items across several repos, collected in one place. None of them is an exploit on its own. **member-dashboard / admin-panel** - [ ] Session cookies (`member_oidc_session`, the admin-panel session) are set without `secure=True`. - [ ] State-changing routes rely on `SameSite=Lax` alone. This covers dashboard `/api/keys`, `/api/guests`, `/api/matrix-mxid` and `/api/cancel-guest`, plus the admin-panel write routes. Lax does not cover sibling `*.inference.coop` origins, because they are same-site. Starlette's `request.json()` also parses `text/plain` bodies, so a plain form POST from any XSS on a sibling app would carry the session. **Suggestion:** require `Content-Type: application/json` and/or check `Origin` against the app's own host. - [ ] Dashboard `DELETE /api/keys/{name}` forwards an unvalidated `name` into the portal URL path. Apply the same `[A-Za-z0-9._-]{1,64}` check used on create. - [ ] Admin panel renders `d.error` into `innerHTML` without `esc()` (`app/main.py` ~L814, in `loadMetrics`). **member-portal** - [ ] Four `/admin/*` routes compare the admin token with `!=` instead of `secrets.compare_digest` (L4724, L4736, L5098, L5113). Route them through `_verify_admin_token`. - [ ] `ADMIN_TOKEN_LEGACY` defaults to **on** when the env var is unset (L258). Now that the cutover is complete, default it to off. **librechat-custom** - [ ] `mcp/image_server.py` L45-47 falls back to the shared `SYSTEM_IMAGE_KEY` whenever the per-user `IC_API_KEY` is empty. It should fail closed, so image spend can never land on the co-op account because a member's key is missing. Consider not passing the system key into per-user MCP processes at all. - [ ] **Verify:** `interface.mcpServers.create: true` lets every USER-role account, **guests included**, register MCP servers that the LibreChat server itself connects to. Confirm that LibreChat 0.8.8 blocks private and internal addresses for user-created servers. If it doesn't, add an `mcpSettings` domain allowlist, or limit `create` to members. --- *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

All items checked against the code and the live apps; everything that needed a change is deployed and verified.

member-dashboard

  • OIDC cookies now Secure — verified on the wire: /auth/openid/login returns HttpOnly; SameSite=lax; Secure for both oidc_state and oidc_nonce.
  • Write routes (POST /api/keys, POST /api/matrix-mxid, POST /api/cancel-guest, POST /api/guests, DELETE /api/keys/{name}) now require an Origin matching the app host when a browser sends one, and application/json bodies for methods that carry one. SameSite alone no longer carries them.
  • DELETE /api/keys/{name} applies the same [A-Za-z0-9._-]{1,64} check as create and URL-quotes the segment.

admin-panel

  • Session cookies Secure (verified the same way).
  • loadMetrics error path now uses esc(d.error); all three write routes go through the same Origin/JSON guard.
  • Harnesses and sync pins pass.

member-portal

  • The four != token comparisons (guest resend, resend-stale, aliases list, aliases add) use secrets.compare_digest, preserving their 401 response shape. Verified live: admin token → 200, legacy webhook token → 403, no token → 403.
  • ADMIN_TOKEN_LEGACY defaults to off when unset.

librechat-custom

  • mcp/image_server.py fails closed when IC_API_KEY is absent, with a message pointing at the dashboard; SYSTEM_IMAGE_KEY is no longer passed into per-user MCP processes or referenced in librechat.yaml. Deployed config and MCP script md5-match the repo on /app/data (they live on the persistent volume, so the image update alone would not refresh them — copied and restarted).
  • MCP create/SSRF: verified safe on 0.8.8. MCPServerUserInputSchema is a union of ws/sse/streamable-HTTP variants only — stdio (command/args) cannot be created by a user, so no arbitrary command execution. For URL servers, isMCPDomainAllowed blocks private/reserved IPs, loopback, cloud metadata and internal hostnames when no allowedDomains whitelist is configured, with a connect-time DNS re-check. No allowlist needed; the create permission can stay on for members.

Both apps keep version/manifest pins in the repo; images are 20261119-<sha> for each repo.

All items checked against the code and the live apps; everything that needed a change is deployed and verified. **member-dashboard** - OIDC cookies now `Secure` — verified on the wire: `/auth/openid/login` returns `HttpOnly; SameSite=lax; Secure` for both `oidc_state` and `oidc_nonce`. - Write routes (`POST /api/keys`, `POST /api/matrix-mxid`, `POST /api/cancel-guest`, `POST /api/guests`, `DELETE /api/keys/{name}`) now require an `Origin` matching the app host when a browser sends one, and `application/json` bodies for methods that carry one. SameSite alone no longer carries them. - `DELETE /api/keys/{name}` applies the same `[A-Za-z0-9._-]{1,64}` check as create and URL-quotes the segment. **admin-panel** - Session cookies `Secure` (verified the same way). - `loadMetrics` error path now uses `esc(d.error)`; all three write routes go through the same Origin/JSON guard. - Harnesses and sync pins pass. **member-portal** - The four `!=` token comparisons (guest resend, resend-stale, aliases list, aliases add) use `secrets.compare_digest`, preserving their 401 response shape. Verified live: admin token → 200, legacy webhook token → 403, no token → 403. - `ADMIN_TOKEN_LEGACY` defaults to off when unset. **librechat-custom** - `mcp/image_server.py` fails closed when `IC_API_KEY` is absent, with a message pointing at the dashboard; `SYSTEM_IMAGE_KEY` is no longer passed into per-user MCP processes or referenced in `librechat.yaml`. Deployed config and MCP script md5-match the repo on `/app/data` (they live on the persistent volume, so the image update alone would not refresh them — copied and restarted). - **MCP create/SSRF: verified safe on 0.8.8.** `MCPServerUserInputSchema` is a union of ws/sse/streamable-HTTP variants only — stdio (`command`/`args`) cannot be created by a user, so no arbitrary command execution. For URL servers, `isMCPDomainAllowed` blocks private/reserved IPs, loopback, cloud metadata and internal hostnames when no `allowedDomains` whitelist is configured, with a connect-time DNS re-check. No allowlist needed; the create permission can stay on for members. Both apps keep `version`/manifest pins in the repo; images are `20261119-<sha>` for each repo.
Owner

The latest private security review is tracked in #61: portal guest groups, MXID revocation/rate limit, no-tier cutoff, internal-only key feed, pinned Tinfoil proxy, root-only backup credentials.

The latest private security review is tracked in #61: portal guest groups, MXID revocation/rate limit, no-tier cutoff, internal-only key feed, pinned Tinfoil proxy, root-only backup credentials.
Owner

All checklist items are deployed and verified: Secure cookies, Origin+JSON CSRF guards, key-name validation, escaped panel error text, compare_digest admin checks, ADMIN_TOKEN_LEGACY off by default, image-MCP fail-closed, and confirmed MCP private-address blocking. Closing.

All checklist items are deployed and verified: Secure cookies, Origin+JSON CSRF guards, key-name validation, escaped panel error text, `compare_digest` admin checks, `ADMIN_TOKEN_LEGACY` off by default, image-MCP fail-closed, and confirmed MCP private-address blocking. Closing.
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: co-op/support#60