Skip to content

Refuse unauthenticated ID-JAG clients and cnf-bound assertions - #7214

Merged
jhrozek merged 3 commits into
mainfrom
as2-idjag-require-client-auth
Nov 22, 2026
Merged

jhrozek merged 3 commits into
mainfrom
as2-idjag-require-client-auth

Conversation

@jhrozek

@jhrozek jhrozek commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

ID-JAG redemption at the embedded auth server departed from draft-ietf-oauth-identity-assertion-authz-grant-06 in two places, and both made a leaked ID-JAG a full bearer credential:

  • Public clients could redeem. Draft §4.4 says the server MUST reject a request that has neither client authentication nor a sender-constrained ID-JAG, with invalid_client. The handler accepted a public client identified only by client_id, on the grounds that the assertion is single-use, short-lived and audience-pinned. Draft §9.1 rejects that: single use only decides who redeems a leaked copy first.
  • cnf was ignored. Draft §9.11 says a server that cannot verify the confirmation method of an ID-JAG with a cnf claim MUST refuse it with invalid_grant. Nothing read cnf, so an ID-JAG the IdP had key-bound was redeemed as a bearer token and the binding was silently lost.

What changed:

  • The ID-JAG handler refuses a public client, and a request with no client credentials, with invalid_client and the reason client_authentication_required. The check runs before the assertion is validated or consumed, so an unauthenticated caller learns nothing about the ID-JAG and the ID-JAG stays redeemable by the right client. IDJAGHandler.CanSkipClientAuth now returns true for a request with no credentials at all, so that request gets this refusal instead of fosite's invalid_request.
  • Both the ID-JAG handler and the plain RFC 7523 handler refuse an assertion that carries cnf, with any value including null, before it is consumed. Only presence counts.
  • Both refusals stay until proof of possession (DPoP or mTLS) can be verified.
  • docs/arch/17-token-exchange-delegation.md is updated: the refusal table, the bound ID-JAG section, the audience section, and the removed "departures" paragraph.

Closes #6984

Type of change

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

Test plan

  • Unit tests: go test -race on pkg/authserver/server/tokenexchange and pkg/authserver (includes the HTTP integration tests)
  • E2E tests (task test-e2e)
  • Linting: golangci-lint and go vet on the same packages
  • Manual testing (describe below)

New tests cover:

  • A public client redeeming a valid ID-JAG gets 401 invalid_client, and the ID-JAG is not consumed: a confidential client redeems the same ID-JAG afterwards.
  • No credentials, a nil client and fosite's empty-ID placeholder are refused the same way, before the assertion is validated.
  • cnf as an object, null and {}, in the full claim set or only in Extra, is refused on both grants, and an assertion without cnf still redeems.

Changes

File Change
pkg/authserver/server/tokenexchange/id_jag_handler.go Client-auth refusal first in HandleTokenEndpointRequest; CanSkipClientAuth for credential-less requests; cnf refusal in validateAssertion; checkClientBinding reuses the same refusal as a backstop
pkg/authserver/server/tokenexchange/jwt_bearer_handler.go Shared mayCarryClientCredentials and hasConfirmationClaim; cnf refusal on the plain grant
pkg/authserver/server/tokenexchange/redemption_refusal.go client_authentication_required reason, sent with 401
pkg/authserver/**/*_test.go Unit and HTTP integration tests above; fixtures that redeemed as a public client now authenticate
docs/arch/17-token-exchange-delegation.md Refusal table, bound ID-JAG section, audience section

Does this introduce a user-facing change?

Yes. Breaking: public clients (CIMD, and DCR with token_endpoint_auth_method: none) can no longer redeem an ID-JAG, and assertions carrying cnf are refused on both the ID-JAG and the plain RFC 7523 JWT-bearer grant, with no opt-out. Release notes should list both.

  • Public clients can no longer redeem an ID-JAG. Before: a public client (DCR with token_endpoint_auth_method: none, or any CIMD client) named in the ID-JAG's client_id could redeem it by sending only its client_id. After: 401 invalid_client, client_authentication_required: The ID-JAG grant requires client authentication. To keep redeeming, register the redeeming client as confidential (client_secret_basic, client_secret_post or private_key_jwt).
  • ID-JAG requests with no client credentials get a different error. Before: fosite's invalid_request. After: 401 invalid_client with the client_authentication_required reason, the same status fosite uses for its own invalid_client. The ID-JAG is not validated or consumed.
  • Assertions that carry cnf are refused on both grants. Before: an assertion with a cnf claim (RFC 7800) was redeemed as a bearer credential and the key binding was dropped. After: 400 invalid_grant, invalid_assertion: The ID-JAG assertion must not carry a 'cnf' claim. for an ID-JAG, and invalid_assertion: The JWT bearer assertion must not carry a 'cnf' claim. for a plain RFC 7523 assertion. Any value is refused, including null.

ToolHive's own callers are unaffected: AS-1 never puts cnf in an ID-JAG it mints, and the vMCP XAA strategy always sends a client secret when a target client is configured.

Special notes for reviewers

  • How this differs from the fix proposed in Reconsider public-client redemption of ID-JAG assertions in the embedded AS #6984. The issue proposed a per-issuer opt-in (allow_public_id_jag_clients) and unauthorized_client, based on draft-04, where confidential clients were a SHOULD. Draft-06 §4.4 makes it a MUST and names the error, invalid_client, so this PR refuses public clients outright with that error. There is no opt-in: no known deployment needs one (vMCP's XAA strategy, Mecatl and the XAA demo setups all use confidential clients), and one can be added if a user asks. The issue's other acceptance points hold: the jti stays unconsumed, and confidential, private_key_jwt and SPIFFE clients are unaffected.
  • 401 for every client-authentication refusal. RFC 6749 §5.2 allows 401 for invalid_client in every case and requires it when the client used the Authorization header. Using 401 always matches fosite's own invalid_client and avoids inspecting the header.
  • The plain-grant cnf refusal is a choice, not a draft requirement. §9.11 covers ID-JAGs only. The same reasoning applies to a plain assertion: accepting it silently drops a binding the issuer asked for. The plain grant's client handling does not change: it still does not require client authentication.
  • RFC 8693 token exchange does not check cnf on its subject or actor tokens, so a key-bound token is still accepted there as a bearer token. That is the same gap this PR closes for assertions, and is left out on purpose to keep this PR to the two assertion grants.
  • as2-local-user-resolution: commit 3b73e24e8 there refuses cnf for resolve issuers only. Once this PR lands, that part of the commit, with its doc rows and test, is redundant and can be dropped when that branch is ported.
  • WWW-Authenticate: the new 401 has no WWW-Authenticate header, like every other 401 the token endpoint sends today (fosite never sets it). That is fixed for all token-endpoint 401s in a separate PR.

jhrozek and others added 3 commits November 22, 2026 10:25
Draft-ietf-oauth-identity-assertion-authz-grant-06 section 4.4 says
the resource authorization server MUST reject a request that has
neither client authentication nor a sender-constrained ID-JAG, with
invalid_client. The ID-JAG handler accepted a public client that was
identified only by client_id, on the reasoning that the assertion is
the credential. The draft rejects that in section 9.1: single use only
decides who redeems a leaked copy first.

The handler now refuses a public client, a nil client and fosite's
empty-ID placeholder client with invalid_client and the reason
client_authentication_required, before the assertion is parsed,
validated or consumed. The status is 401, the same as fosite's own
invalid_client; RFC 6749 section 5.2 allows 401 for invalid_client in
every case. Refusing first also gives an unauthenticated caller no way
to learn whether an ID-JAG is valid. The later client binding check
returns the same refusal, as a backstop if the checks are reordered.

IDJAGHandler.CanSkipClientAuth now returns true for a request with no
client credentials at all, so that request reaches the handler and gets
this refusal instead of fosite's invalid_request. The check is shared
with the plain JWT-bearer handler, whose behaviour does not change.

Public clients stay refused until a sender-constrained ID-JAG (proof
of possession, DPoP or mTLS) can be verified.

Closes #6984

Co-authored-by: Mecatl <noreply@mecatl.dev>
Draft-ietf-oauth-identity-assertion-authz-grant-06 section 9.11 says
an ID-JAG with a cnf claim needs proof of possession, and a server that
cannot verify the confirmation method MUST refuse it with
invalid_grant. Nothing at this server read cnf, so an ID-JAG that the
IdP had key-bound was accepted as a plain bearer credential and the
binding was silently lost.

IDJAGHandler.validateAssertion now refuses an ID-JAG with a cnf claim,
for every issuer, before the assertion is consumed. Only the presence
of the claim counts, in the full claim set or in Extra, so "cnf": null
and "cnf": {} are refused too. The check lives in the ID-JAG handler,
not in the shared validator, so other grants are unchanged.

The refusal applies until proof of possession (DPoP or mTLS) is
verified.

Co-authored-by: Mecatl <noreply@mecatl.dev>
An RFC 7800 cnf claim means the issuer expects the presenter to prove
possession of a key. The plain RFC 7523 handler never read it, so an
assertion the issuer had key-bound was accepted as an ordinary bearer
credential and the binding was silently dropped. Draft-ietf-oauth-
identity-assertion-authz-grant-06 section 9.11 requires a server that
cannot verify the confirmation method to refuse; the same reasoning
applies to a plain assertion.

JWTBearerHandler now refuses an assertion with a cnf claim with
invalid_grant, before anything is consumed, using the presence check
shared with the ID-JAG handler ("cnf": null is refused too). The plain
grant's client handling does not change: it still authenticates no
client.

The refusal applies until proof of possession (DPoP or mTLS) is
verified.

Co-authored-by: Mecatl <noreply@mecatl.dev>
@jhrozek
jhrozek requested a review from ChrisJBurns as a code owner November 22, 2026 09:29
@github-actions github-actions Bot added the size/L Large PR: 600-999 lines changed label Nov 22, 2026
@codecov

codecov Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.60%. Comparing base (2d33d6b) to head (2e6ae06).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7214      +/-   ##
==========================================
+ Coverage   81.58%   81.60%   +0.01%     
==========================================
  Files         898      898              
  Lines       91550    91570      +20     
==========================================
+ Hits        74692    74723      +31     
+ Misses      16853    16842      -11     
  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 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.

Approve: the client-authentication and cnf checks are made at the right layer and close the "leaked ID-JAG as bearer token" hole.

Design: Client authentication is decided in the ID-JAG grant handler (fosite only authenticates; CanSkipClientAuth decides whether a failure is tolerated), and the PR checks it before any assertion work, so an unauthenticated caller learns nothing and the jti is not consumed. CanSkipClientAuth now returns true only for requests with no credentials at all and fails closed when the raw request is missing, and the plain JWT-bearer handler already refused ID-JAG assertions, so there is no side door. The cnf refusal sits in the shared assertion validation, so both grants are covered. Upgrade impact is behavioural only (no flags, CRDs or persisted state), and the PR body states it.

Things to be aware of (not blocking):

  • Public and CIMD clients (and DCR clients with token_endpoint_auth_method: none) that redeemed an ID-JAG on client_id alone now get 401 invalid_client, and credential-less requests move from 400 invalid_request to 401 invalid_client. Please carry this into the release notes as a breaking change.
  • The cnf refusal on the plain RFC 7523 grant goes beyond draft §9.11, which only covers ID-JAGs. A deployment whose IdP stamps cnf on ordinary assertions will start failing with invalid_grant and has no opt-out. The reasoning (don't silently drop a binding) is defensible; just call it out in the release notes too.

🤖 Reviewed with Claude Code

@jhrozek

jhrozek commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Agreed on both points. I added a Breaking line at the top of the user-facing section so the release notes pick up both the public-client refusal (including the 400 invalid_request to 401 invalid_client move for credential-less requests) and the plain-grant cnf refusal. The plain-grant one is a single check in JWTBearerHandler.validateAssertion, so it's easy to back out if someone turns up with an IdP that stamps cnf on ordinary assertions.

@github-actions github-actions Bot added size/L Large PR: 600-999 lines changed and removed size/L Large PR: 600-999 lines changed labels Nov 22, 2026
@jhrozek
jhrozek merged commit 4b6b17d into main Nov 22, 2026
48 checks passed
@jhrozek
jhrozek deleted the as2-idjag-require-client-auth branch November 22, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Large PR: 600-999 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reconsider public-client redemption of ID-JAG assertions in the embedded AS

2 participants