Skip to content

Prevent ID-JAGs from being used as access tokens - #7089

Merged
jhrozek merged 3 commits into
mainfrom
idjag-pr-2
Nov 10, 2026
Merged

jhrozek merged 3 commits into
mainfrom
idjag-pr-2

Conversation

@jhrozek

@jhrozek jhrozek commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

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.

  • Prevent token-type confusion by rejecting ID-JAGs in resource-server and token-exchange access-token validation, while keeping assertion redemption separate.
  • Prepare for issuing ID-JAGs from grants by separating grant validity from child-derivation eligibility. The existing child-derivation checks and refusal order remain unchanged.

Refs #6898. This PR does not implement ID-JAG issuance and does not close that issue.

Type of change

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

Test plan

  • Unit tests (task test) — full run not done. Scoped race tests on pkg/authserver/server/tokenexchange pass on aae5551.
  • E2E tests (task test-e2e)
  • Linting (task lint-fix) — not run repo-wide. golangci-lint on pkg/authserver/server/tokenexchange reports 0 issues on aae5551.
  • Manual verification — compared the final commit tree with the pre-amend tree using git diff --exit-code ecfa3714a HEAD; confirmed the commit-message edits did not change the code.

Changes

Area Change
Exchange grants Validate grant liveness separately from child-derivation eligibility.
Auth server Reject ID-JAG types in self-issued and external access-token validation, including subject and actor tokens.
Resource authentication Reject ID-JAGs presented as bearer access tokens.
JOSE and vMCP Share case-insensitive, optional application/ type matching; use it for the vMCP ID-JAG diagnostic.
Tests and documentation Cover grant validation and type handling; document the observable rejection.

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 typ headers are not rejected by this targeted check.

Special notes for reviewers

  • Exchange-grant validation checks whether the grant is live and belongs to the client; decideChild separately 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.
  • JWT-bearer redemption compares the ID-JAG typ exactly (oauth-id-jag+jwt), as the ID-JAG draft requires of an issuer. Case and application/ variants are refused as access tokens and also refused at redemption with invalid_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's typ allowlist (IDJAGHandler claims the exact type first), with no behaviour change.
  • 0cc46ba12 is prep for the ID-JAG issuance work and changes no behaviour.

jhrozek and others added 2 commits November 9, 2026 15:52
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]>
@github-actions github-actions Bot added the size/M Medium PR: 300-599 lines changed label Nov 9, 2026
@codecov

codecov Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.89%. Comparing base (2d1093f) to head (aae5551).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...ver/server/tokenexchange/multi_issuer_validator.go 87.50% 1 Missing ⚠️
pkg/authserver/server/tokenexchange/validator.go 87.50% 1 Missing ⚠️
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.
📢 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.

rdimitrov
rdimitrov previously approved these changes Nov 9, 2026

@rdimitrov rdimitrov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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:

  1. pkg/authserver/server/tokenexchange/refresh_token_handler.go:402: moving the ParentSignature/IssuableTokenTypes check into decideChild doesn't change behaviour (presentedGrant has one caller), but it is prep for ID-JAG issuance, not this fix. Worth its own PR, or landing with the issuance work.
  2. jwt_bearer_handler.go:117, :134, :391 and id_jag_handler.go:96 still compare typ exactly, and the PR documents that gap in a code comment and docs/arch/11-auth-server-storage.md instead of switching those four sites to the new oauthproto.IsJOSEType. It fails closed today (application/oauth-id-jag+jwt routes to the JWT-bearer handler and validateAssertionType refuses it). The pkg/vmcp/auth/strategies/xaa.go:288 change already accepts the application/ 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]>
@jhrozek

jhrozek commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

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 application/oauth-id-jag+jwt, which it refuses today. That's an accept-side change on a different endpoint than this deny-only PR, and I don't know of an issuer that sends that spelling. The ID-JAG draft only says the typ must be oauth-id-jag+jwt and doesn't spell out a comparison rule, so staying exact on redemption is a conservative choice, not a spec requirement. I reworded the code comment and the arch doc from "known gap" to say it's intentional and fails closed, and that we'll revisit it if an issuer shows up emitting a variant. I haven't opened a tracking issue for now.

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.

@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Nov 9, 2026

@rdimitrov rdimitrov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

@jhrozek
jhrozek merged commit 965db4d into main Nov 10, 2026
48 checks passed
@jhrozek
jhrozek deleted the idjag-pr-2 branch November 10, 2026 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Medium PR: 300-599 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants