Fix trusted header auth bypass#200
Conversation
Co-authored-by: Hugo Demenez <hugodemenez@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🤖 Automated Code ReviewNo critical issues found in the diff. The main change in One non-critical concern is performance: Code quality is otherwise good. Error handling is consistent with the existing auth helpers, and Generated by Cursor CLI workflow — |
Bug and Impact
Server-side auth helpers trusted incoming
x-user-id/x-user-emailrequest headers. Because proxy only sets those values on the response, a client could spoof them on Server Action requests and cause user-scoped account/trade/import paths to run as another user, or spoof subscription email checks.Root Cause
getUserId()and subscription lookup treated middleware response headers as if they were trusted forwarded request headers.Fix
getUserId()andgetUserEmail()from the Supabase session only.Validation
npx vitest run server/auth.test.tsnpm run typecheck