Repository navigation
Refuse ID-JAGs with a multi-valued aud - #7204
Conversation
Delegated access: subject mapping at ID-JAG redemption (#6887) requires the ID-JAG's aud to name exactly one audience. Until now redemption accepted an aud array with two elements, logged it as a draft departure and went on to issue a token. ID-JAG draft -06 defines aud as the issuer identifier of the Resource Authorization Server, a single value; an array that names several servers lets one ID-JAG be presented to each of them. Redemption now refuses it with invalid_grant and invalid_assertion before the assertion is consumed, for every issuer. This is a client-visible change for every issuer: a two-element aud that was accepted and logged is now refused. A single-element array and a string aud behave as before. The multiple_audiences departure is removed because it can no longer occur. Refs #6887 Co-authored-by: Mecatl <[email protected]>
rdimitrov
left a comment
There was a problem hiding this comment.
Draft review: the code is right and well placed; a few things to settle before it leaves draft.
Design: The ID-JAG-specific policy lives in IDJAGHandler, and the check sits in IDJAGHandler.validateAssertion. The shared ValidateJWTBearerAssertion / audienceIntersects path stays untouched, so the plain RFC 7523 handler keeps accepting multi-valued aud. The only ID-JAG entry point is HandleTokenEndpointRequest, and the refusal runs before the replay consume, so a refused assertion isn't burned. On upgrade, any IdP that sends aud: [issuer, something-else] now gets 400 invalid_grant instead of a token plus a WARN, for every issuer and with no opt-out.
Findings:
docs/arch/17-token-exchange-delegation.md:1598: "A strict mode would have to refuse these two as well as the two logged findings" is stale. Only one logged finding (audience_not_issuer) remains. Update it.- Rollout:
multiple_audienceswas warn-only first shipped in v0.65.0, and the current tag is v0.66.0, so there is about one release of warning before a hard refusal. The arch doc frames the analogous client-auth case as "deprecated, a later release will require...". Please state in the PR why a hard refusal is acceptable here (e.g. draft -06 §4.4.1 makesaudthe single issuer identifier, and no supported IdP emits a multi-valuedaud), or release-note it as breaking. - Stale docs: the
accepted_audiencesdescription (Go doc comment,docs/server/swagger.*,crd-api.md) still says the assertion'saud"must intersect" the accepted set. For ID-JAG that is no longer the full story; regenerate after fixing the comment. - Tests: the multi-aud case only runs against the mock validator (
id_jag_handler_test.go:221). Add (a) a check that a refused multi-aud ID-JAG is not consumed (a retry fails identically / consumer not called), and (b) one case through the real validator, sinceTestIDJAGHandler_RealValidatorRedeemsIssuerAudienceonly covers singleaud. - The test plan boxes are unchecked.
Simpler alternative: none; the change is already minimal.
🤖 Reviewed with Claude Code
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7204 +/- ##
==========================================
+ Coverage 81.56% 81.58% +0.02%
==========================================
Files 898 898
Lines 91491 91542 +51
==========================================
+ Hits 74622 74684 +62
+ Misses 16864 16853 -11
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The accepted_audiences description still said the assertion's aud only has to intersect the accepted set, and the arch doc still counted two logged findings after multiple_audiences was removed. Say that the ID-JAG grant refuses an aud array with more than one value, fix the finding count, and regenerate the swagger and SDK files. Run the real multi-issuer validator with a two-value aud, so the refusal is covered end to end and shown not to consume the assertion. Co-authored-by: Mecatl <[email protected]>
|
Thanks, pushed 696ba1b for these.
I did not check whether any IdP in the wild emits a multi-valued |
rdimitrov
left a comment
There was a problem hiding this comment.
Re-review of 696ba1b: approve. The earlier findings are resolved or answered, and the new commit adds no significant issue.
- Stale "two logged findings" sentence in the arch doc: resolved (now "the logged finding").
- Rollout justification: resolved. The PR body now cites the draft's multi-valued
audrule and explains the hard refusal; ID-JAG redemption is new and the draft is unstable, so that holds. - Stale
accepted_audiencesdocs: resolved. The Go comment, swagger/SDK output and arch doc now state the plain-grant vs ID-JAG difference.crd-api.mdnever had the "must intersect" claim, so the author was right there. - Tests: resolved.
TestIDJAGHandler_RealValidatorAudienceruns a multi-aud assertion through the real validator and checksinvalid_grantand that the assertion is not consumed, which covers the replay point. - Test plan boxes: resolved. They now match what was run.
Design: unchanged. The refusal stays in IDJAGHandler.validateAssertion, ahead of policy, jti and consume. The plain JWT-bearer handler, the other caller of ValidateJWTBearerAssertion, deliberately keeps accepting multi-valued aud.
Two non-blocking leftovers: the reflowed paragraph at docs/arch/17-token-exchange-delegation.md:1346 is over-long, and the AcceptedAudiences CRD comment could mention the refusal. Please confirm lint is green in CI.
🤖 Reviewed with Claude Code
Summary
audas the issuer identifier of the Resource Authorization Server, a single value. Redemption accepted anaudarray with two elements and only logged amultiple_audiencesdraft departure. An array that names several servers lets one ID-JAG be presented to each of them, and subject mapping at redemption ("Delegated access: subject mapping at ID-JAG redemption") needs exactly one audience to bind to.audarray with more than one value with400 invalid_grantandinvalid_assertion: The ID-JAG assertion aud must name exactly one audience., for every issuer. The check runs right after the assertion is verified, before the assertion is consumed, so a refused assertion is not burned.multiple_audiencesdeparture and its tests are removed because it can no longer occur.docs/arch/17-token-exchange-delegation.mdgets a new refusal row and drops the finding.Refs #6887
Type of change
Test plan
task test)task test-e2e)task lint-fix)Ran the tokenexchange package tests with the
task testflags (-race), andtask docs-verify(the generated swagger and SDK files match). The fulltask testandtask lint-fixwere not run.Added a
TestIDJAGHandler_ClientBindingAndJTIcase for the two-elementaud(it also asserts the assertion is not consumed), and a case inTestIDJAGHandler_RealValidatorAudiencethat sends a two-valueaudthrough the real multi-issuer validator. The departure-logging tests now use single audiences.Does this introduce a user-facing change?
Yes, for every issuer.
audas a two-element array was accepted, logged asmultiple_audiences, and a token was issued.400 invalid_grant,invalid_assertion: The ID-JAG assertion aud must name exactly one audience.A one-element array and a string
audbehave as before.Special notes for reviewers
Hard refusal after one release of warning.
multiple_audienceswas warn-only from v0.65.0, and the current tag is v0.66.0. The client-authaudchecks (see the arch doc, "deprecated, a later release will require...") get a deprecation period first; this one deliberately does not. The reason is that draft -06 §4.4.1 makesaudthe single issuer identifier, and an array lets one ID-JAG be presented to every server it names. There is no opt-out. An IdP that sendsaud: [issuer, other]now gets400 invalid_grantinstead of a token plus a WARN.The refusal comes before the "issuer not enabled for this grant" check, so a multi-valued
audfrom a non-enabled issuer gets theauderror instead. Both areinvalid_grant.The plain RFC 7523 handler is unchanged; it still accepts a multi-valued
aud.