Skip to content

fix(core/api): gate token mint + revoke on sentinel:all#80

Merged
BK1031 merged 1 commit into
mainfrom
bk1031/harden-token-gates
Jun 17, 2026
Merged

fix(core/api): gate token mint + revoke on sentinel:all#80
BK1031 merged 1 commit into
mainfrom
bk1031/harden-token-gates

Conversation

@BK1031

@BK1031 BK1031 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Audit hole

The most severe gap from the post-s2s-auth audit:

  • `POST /core/token` (GenerateToken) — UNGATED. Anyone reachable could mint a JWT claiming any entity, with any scope (including `sentinel:all` itself).
  • `DELETE /core/token/:id` (RevokeToken) — UNGATED. Anyone could revoke any token by ID.

Fix

Both now `Require(c, RequestTokenHasScope(c, "sentinel:all"))`. Internal services (sentinel-core/discord/oauth/saml) already carry `sentinel:all` after PR #79, so they keep working. Any third-party caller or unauthed request is now 401.

This is the first in a stack of "harden core API gates" PRs. After this lands:

Test plan

  • `curl -X POST /core/token` without auth → 401
  • `curl -X POST /core/token` with a non-sentinel:all bearer → 401
  • `curl -X POST /core/token` with sentinel-core's bearer → 200, token issued
  • OAuth login flow (which calls into core's token service from oauth, not core directly) still works

POST /core/token and DELETE /core/token/:id were entirely ungated.
Anyone reaching the API could mint a JWT claiming any entity at any
scope (including sentinel:all itself) or revoke arbitrary tokens by
ID. These are the highest-blast-radius operations in core; any
mitigating factor (network segmentation, etc) was the only thing
saving us.

Both now require sentinel:all on the bearer — same convention used
elsewhere for first-party-only operations. No new audit surface added;
just turning on the gate.
@BK1031 BK1031 merged commit dbbebb2 into main Jun 17, 2026
15 checks passed
@BK1031 BK1031 deleted the bk1031/harden-token-gates branch June 17, 2026 08:29
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.

1 participant