Skip to content

Refuse ID-JAGs with a multi-valued aud - #7204

Merged
jhrozek merged 2 commits into
mainfrom
as2-redemption-hardening-4-single-aud
Nov 20, 2026
Merged

jhrozek merged 2 commits into
mainfrom
as2-redemption-hardening-4-single-aud

Conversation

@jhrozek

@jhrozek jhrozek commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • ID-JAG draft -06 defines aud as the issuer identifier of the Resource Authorization Server, a single value. Redemption accepted an aud array with two elements and only logged a multiple_audiences draft 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.
  • Redemption now refuses an aud array with more than one value with 400 invalid_grant and invalid_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.
  • The multiple_audiences departure and its tests are removed because it can no longer occur. docs/arch/17-token-exchange-delegation.md gets a new refusal row and drops the finding.

Refs #6887

Type of change

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

Test plan

  • Unit tests (task test)
  • E2E tests (task test-e2e)
  • Linting (task lint-fix)
  • Manual testing (describe below)

Ran the tokenexchange package tests with the task test flags (-race), and task docs-verify (the generated swagger and SDK files match). The full task test and task lint-fix were not run.

Added a TestIDJAGHandler_ClientBindingAndJTI case for the two-element aud (it also asserts the assertion is not consumed), and a case in TestIDJAGHandler_RealValidatorAudience that sends a two-value aud through the real multi-issuer validator. The departure-logging tests now use single audiences.

Does this introduce a user-facing change?

Yes, for every issuer.

  • Before: an ID-JAG with aud as a two-element array was accepted, logged as multiple_audiences, and a token was issued.
  • After: the same ID-JAG is refused with 400 invalid_grant, invalid_assertion: The ID-JAG assertion aud must name exactly one audience.

A one-element array and a string aud behave as before.

Special notes for reviewers

  • Hard refusal after one release of warning. multiple_audiences was warn-only from v0.65.0, and the current tag is v0.66.0. The client-auth aud checks (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 makes aud the 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 sends aud: [issuer, other] now gets 400 invalid_grant instead of a token plus a WARN.

  • The refusal comes before the "issuer not enabled for this grant" check, so a multi-valued aud from a non-enabled issuer gets the aud error instead. Both are invalid_grant.

  • The plain RFC 7523 handler is unchanged; it still accepts a multi-valued aud.

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]>
@github-actions github-actions Bot added the size/XS Extra small PR: < 100 lines changed label Nov 19, 2026

@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.

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:

  1. 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.
  2. Rollout: multiple_audiences was 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 makes aud the single issuer identifier, and no supported IdP emits a multi-valued aud), or release-note it as breaking.
  3. Stale docs: the accepted_audiences description (Go doc comment, docs/server/swagger.*, crd-api.md) still says the assertion's aud "must intersect" the accepted set. For ID-JAG that is no longer the full story; regenerate after fixing the comment.
  4. 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, since TestIDJAGHandler_RealValidatorRedeemsIssuerAudience only covers single aud.
  5. The test plan boxes are unchecked.

Simpler alternative: none; the change is already minimal.

🤖 Reviewed with Claude Code

@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.58%. Comparing base (c310a81) to head (696ba1b).
⚠️ Report is 4 commits behind head on main.

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.
📢 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.

@jhrozek
jhrozek marked this pull request as ready for review November 20, 2026 11:08
@jhrozek
jhrozek requested a review from ChrisJBurns as a code owner November 20, 2026 11:08
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]>
@jhrozek

jhrozek commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks, pushed 696ba1b for these.

  • The "two logged findings" sentence in the arch doc now says "the logged finding". I also changed the accepted_audiences bullet in the same doc, which said an assertion may name other audiences without losing its match. That is now qualified: true for the plain JWT-bearer grant, not for ID-JAG.
  • The AcceptedAudiences doc comment now says the ID-JAG grant refuses an aud array with more than one value. I regenerated swagger and the SDK from it. crd-api.md has no "must intersect" text in this tree, so nothing changed there.
  • Added a real-validator case: a two-value aud through the multi-issuer validator is refused with the same description, and the consumer is not called. The existing two-element case in TestIDJAGHandler_ClientBindingAndJTI already asserts the consumer key stays empty, so I didn't add a separate retry test.
  • The PR body now explains the rollout. It is a hard refusal after one release of warning, on purpose, because -06 §4.4.1 makes aud the single issuer identifier. The test plan boxes are filled in, with what I did and didn't run.

I did not check whether any IdP in the wild emits a multi-valued aud, so the body doesn't claim that. I don't think this needs a breaking-change release note. ID-JAG redemption first shipped in v0.65.0, the draft is still a draft, and accepting a multi-valued aud was only ever a logged departure from -06 §4.4.1, never supported behaviour. It is listed as a user-facing change in the PR body.

@github-actions github-actions Bot added size/S Small PR: 100-299 lines changed and removed size/XS Extra small PR: < 100 lines changed labels Nov 20, 2026

@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.

Re-review of 696ba1b: approve. The earlier findings are resolved or answered, and the new commit adds no significant issue.

  1. Stale "two logged findings" sentence in the arch doc: resolved (now "the logged finding").
  2. Rollout justification: resolved. The PR body now cites the draft's multi-valued aud rule and explains the hard refusal; ID-JAG redemption is new and the draft is unstable, so that holds.
  3. Stale accepted_audiences docs: resolved. The Go comment, swagger/SDK output and arch doc now state the plain-grant vs ID-JAG difference. crd-api.md never had the "must intersect" claim, so the author was right there.
  4. Tests: resolved. TestIDJAGHandler_RealValidatorAudience runs a multi-aud assertion through the real validator and checks invalid_grant and that the assertion is not consumed, which covers the replay point.
  5. 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

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

Labels

size/S Small PR: 100-299 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants