Repository navigation
Refuse unauthenticated ID-JAG clients and cnf-bound assertions - #7214
Conversation
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>
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
rdimitrov
left a comment
There was a problem hiding this comment.
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 onclient_idalone now get 401invalid_client, and credential-less requests move from 400invalid_requestto 401invalid_client. Please carry this into the release notes as a breaking change. - The
cnfrefusal on the plain RFC 7523 grant goes beyond draft §9.11, which only covers ID-JAGs. A deployment whose IdP stampscnfon ordinary assertions will start failing withinvalid_grantand 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
|
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. |
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:
invalid_client. The handler accepted a public client identified only byclient_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.cnfwas ignored. Draft §9.11 says a server that cannot verify the confirmation method of an ID-JAG with acnfclaim MUST refuse it withinvalid_grant. Nothing readcnf, so an ID-JAG the IdP had key-bound was redeemed as a bearer token and the binding was silently lost.What changed:
invalid_clientand the reasonclient_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.CanSkipClientAuthnow returns true for a request with no credentials at all, so that request gets this refusal instead of fosite'sinvalid_request.cnf, with any value includingnull, before it is consumed. Only presence counts.docs/arch/17-token-exchange-delegation.mdis updated: the refusal table, the bound ID-JAG section, the audience section, and the removed "departures" paragraph.Closes #6984
Type of change
Test plan
go test -raceonpkg/authserver/server/tokenexchangeandpkg/authserver(includes the HTTP integration tests)task test-e2e)golangci-lintandgo veton the same packagesNew tests cover:
invalid_client, and the ID-JAG is not consumed: a confidential client redeems the same ID-JAG afterwards.cnfas an object,nulland{}, in the full claim set or only inExtra, is refused on both grants, and an assertion withoutcnfstill redeems.Changes
pkg/authserver/server/tokenexchange/id_jag_handler.goHandleTokenEndpointRequest;CanSkipClientAuthfor credential-less requests;cnfrefusal invalidateAssertion;checkClientBindingreuses the same refusal as a backstoppkg/authserver/server/tokenexchange/jwt_bearer_handler.gomayCarryClientCredentialsandhasConfirmationClaim;cnfrefusal on the plain grantpkg/authserver/server/tokenexchange/redemption_refusal.goclient_authentication_requiredreason, sent with 401pkg/authserver/**/*_test.godocs/arch/17-token-exchange-delegation.mdDoes 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 carryingcnfare refused on both the ID-JAG and the plain RFC 7523 JWT-bearer grant, with no opt-out. Release notes should list both.token_endpoint_auth_method: none, or any CIMD client) named in the ID-JAG'sclient_idcould redeem it by sending only itsclient_id. After: 401invalid_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_postorprivate_key_jwt).invalid_request. After: 401invalid_clientwith theclient_authentication_requiredreason, the same status fosite uses for its owninvalid_client. The ID-JAG is not validated or consumed.cnfare refused on both grants. Before: an assertion with acnfclaim (RFC 7800) was redeemed as a bearer credential and the key binding was dropped. After: 400invalid_grant,invalid_assertion: The ID-JAG assertion must not carry a 'cnf' claim.for an ID-JAG, andinvalid_assertion: The JWT bearer assertion must not carry a 'cnf' claim.for a plain RFC 7523 assertion. Any value is refused, includingnull.ToolHive's own callers are unaffected: AS-1 never puts
cnfin 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
allow_public_id_jag_clients) andunauthorized_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: thejtistays unconsumed, and confidential,private_key_jwtand SPIFFE clients are unaffected.invalid_clientin every case and requires it when the client used theAuthorizationheader. Using 401 always matches fosite's owninvalid_clientand avoids inspecting the header.cnfrefusal 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.cnfon 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 refusescnffor 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 noWWW-Authenticateheader, 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.