Skip to content

fix(auth): sessions authenticate by bearer only - #2477

Merged
Makisuo merged 2 commits into
mainfrom
sec/session-bearer-only
Nov 10, 2026
Merged

Makisuo merged 2 commits into
mainfrom
sec/session-bearer-only

test(mcp): a request with cookies and no bearer carries no credential

9259676
Select commit
Loading
Failed to load commit list.
Maple Review Bot / Maple / review succeeded Nov 10, 2026 in 41s

Confidence 10/10 · No issues found

🟢 Confidence 10/10 · safe to merge. Both new behaviours — cookie never read by toHeaders, cookie stripped by the /_api proxy — are pinned by tests that fail on main; the only new commit adds one such test.
no findings · tests covered · risk high

Sessions now authenticate by the Authorization bearer only: toHeaders forwards nothing else to Clerk, the /_api proxy drops Cookie, and MCP stops counting a cookie as a credential. Contained and safe to merge; the comment at apps/ai/src/runtime/auth-graph.ts:16 still says "session cookie".

  • toHeaders forwards only the authorization header to Clerk's authenticateRequest
  • /_api forwarding deletes the incoming Cookie header before the binding call
  • MCP carriesCredential no longer treats a cookie as a credential
  • New tests: cookie-only rejection in packages/auth and apps/ai, cookie stripped in apps/web
What was checked
  • toHeaders is reached only through toRequest in authenticateClerkUser (packages/auth/src/index.ts:197), so no other auth path loses headers
  • Electric shape fetches send the session bearer (apps/web/src/platform/api-clients.ts:79), so live sync is unaffected
  • /_api has no second forwarding path: a missing binding 503s before any request is built (api-proxy-forward.ts:37), so no path still carries cookies

9259676 · Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.