Repository navigation
Description
Bug description
The ID-JAG redemption handler takes the target resource only from the token request form and never reads the assertion's resource claim.
pkg/authserver/server/tokenexchange/id_jag_handler.go:131callsvalidateJWTBearerPolicy(requester.GetRequestForm(), ...). That function (jwt_bearer_handler.go:233-251) requires exactly one non-empty formresource(anything else isinvalid_request) and matches it against the subject binding'sAllowedResources.ValidatedClaimshas no resource field, so the claim ends up inExtra["resource"](validator.go,assignClaim) and nothing reads it.
draft-ietf-oauth-identity-assertion-authz-grant-04 (the current revision, and the one the code's section references match):
- §4.4 defines the token request parameters as only
grant_typeandassertion. Its example sends noresource. - §3.1 defines the
resourceclaim as optional, a single URI or an array. - §4.4.1: "If the resource claim is present, the Resource Authorization Server MUST process it according to Section 2 of [RFC8707]." The granted resources MAY be a subset of the claim's.
- §4.4.1 also requires the access token response to include the granted resource, scope and authorization_details when present. ToolHive's response does not return the granted resource.
Steps to reproduce
- Enable the JWT-bearer grant for an issuer whose subject binding lists resources A and B.
- Redeem an ID-JAG (
typ: oauth-id-jag+jwt,resource: A) with onlygrant_typeandassertion. The server answersinvalid_request. - Redeem the same kind of ID-JAG with
resource=Bin the form. The server issues a token for B, although the IdP granted A.
Steps 2 and 3 are from reading the code and the existing tests, not from an end-to-end run.
Expected behavior
The resource claim decides the resource, or bounds it when the form also names one. A request without a form resource succeeds when the resource is unambiguous. The response includes the granted resource.
Actual behavior
A form resource is required and the claim is ignored. Two consequences:
- Interop. A client that follows the draft gets
invalid_request. The requesting side in this repo does exactly that:pkg/vmcp/auth/strategies/xaa.go:386(performTargetGrant) usesjwtbearer.buildFormData(pkg/oauthproto/jwtbearer/grant.go:177), which sends onlygrant_type,assertionandscope. So vMCP's XAA strategy cannot redeem at a ToolHive authorization server. - Resource substitution. A client holding an ID-JAG issued for A can ask for B, and gets it whenever the subject's binding lists B. The IdP administrator's per-resource decision is not enforced. Bindings are keyed by subject, not by client.
Additional context
These checks already bound the substitution: the subject binding's AllowedResources (each entry must be in allowed_audiences, jwt_bearer_handler.go:521-536), aud, the client_id binding, the single-use jti, and the assertion age cap. Nothing escapes ToolHive's local policy; what is lost is the IdP-side bound.
Tests that pin today's behavior: jwt_bearer_handler_test.go:333 ("missing resource" expects invalid_request), id_jag_handler_test.go:101 (the request helper always sets a form resource), pkg/authserver/integration_test.go (the ID-JAG signer emits no resource claim). Docs: docs/arch/17-token-exchange-delegation.md describes the exactly-one-resource requirement for both handlers.
The plain RFC 7523 handler is out of scope.
Proposed fix
Change the ID-JAG handler only. Parse the claim as a string or an array of absolute URIs without fragments (malformed: invalid_grant). A repeated or malformed form resource keeps its current errors.
| Claim | Form resource |
Result |
|---|---|---|
| present | absent | exactly one claim entry is in AllowedResources: grant it. None, or more than one: invalid_target |
| present | present | form value in the claim and allowed: grant it. Otherwise invalid_target |
| absent | present | unchanged: grant if allowed, else invalid_target |
| absent | absent | the binding has exactly one AllowedResource: grant it as the default. Otherwise invalid_target (today: invalid_request) |
Also return the granted resource in the token response and update the docs.
Behavior changes for existing callers: a form value outside the claim, accepted today if policy allows it, gets invalid_target. A caller that sends no form resource and got invalid_request now succeeds when the claim or a single-entry binding settles the resource.
Acceptance criteria
- A request with only
grant_typeandassertion, with aresourceclaim, succeeds. - A form
resourcethat is not in the claim is rejected withinvalid_target. - Unit tests cover every row above, with string and array claims and a malformed claim. Integration tests cover the claim-only and mismatch cases.
- The vMCP XAA strategy redeems successfully against the embedded authorization server in a test.
- The granted
resourceis in the token response. - The plain JWT-bearer handler's behavior and tests are unchanged.
Activity
pcbeingused333 commentedon Nov 7, 2026
I'd like to pick this up if nobody on the team has it yet. Plan, following your table: keep the plain JWT-bearer handler untouched, add an ID-JAG-only resolver that reads the
resourceclaim fromExtra(string or array,invalid_grantif malformed), applies the four rows (invalid_targetotherwise, single-entry binding as default), and returns the grantedresourcein the token response. Tests: a unit table for every row (string/array/malformed claim), integration cases for claim-only and mismatch, and an XAAperformTargetGranttest against the embedded AS; docs in 17-token-exchange-delegation.md updated. Could you assign it to me?jhrozek commentedon Nov 9, 2026
Sure, it would be nice to test the result against both xaa.dev sandbox (following the RFC) and a real Okta though, I remember their resource handling was different
jhrozek commentedon Nov 16, 2026
Closing as a duplicate of "ID-JAG redemption: compare the requested resource with the assertion's resource claim, and decide the default when it is omitted (#6892)", which carries the fix and the decided rules for a missing resource parameter and array claims. The spec references here should move there.