Skip to content

fix(tokens): require the exact broker scope to mint History assertions - #114

Merged
khaliqgant merged 2 commits into
mainfrom
fix/assertion-scope-exact
Oct 31, 2026
Merged

khaliqgant merged 2 commits into
mainfrom
fix/assertion-scope-exact

Conversation

@khaliqgant

@khaliqgant khaliqgant commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Summary

Tighten scope checks on the History assertion route. Workspace tokens and admin keys can no longer satisfy the assertion scope by implication.

  • New lib/broker-scopes.ts: an assertion scope is satisfied only by its exact literal.
  • The History assertion route authorizes with that exact matcher and accepts only a plain api-key credential.
  • API key and workspace token issuance refuse to delegate an assertion scope unless the caller holds that exact literal.

Found in the 2026-10-30 security sweep.

Verification

  • packages/server tests: all pass (691/691 at merge).
  • Reverting the route changes (tests kept) fails the new tests.
  • npx turbo build && npx turbo typecheck: clean.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff


Agent Relay sessions

  • claude session aac00799 · opened via gh pr create · last active 2026-10-31
  • claude session a685ac1e · contributor · ran gh pr commands · last active 2026-10-31

POST /v1/tokens/relayhistory-assertion signs the org, workspace and
sponsor from the request body; that is intended for the dedicated
assertion broker key, which mints for every org it fronts. The route
authorized with matchScope, where `manage` implies `create` and `*`
implies everything, so any org admin API key holding
relayauth:*:manage:* (the documented relayauth-admin role) or `*` also
passed and could mint an rth:read assertion for another org.

The route now requires the literal relayauth:assertion:create:relayhistory
on the key, and POST /v1/api-keys refuses to put a relayauth:assertion:*
scope on a new key unless the caller holds that exact literal, so an
admin cannot delegate the broker scope to itself either. The bootstrap
key and Cloud's broker key already hold the exact literal.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…broker

An org admin could mint a workspace token whose stored scopes carry the broker
literal (scopesWithinGrant accepts it by implication), then present it as an
x-api-key, which satisfies the exact-scope check. Workspace token issuance now
applies the same broker-delegation rule as POST /v1/api-keys, and the assertion
route requires a plain api_key kind, as attestations already do.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@khaliqgant
khaliqgant marked this pull request as ready for review October 31, 2026 00:39
@khaliqgant
khaliqgant merged commit dc1f74b into main Oct 31, 2026
5 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T00:39:52.324716Z 5881320 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@greptile-apps

greptile-apps Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Review summary redacted by a maintainer (security). The one finding was fixed in #119.

Comment thread packages/server/src/routes/api-keys.ts Resolved
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