Skip to content

Narrow authorization_details on token exchange and refresh #6912

Open

Description

@jhrozek

Part of #6909. Token-exchange part depends on #6910 (the subject token must carry
details). Refresh part depends on #6913.

Problem: with #6894, a token exchange can return details that the subject
token never had. The Grant hook can refuse that, but nothing makes it check.
For audience, ToolHive already enforces "never wider than the subject token":
ensureAudienceSubsetOfSubject in
pkg/authserver/server/tokenexchange/handler.go refuses with invalid_target.
Details need the same rule.

RFC 9396 §6 says the AS checks whether the underlying grant allows the
requested details and otherwise refuses with invalid_authorization_details.
It names authorization_code and refresh_token. Treating the subject token as
the underlying grant for token exchange is our reading, not something RFC 9396
or RFC 8693 states. §6.1 says there is no standard way to compare two sets of
details, that the comparison depends on the type definition, and that the AS
should not rely on simple object comparison in most cases.

Change:

  • Each type may provide a Covers(granted, requested) hook.
  • Token exchange: when the subject token carries authorization_details, every
    requested entry must be covered by an entry of the same type in the subject
    token. Otherwise refuse with invalid_authorization_details (RFC 9396 §6,
    §8). A type that has entries in the subject token but no Covers hook allows
    only entries identical to the subject token's entries (RFC 8259 equality, as
    RFC 9396 §12 requires for strings).
  • If the request leaves out authorization_details, the issued token carries
    the subject token's details for the new audience (filtered as in Convey granted authorization_details to resource servers #6910). RFC 9396
    §7 leaves this to the AS.
  • Refresh: a refresh request with authorization_details must be covered by the
    details stored with the grant. Without the parameter, the stored details
    apply. Same rule as for scope in RFC 6749 §6. The stored grant is not
    changed (RFC 9396 §6.1).
  • Run the check before the Grant hook, so a hook never sees a request wider
    than the subject token.

Acceptance:

  • Exchanging a token with write on repo X for read on repo X succeeds when
    the type's Covers says write covers read. Asking for repo Y is refused.
  • A type without Covers accepts only identical entries.
  • A refresh can narrow but never widen, and the next refresh without the
    parameter gets the original stored details back.

Open questions:

  • Should locations (§2.2) be checked against the granted audience, the way
    §12 suggests it limits where a token is used? That would tie this rule to
    ensureAudienceSubsetOfSubject.
  • External subject tokens (trusted issuers): use their authorization_details
    claim as the upper bound, or ignore it and let the Grant hook decide?
  • Refresh grants run inside fosite. Can this use the handler seam proposed in
    authserver: let embedders validate refresh-token grants, and type upstream refresh rejections #6901?

Activity

  1. added
    needs-triage
    on Oct 22, 2026
  2. removed
    needs-triage
    on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions