Skip to content

security(core): stop scoped tokens from escalating via token create and login (24.05) - #7958

Closed
ar2rsawseen wants to merge 1 commit into
release.24.05from
backport/token-create-full-permission-2405
Closed

security(core): stop scoped tokens from escalating via token create and login (24.05)#7958
ar2rsawseen wants to merge 1 commit into
release.24.05from
backport/token-create-full-permission-2405

Conversation

@ar2rsawseen

Copy link
Copy Markdown
Member

Backport of #7957 to release.24.05.

A token scoped to one app could escalate to the owner's full account: /i/token/create isn't gated by the token's app/endpoint restriction (it carries no app_id), validateUser resolves any bearer token to the full member, the handler saved caller-supplied app/endpoint/purpose with no relationship to the creating credential, and /login/token/:token then granted the owner's full session from any token with a login purpose regardless of scope.

Fix (identical to #7957), both ends:

  • /i/token/create via a token is allowed only if that token has no app and no endpoint restriction; api_key callers and unrestricted tokens (what a dashboard session token is) are unaffected.
  • /login/token/:token additionally requires the token to be unrestricted; legitimate session tokens always are.

7 regression tests in test/2.api/16.token.manager.js (run by test-api-core). eslint clean.

🤖 Generated with Claude Code

…nd login

Backport of #7957 to release.24.05.

A token's app/endpoint restriction is a data-scoping control that does not gate
/i/token/create (no app_id there), and validateUser resolves any bearer token to
the full member. The create handler then saved caller-supplied app/endpoint/purpose
with no relationship to the authenticating credential, and /login/token/:token
granted the owner's full session from any token carrying a login purpose regardless
of scope. So a token scoped to one app could mint an unrestricted or LoggedInAuth
token and take over the owner's entire account.

Close it from both ends: token creation is allowed only from a full-permission
credential (api_key, or a token with no app and no endpoint restriction), and
/login/token requires the token to be unrestricted in addition to the purpose
allowlist. api_key callers and unrestricted tokens - which is what a dashboard
session token is - are unaffected.

Tests: 7 cases in test/2.api/16.token.manager.js.

Reported through the security bug bounty programme (received 2026-08-18).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ar2rsawseen

Copy link
Copy Markdown
Member Author

Closing in favor of a broader token-model rework that addresses this at the root rather than with the two containment checks here. The branch is retained as a fallback and can be reopened if needed.

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