Repository navigation
Refuse tokens that carry authorization_details - #7282
Merged
Merged
Conversation
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]>
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
jhrozek
reviewed
Nov 24, 2026
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]>
jhrozek
approved these changes
Nov 24, 2026
4 tasks done
This was referenced Nov 25, 2026
This was referenced Nov 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
"Authorization server: narrow a JWT-bearer access token to one MCP call with authorization_details" (#7061) has AS-2 copy a signed
authorization_detailsentry 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 carryingauthorization_detailsis 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.hasDelegatedAccessMarkerwithrestrictionsOf, which reports the delegated-access marker,authorization_detailsandcnfas three separate facts.hasConfirmationClaimfolds 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.authorization_detailsat 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.authorization_detailsat plain RFC 7523 and ID-JAG redemption, after thecnfcheck 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.docs/arch/17-token-exchange-delegation.mdwith a "Terminal tokens" section covering both claims, the redemption site and the issuer scope of each site.Part of #7061
Type of change
Test plan
task test)task test-e2e)task lint-fix)Also ran
go test -race ./pkg/authserver/...andgolangci-lint run ./pkg/authserver/.... A mutation check that disables theauthorization_detailsfact 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 inExtraor 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, andcnfwith details (cnfwins). No refused assertion is consumed. A row with the marker alone is redeemed, which pins that redemption does not refuse the marker.TestRestrictionsOfreplacesTestHasDelegatedAccessMarkerandTestHasConfirmationClaim. It covers nil claims, nil maps, each claim in either map, and all three together.Changes
pkg/authserver/server/tokenexchange/restriction.gorestrictions,restrictionsOf,hasClaim,claimConfirmationhandler.gorefuseTerminalTokenat the RFC 8693 subject and actor sites; details hintsrefresh_token_handler.goterminalSubjectReasonat grant opening; new reasonsrefresh_token_id_jag.gorefuseDelegatedAccessActor→refuseTerminalActorjwt_bearer_handler.go,id_jag_handler.govalidateAssertionusesrestrictionsOfforcnfand callsrefuseSignedDetailsredemption_refusal.go,redeemer.goredeemer.refuseSignedDetails, logged at WARN once per issuer, then at DEBUGdocs/arch/17-token-exchange-delegation.mdDoes this introduce a user-facing change?
Yes.
subject_tokencarriesauthorization_details(self-issued or from a trusted external issuer)invalid_request, hint "The subject token carries authorization_details and cannot be exchanged."; WARNSubject token refused,reason=authorization_details_tokenactor_tokencarriesauthorization_detailsinvalid_request, hint "The actor token carries authorization_details and cannot be exchanged."; WARNActor token refused,reason=authorization_details_tokensubject_tokenthat carriesauthorization_detailsinvalid_request,subject_token_authorization_detailsactor_tokenthis server signed that carriesauthorization_detailsinvalid_request,actor_token_authorization_detailsauthorization_details(any value, includingnull)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 thatThe 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
subject_tokenaccepts 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.cnfdoes not. The siblingcnfrefusal 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 puttingauthorization_detailsinto 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 (async.Mapon the redeemer, bounded by the trusted issuers) and at DEBUG after that. This is the same pattern as the ID-JAG draft-departure lines.authorization_detailsright 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, anaudwith more than one value and acnfclaim are also refused beforeauthorization_details. All of these run before the assertion is consumed. The docs table states this.Confirmed in the issue discussion
The issue author agreed with these rules in this comment on #7061 (items 2, 3 and 4):
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:invalid_requestwith the hint "The subject token carries authorization_details and cannot be exchanged." or "The actor token carries authorization_details and cannot be exchanged.", logged withreason=authorization_details_token. The marker refusal already uses a hint plusreason=delegated_access_tokenhere.invalid_request,subject_token_authorization_details, next tosubject_token_delegated_access.invalid_request,actor_token_authorization_details, next toactor_token_delegated_access.reason=authorization_details_assertion.authorization_detailsis refused withinvalid_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.null,[], a string, an object and an array holding a non-object are all refused withinvalid_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