Skip to content

ID-JAG grant ignores the assertion's resource claim and requires a form resource #6983

Closed as not planned

Description

@jhrozek

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:131 calls validateJWTBearerPolicy(requester.GetRequestForm(), ...). That function (jwt_bearer_handler.go:233-251) requires exactly one non-empty form resource (anything else is invalid_request) and matches it against the subject binding's AllowedResources.
  • ValidatedClaims has no resource field, so the claim ends up in Extra["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_type and assertion. Its example sends no resource.
  • §3.1 defines the resource claim 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

  1. Enable the JWT-bearer grant for an issuer whose subject binding lists resources A and B.
  2. Redeem an ID-JAG (typ: oauth-id-jag+jwt, resource: A) with only grant_type and assertion. The server answers invalid_request.
  3. Redeem the same kind of ID-JAG with resource=B in 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) uses jwtbearer.buildFormData (pkg/oauthproto/jwtbearer/grant.go:177), which sends only grant_type, assertion and scope. 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_type and assertion, with a resource claim, succeeds.
  • A form resource that is not in the claim is rejected with invalid_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 resource is in the token response.
  • The plain JWT-bearer handler's behavior and tests are unchanged.

Activity

  1. pcbeingused333 commented on Nov 7, 2026

    @pcbeingused333
    Contributor

    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 resource claim from Extra (string or array, invalid_grant if malformed), applies the four rows (invalid_target otherwise, single-entry binding as default), and returns the granted resource in the token response. Tests: a unit table for every row (string/array/malformed claim), integration cases for claim-only and mismatch, and an XAA performTargetGrant test against the embedded AS; docs in 17-token-exchange-delegation.md updated. Could you assign it to me?

  2. removed
    needs-triageIssue needs initial triage by a maintainer
    on Nov 9, 2026
  3. jhrozek commented on Nov 9, 2026

    @jhrozek
    ContributorAuthor

    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

  4. jhrozek commented on Nov 16, 2026

    @jhrozek
    ContributorAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions