Repository navigation
Prevent ID-JAGs from being used as access tokens - #7089
Conversation
A live exchange grant is not necessarily eligible to create a child. For example, an ID-JAG-only grant can be valid but must not derive another refresh-token grant. Move the top-level and refresh-token issuability checks into decideChild, leaving presentedGrant to validate the grant itself. This prepares validation for ID-JAG issuance without adding that path or changing the derivation refusal order. Refs: #6898 Co-authored-by: Mecatl <[email protected]>
An ID-JAG is an assertion for an authorization server, not an access token. When an issuer signs both with the same key, an ID-JAG could otherwise pass access-token validation if its claims also satisfy the checks. Refuse its JOSE type in resource-server and token-exchange access-token validators while keeping ID-JAG redemption separate. The check covers subject and actor tokens and login tokens used to create exchange grants. It matches the type case-insensitively and with an optional application/ prefix; missing or non-string types are not rejected by this check. vMCP uses the same matcher for its ID-JAG diagnostic. JWT-bearer redemption retains its exact type match for routing. Type variants therefore fail closed rather than reaching the ID-JAG handler; normalizing redemption routing is a follow-up. Refs: #6898 Co-authored-by: Mecatl <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7089 +/- ##
==========================================
+ Coverage 80.87% 80.89% +0.01%
==========================================
Files 865 866 +1
Lines 88731 88758 +27
==========================================
+ Hits 71764 71801 +37
+ Misses 16962 16952 -10
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
rdimitrov
left a comment
There was a problem hiding this comment.
Approving: the ID-JAG typ refusal is placed at every access-token validator and stays out of the redemption path.
Design: The check lives where "is this an access token" is decided: pkg/auth's validateTokenHeader (both the local-key and JWKS paths, reached by the proxy and vMCP incoming-auth middleware) and the auth server's self-issued and external subject/actor validators. The shared signature helpers stay type-neutral, so ID-JAG and JWT-bearer redemption still accept ID-JAGs. A deny-list of one type, rather than an allowlist of access-token types, avoids breaking IdPs that omit typ or use vendor values. The only upgrade effect is the intended one: a token typed oauth-id-jag+jwt (any case, with or without application/) now gets a 401 from the middleware and invalid_grant in token exchange.
Non-blocking notes:
pkg/authserver/server/tokenexchange/refresh_token_handler.go:402: moving theParentSignature/IssuableTokenTypescheck intodecideChilddoesn't change behaviour (presentedGranthas one caller), but it is prep for ID-JAG issuance, not this fix. Worth its own PR, or landing with the issuance work.jwt_bearer_handler.go:117,:134,:391andid_jag_handler.go:96still comparetypexactly, and the PR documents that gap in a code comment anddocs/arch/11-auth-server-storage.mdinstead of switching those four sites to the newoauthproto.IsJOSEType. It fails closed today (application/oauth-id-jag+jwtroutes to the JWT-bearer handler andvalidateAssertionTyperefuses it). Thepkg/vmcp/auth/strategies/xaa.go:288change already accepts theapplication/prefix on the vMCP side, so vMCP and the embedded AS now disagree on that form until the follow-up lands. Either do the swap here, or open a tracking issue so the arch-doc note doesn't become permanent.
🤖 Reviewed with Claude Code
Redemption routing compares the ID-JAG typ exactly, as the ID-JAG draft requires of an issuer, while the access-token checks normalize it per RFC 7515 Section 4.1.9. Document that as intended and fail closed, not as a known gap. Remove the ID-JAG case from the plain JWT-bearer typ allowlist. It was unreachable: IDJAGHandler claims the exact type first. Keeping it would let a mis-routed ID-JAG skip client authentication. Pin the refusal of variant spellings and the exact-complement routing in tests. Co-authored-by: Mecatl <[email protected]>
|
Thanks for the review, and for the careful notes. I pushed aae5551 for them. On the first one, I left the decideChild move where it is. It doesn't change behaviour, and pulling it out now would mean rewriting a PR that's already approved. I added a line to the PR body saying it's prep for the issuance work. On the second, I didn't switch the four sites to IsJOSEType. Doing that would make the auth server start redeeming While I was in there I also removed the ID-JAG case from the plain JWT-bearer handler's typ allowlist. It was unreachable, since IDJAGHandler claims the exact type first, and it would only matter if routing and the allowlist ever drifted apart. The tests now pin that variant spellings are refused and that the two matchers never both claim the same assertion. xaa.go is unchanged. Its typ check only logs. |
rdimitrov
left a comment
There was a problem hiding this comment.
Re-review of aae5551: still approve. The new commit changes no reachable behaviour and keeps everything the earlier approval relied on.
The push keeps exact typ matching on the accept side (variant spellings such as application/oauth-id-jag+jwt are refused, which is now documented as intended rather than a gap). It also drops oauth-id-jag+jwt from validateAssertionType's allowlist and adds tests that pin the two routing predicates as exact complements. The allowlist entry was unreachable, because JWTBearerHandler.CanHandleTokenEndpointRequest already declines exact ID-JAGs before validateAssertionType runs. IDJAGHandler never calls that function, so redemption is unaffected. Removing the entry hardens the plain handler: if routing ever drifted, a misrouted ID-JAG could no longer slip through the path that allows skipping client authentication. Issuers see the same behaviour as on main. The deny side (rejectIDJAGType, pkg/auth/token.go) still uses IsJOSEType, so no spelling of the ID-JAG type is accepted as an access token.
🤖 Reviewed with Claude Code
Summary
An ID-JAG is an assertion for an authorization server, not an access token. If an issuer signs both with the same key, an ID-JAG could otherwise pass access-token validation when its other claims satisfy the checks. Future ID-JAG issuance also needs to distinguish a live exchange grant from one eligible to derive a child.
Refs #6898. This PR does not implement ID-JAG issuance and does not close that issue.
Type of change
Test plan
task test) — full run not done. Scoped race tests onpkg/authserver/server/tokenexchangepass on aae5551.task test-e2e)task lint-fix) — not run repo-wide.golangci-lintonpkg/authserver/server/tokenexchangereports 0 issues on aae5551.git diff --exit-code ecfa3714a HEAD; confirmed the commit-message edits did not change the code.Changes
application/type matching; use it for the vMCP ID-JAG diagnostic.Does this introduce a user-facing change?
Before, an ID-JAG could be accepted where an access token was expected if its signature and claims passed the applicable checks. After, a JWT identifying itself as an ID-JAG is rejected at those boundaries. Existing ID-JAG assertion redemption remains separate. Missing or non-string
typheaders are not rejected by this targeted check.Special notes for reviewers
decideChildseparately checks whether it may create a child. This allows a future ID-JAG issuance path to validate a live child grant without treating it as eligible for further derivation.typexactly (oauth-id-jag+jwt), as the ID-JAG draft requires of an issuer. Case andapplication/variants are refused as access tokens and also refused at redemption withinvalid_grant; they fail closed. This is deliberately narrower than the deny side, and will be revisited if an issuer is found to emit a variant spelling. The last commit also removes an unreachable ID-JAG case from the plain handler'stypallowlist (IDJAGHandlerclaims the exact type first), with no behaviour change.0cc46ba12is prep for the ID-JAG issuance work and changes no behaviour.