Skip to content

Refuse tokens that carry authorization_details - #7282

Merged
rdimitrov merged 2 commits into
mainfrom
as2-call-binding-3-terminal-details
Nov 24, 2026
Merged

rdimitrov merged 2 commits into
mainfrom
as2-call-binding-3-terminal-details

Conversation

@rdimitrov

@rdimitrov rdimitrov commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Summary

"Authorization server: narrow a JWT-bearer access token to one MCP call with authorization_details" (#7061) has AS-2 copy a signed authorization_details entry into the access token so the token serves one MCP call. That restriction is worthless if the token can be swapped for a token without it. Today every place that mints a token from an existing one drops the claim: an RFC 8693 subject or actor token carrying authorization_details is exchanged and the new token has no details, and a JWT-bearer or ID-JAG assertion's claim is ignored at redemption. This PR makes such tokens terminal, the same way delegated-access tokens already are, so a narrowed token stays narrow. It is fail-closed on its own and needs nothing else to land first.

  • Replace hasDelegatedAccessMarker with restrictionsOf, which reports the delegated-access marker, authorization_details and cnf as three separate facts. hasConfirmationClaim folds into it. Each call site picks its own order, so a token carrying both the marker and details cannot slip past a site that refuses only one of them.
  • Refuse a token carrying authorization_details at the four RFC 8693 sites: the subject token, the actor token, the subject token that opens an exchange grant, and the self-signed actor token at ID-JAG issuance. The marker is still checked first at these sites, so a marked token gets the same response as before.
  • Refuse an assertion carrying authorization_details at plain RFC 7523 and ID-JAG redemption, after the cnf check and before the assertion is consumed. Redemption still does not refuse the marker. A later branch narrows this refusal to plain RFC 7523 once AS-2 processes the claim on ID-JAGs.
  • Replace the "A marked token is terminal" table in docs/arch/17-token-exchange-delegation.md with a "Terminal tokens" section covering both claims, the redemption site and the issuer scope of each site.

Part of #7061

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe):

Test plan

  • Unit tests (task test)
  • E2E tests (task test-e2e)
  • Linting (task lint-fix)
  • Manual testing (describe below)

Also ran go test -race ./pkg/authserver/... and golangci-lint run ./pkg/authserver/.... A mutation check that disables the authorization_details fact fails 16 subtests: the details-only rows at every site, the external-issuer row and every redemption row.

New tests:

  • TestTerminalTokenRefusedInTokenExchange: RFC 8693 subject and actor tokens, each with details only, marker only, and both, plus an actor token bound to another client, to show the refusal runs before client binding. Subject and actor tokens without either claim are still exchanged.
  • TestTerminalTokenRefusedFromExternalIssuer: a trusted external issuer's subject token with details only, marker only and both is refused, and an unrestricted one is still exchanged.
  • TestTerminalTokenRefusedAtGrantOpening: details only, marker only, both, on a token that every later check would also refuse (act, a source client that is not allowed, another audience). This pins that the terminal reason comes first.
  • TestTerminalTokenRefusedAsIDJAGActorToken: details, marker, both, expired, and the cases that go to the actor validator: a token signed with another key, or naming another issuer.
  • TestRedemptionRefusesAuthorizationDetailsClaim: both redemption forms, with details in Extra or only in the full claim set, every shape from the issue (null, [], a string, an object, an array holding a non-object), marker with details, and cnf with details (cnf wins). No refused assertion is consumed. A row with the marker alone is redeemed, which pins that redemption does not refuse the marker.
  • TestRestrictionsOf replaces TestHasDelegatedAccessMarker and TestHasConfirmationClaim. It covers nil claims, nil maps, each claim in either map, and all three together.

Changes

File Change
pkg/authserver/server/tokenexchange/restriction.go New: restrictions, restrictionsOf, hasClaim, claimConfirmation
handler.go refuseTerminalToken at the RFC 8693 subject and actor sites; details hints
refresh_token_handler.go terminalSubjectReason at grant opening; new reasons
refresh_token_id_jag.go refuseDelegatedAccessActor → refuseTerminalActor
jwt_bearer_handler.go, id_jag_handler.go validateAssertion uses restrictionsOf for cnf and calls refuseSignedDetails
redemption_refusal.go, redeemer.go redeemer.refuseSignedDetails, logged at WARN once per issuer, then at DEBUG
docs/arch/17-token-exchange-delegation.md "Terminal tokens" section; redemption, exchange-grant and ID-JAG actor tables

Does this introduce a user-facing change?

Yes.

Request Before After
RFC 8693 exchange whose subject_token carries authorization_details (self-issued or from a trusted external issuer) Exchanged; the new token has no details 400 invalid_request, hint "The subject token carries authorization_details and cannot be exchanged."; WARN Subject token refused, reason=authorization_details_token
RFC 8693 exchange whose actor_token carries authorization_details Exchanged 400 invalid_request, hint "The actor token carries authorization_details and cannot be exchanged."; WARN Actor token refused, reason=authorization_details_token
Opening an exchange grant with a subject_token that carries authorization_details Grant opened 400 invalid_request, subject_token_authorization_details
ID-JAG issuance with an actor_token this server signed that carries authorization_details Passed to the actor validator 400 invalid_request, actor_token_authorization_details
JWT-bearer or ID-JAG redemption of an assertion that carries authorization_details (any value, including null) Token issued; claim dropped 400 invalid_grant, invalid_assertion: The assertion must not carry an 'authorization_details' claim.; the assertion is not consumed; Assertion refused, reason=authorization_details_assertion, with the issuer, at WARN the first time per issuer and at DEBUG after that
Any of the above that also carries the delegated-access marker Marker refusal Same marker refusal (unchanged wire text), except at redemption, which refuses for the details

The external-issuer row is deliberate. If an AS-1 trusts AS-2 as an external issuer, this refusal is what stops a token AS-2 narrowed to one call from being exchanged at AS-1 for an unrestricted one (provided AS-1 runs this version). The trade-off is that a trusted IdP's RFC 9396 access token, which is exchanged today with its details dropped, is now refused. A narrowed token cannot be re-exchanged for another audience either.

Special notes for reviewers

  • Why a set and not a classifier. A single classifier that returns one value, marker first, is unsafe at redemption, which refuses the details but not the marker: an assertion carrying both would be classified as "marker" and redeemed with the details dropped. With independent facts each site states its own order, and every site has a test row with both claims.
  • Issuer scope per site. Only the RFC 8693 subject_token accepts external issuers. The RFC 8693 actor token and the grant-opening subject token are self-issued only. At ID-JAG issuance only an actor token this server signed is refused, because an external actor's details describe the agent's own limits, not the subject's grant, so the configured actor validator decides on them.
  • Redemption logs, cnf does not. The sibling cnf refusal has no log line. The details refusal logs the issuer because it can newly break a trusted IdP's redemptions, for example an IdP that starts putting authorization_details into its ID-JAGs. The plain grant needs no client authentication, and a refused assertion is not consumed, so one assertion could be resent until it expires. The line is therefore at WARN only the first time per issuer (a sync.Map on the redeemer, bounded by the trusted issuers) and at DEBUG after that. This is the same pattern as the ID-JAG draft-departure lines.
  • Order at redemption. Both handlers refuse authorization_details right after the issuer's policy lookup (enabledPolicy), so an issuer the validator trusts but that is not enabled for the grant gets "issuer is not enabled for this grant", and the Warn line names only issuers the grant accepts. On an ID-JAG, an aud with more than one value and a cnf claim are also refused before authorization_details. All of these run before the assertion is consumed. The docs table states this.
  • Merge order. This must merge no later than the branch that makes AS-2 copy the ID-JAG's claim into the token. That branch narrows the redemption refusal to plain RFC 7523.

Confirmed in the issue discussion

The issue author agreed with these rules in this comment on #7061 (items 2, 3 and 4):

  • Terminal tokens (item 4). On RFC 8693 exchange, a subject or actor token that carries authorization_details, with any value, from this server or an external IdP, is refused before any hook runs or anything is consumed. It gets the error code the handler already uses for a refused subject or actor token. The comment's reason name was only an example. This PR uses the names that already exist next to the marker's:
    • RFC 8693 handler: invalid_request with the hint "The subject token carries authorization_details and cannot be exchanged." or "The actor token carries authorization_details and cannot be exchanged.", logged with reason=authorization_details_token. The marker refusal already uses a hint plus reason=delegated_access_token here.
    • Exchange-grant opening: invalid_request, subject_token_authorization_details, next to subject_token_delegated_access.
    • ID-JAG issuance: invalid_request, actor_token_authorization_details, next to actor_token_delegated_access.
    • Redemption log line: reason=authorization_details_assertion.
  • Plain RFC 7523 (item 2). An assertion carrying authorization_details is refused with invalid_grant / invalid_assertion. This PR refuses it on the ID-JAG form too, and both forms have test rows, so the later AS-2 change that starts processing the claim on ID-JAGs has to change the ID-JAG rows on purpose.
  • Claim shape (item 3). null, [], a string, an object and an array holding a non-object are all refused with invalid_grant / invalid_assertion. The claim is checked in both the standard and extra claims, and each case leaves the assertion unconsumed. Until AS-2 processes the claim, every shape is refused, because only presence counts.

🤖 Generated with Claude Code

A token narrowed with authorization_details must stay narrow, but every
place that mints a token from an existing one dropped the claim: the
RFC 8693 subject and actor tokens, the subject token that opens an
exchange grant, the actor token at ID-JAG issuance, and the assertion
at JWT-bearer and ID-JAG redemption. Refuse such tokens at all five
sites instead, for external subject-token issuers too, so a narrowed
token cannot be exchanged here, or at a server that trusts this one,
for an unrestricted one.

Replace the single delegated-access marker check with restrictionsOf,
which reports the marker, authorization_details and cnf as separate
facts. Each site applies its own order: the four exchange sites check
the marker first, so a marked token keeps its wire text, while
redemption refuses cnf, then authorization_details, and never the
marker, so an assertion carrying both is still refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the size/L Large PR: 600-999 lines changed label Nov 24, 2026
@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.86%. Comparing base (8d64314) to head (10b89aa).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7282      +/-   ##
==========================================
- Coverage   81.86%   81.86%   -0.01%     
==========================================
  Files         915      916       +1     
  Lines       92868    92897      +29     
==========================================
+ Hits        76029    76046      +17     
- Misses      16834    16846      +12     
  Partials        5        5              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The authorization_details refusal ran inside validateAssertion, before
the issuer's policy lookup. An issuer the validator trusts but that is
not enabled for the grant got the details refusal, and a Warn line that
reads as if that issuer had started breaking redemptions, instead of
"issuer is not enabled for this grant".

Move the refusal into enabledPolicy, right after the policy lookup, in
both redemption handlers. It still runs before the assertion is
consumed. Add a test row for a trusted issuer that is not enabled.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added size/L Large PR: 600-999 lines changed and removed size/L Large PR: 600-999 lines changed labels Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Large PR: 600-999 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants