Skip to content

fix(server): act as a member only where the web does, and never send a stray acting header to Supabase Auth - #1974

Merged
gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:fix/acting-user-allowlist
Nov 2, 2026
Merged

gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:fix/acting-user-allowlist

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

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/bulk and POST /reports/summary are 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-User whose secret doesn't match is refused with 401 in decodeToken, before anything goes to auth.getUser. The warning is logged without the secret.

    • Change: a session token sent with X-Acting-User is now a 401 too. It used to be ignored, and the web never sends that.
  • server/.env.example and 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 feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

Unit tests in src/middleware/acting-user.test.js:

  • the four routes pass;
  • the dropped three answer 401 with the secret;
  • X-Acting-User with a wrong secret, or with a session token, is a 401 that never calls getUser.

npx vitest run src/middleware src/routes passes (70 files / 708 tests).

Checklist

  • Branch follows the naming convention
  • Commits follow Conventional Commits
  • npm run lint passes
  • npm run format:check passes
  • Changes are focused — one concern per PR
  • Help article updated under help/ (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 and yarn build pass; server lint, format:check and all tests pass.

🤖 Generated with Claude Code

…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]>
@mintlify

mintlify Bot commented Nov 1, 2026

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 0099c26.

Approve preview

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gkhngyk
gkhngyk merged commit c377511 into ansvisor:main Nov 2, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants