Repository navigation
fix(server): act as a member only where the web does, and never send a stray acting header to Supabase Auth - #1974
Merged
Conversation
…a stray acting header to Supabase Auth Review follow-ups (D-1, D-4) for internal requests acting as a member (ansvisor#1949): - ACTING_USER_ROUTES keeps only the routes the web writes through for a run with no session: an opportunity's status, a dismissed prompt suggestion, and Send to Action Center with its duplicate check. Site Audit's starts (POST /audits, /audits/bulk) and a report's summary (POST /reports/summary) leave it: their Chat changes always wait on the person's card, whose Approve runs with their session. Least privilege: the secret now answers 401 there. - decodeToken refuses a request carrying X-Acting-User without the acting secret (401) before anything reaches Supabase Auth, so a web whose CHAT_ACTING_SECRET differs from this server's never sends its secret to getUser as a token. It is logged without the secret. - server/.env.example and the self-host env docs name the routes and the refusal. Tests: the three routes are refused with the secret and nothing is read; X-Acting-User with a session's token or a wrong secret is refused before getUser or getUserById; a session without the header still passes. The default request is now Send to Action Center. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
6 of 13 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Least privilege for #1949's acting secret. Found in the pre-push security reviews of #1949 and the web side.
Only the four routes the web uses. The acting secret now acts as a member only on:
PATCH /content/:id/status;POST /prompts/suggestions/:id/dismiss;POST /action-center/chat-actions/check;POST /action-center/chat-actions.POST /audits,POST /audits/bulkandPOST /reports/summaryare dropped and answer 401 with the secret. So a leaked secret can't spend anyone's audit quota or AI budget.A mismatched secret never reaches Supabase Auth. A request carrying
X-Acting-Userwhose secret doesn't match is refused with 401 indecodeToken, before anything goes toauth.getUser. The warning is logged without the secret.X-Acting-Useris now a 401 too. It used to be ignored, and the web never sends that.server/.env.exampleand the self-host docs' server line are updated.Server only. No migration.
Related issue
None. Follow-up to the security review of #1949.
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
Unit tests in
src/middleware/acting-user.test.js:X-Acting-Userwith a wrong secret, or with a session token, is a 401 that never callsgetUser.npx vitest run src/middleware src/routespasses (70 files / 708 tests).Checklist
npm run lintpassesnpm run format:checkpasseshelp/(or no user-visible change)CI passed on this branch (0099c26), run on the fork (https://github.com/cihan-gyk/ansvisor/actions/runs/41360087011): schema is up to date; web
format:check, lint, typecheck, all tests andyarn buildpass; server lint,format:checkand all tests pass.🤖 Generated with Claude Code