Repository navigation
Require the issuer as the only client assertion aud - #7213
Conversation
rdimitrov
left a comment
There was a problem hiding this comment.
The check is correct and in the right place, but it is an unconditional breaking change that the PR and issue #7039 don't agree on.
Design: Enforcing the audience in front of fosite's client-authentication strategy is the right layer. Every client-authenticating endpoint goes through it, and narrowing GetTokenURLs to the issuer has no other consumer in this repo. The extra go-jose v4 "unreadable" refusal is needed because fosite parses with v3. The concern is the rollout: after upgrade, any client that sends the token URL as aud (Spring Security and authlib default to it) gets 401 invalid_client, and there is no switch to turn that off.
-
private_key_jwt_client_auth.go:50-55,:120: the behaviour change contradicts #7039, which says "with it off, behavior is unchanged" and asks what the default is so existing clients can migrate. The PR drops the option and rejects the token URL everywhere in one release. Your point about the replay hole is right for multi-valueaud, which is the real exploit. It is much weaker for a sole token-URLaud, which is a spec-conformance issue, and the old doc text promised a deprecation period. Suggested fix: always refuse multi-valueaud, and keep accepting a sole token-URLaudfor one more release with a deprecation WARN. Alternatively, get maintainer agreement that the hard break is intended and add an explicit breaking-change and migration note to the PR body and release notes. Also mention that during a rolling upgrade on shared Redis, old replicas accept the token URL and new ones refuse it, so clients can see intermittent 401s. -
private_key_jwt_client_auth.go:107-121,provider.go:746-755: the audience check now runs beforenexteven whenrecoverTimeErrorsis false, which is the path where a caller-suppliedClientAuthenticationStrategyis preserved. An embedder that sets its own strategy previously chose its own audience rules. Now everyprivate_key_jwtrequest is refused unlessaudis the issuer alone, before that strategy's client lookup runs. I found no in-repo setter, so this is a risk for embedders only. Suggested fix: apply the check only whenrecoverTimeErrorsis true, or say in the PR that this is deliberate. Moving it into its own small decorator wired inprovider.gowould make that choice explicit and leave the skew function's signature alone.
🤖 Reviewed with Claude Code
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7213 +/- ##
==========================================
+ Coverage 81.58% 81.64% +0.06%
==========================================
Files 898 898
Lines 91550 91601 +51
==========================================
+ Hits 74692 74790 +98
+ Misses 16853 16806 -47
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
A private_key_jwt client assertion could carry the token endpoint URL as aud, or an array holding the issuer plus other values, because fosite only checks that one accepted value is among the aud values. RFC 10070 section 4 requires the issuer identifier as the sole aud value and forbids the token endpoint URL, so a client assertion made for one endpoint could be replayed at another. Accept only an aud that holds the issuer and nothing else, as a string or as a one-element array, which RFC 7519 and RFC 10070 both allow. Refuse everything else with 401 invalid_client, and log the refusal at WARN so operators can see why a client that worked before now fails. The check runs before fosite so it covers both the normal path and the clock skew recovery path, and it refuses an assertion that go-jose v4 cannot read, because fosite's go-jose v3 parser accepts encodings that v4 rejects. There is no setting. Closes #7039 Co-authored-by: Mecatl <noreply@mecatl.dev>
5ecd7a2 to
f852ed3
Compare
|
Thanks for the review. On the hard break: I'd like to keep it, but I disagree that a sole token-URL You're right that the PR didn't say enough about migration, so I've updated the body. It now marks this as a breaking change, says to switch clients to the issuer before upgrading (the issuer form works on old releases too), names Spring Security and authlib as defaulting to the token URL, and mentions the intermittent 401s during a rolling upgrade on shared Redis. On the caller-supplied strategy: applying the check there is deliberate, same as the JWS guard, and nothing in this repo or in Mecatl sets one. I took your decorator suggestion though, because it makes that choice visible. The check now lives in its own |
rdimitrov
left a comment
There was a problem hiding this comment.
Re-review of f852ed3: approve. Both earlier findings are settled.
- Unconditional breaking change vs #7039: withdrawn. A sole token-URL
audis the audience-injection case the spec describes, so a grace period would keep the hole open, and the arch doc has called both forms deprecated since v0.58.0. The PR body now carries the breaking-change and migration note, including the rolling-upgrade 401 caveat. - Audience check running with a caller-supplied strategy: resolved. The check is its own decorator in
provider.go, the clock-skew function's signature is back to main's, and the PR and code comment state that it deliberately applies to a caller-supplied strategy, like the JWS guard. That was the alternative we offered. No in-repo code sets that strategy, andTestClientAssertionAudienceStrategypins that a refused assertion never reaches the inner strategy.
Non-blocking follow-ups:
- The "audience strategy must stay above the clock-skew strategy" rule is enforced only by a comment (
provider.go:~758), and the test harness rebuilds the wrapping by hand, so reordering inprovider.gowould not fail a test. An integration case throughNewAuthorizationServerwith a skewed assertion andaud: [issuer, "other"]would pin it. - Flag this as breaking in the release notes when the release is cut.
🤖 Reviewed with Claude Code
Summary
A
private_key_jwtclient assertion was accepted when itsaudwas the token endpoint URL, or an array that merely contained the issuer, because fosite only checks that one accepted value is among theaudvalues. RFC 10070 section 4 closes the audience injection attack (Hosseyni, Küsters and Würtele) by requiring the issuer identifier as the soleaudvalue and forbidding the token endpoint URL. The issuer is the only metadata value a client can validate (RFC 8414 section 3.3). A malicious server can publish our token endpoint URL as one of its own endpoints, get a client to sign an assertion with that URL asaud, and replay it here. An array such as["<issuer>", "https://other-as.example"]can be replayed the same way.audholds the issuer and nothing else, as a string or as a one-element array. Refuse everything else with401 invalid_client.newClientAssertionAudienceStrategy, wired inprovider.goabove the clock skew strategy. It covers fosite's path, the 60-second clock skew recovery path, and a caller-supplied strategy. The recovery path no longer checksauditself.audarray past the check.client_id.docs/arch/17-token-exchange-delegation.md,docs/arch/11-auth-server-storage.mdand theTokenEndpointPathcomment.Closes #7039
Type of change
Test plan
go test -race ./pkg/authserver/server/ ./pkg/authserver/task test-e2e)golangci-lint run ./pkg/authserver/...New and changed tests:
TestClientAssertionAudienceruns everyaudshape (issuer as a string and in a one-element array, token URL, extra values, empty array, null, missing, empty string, numbers) on fosite's path and on the clock skew path, and asserts the hint and that nojtiis reserved for a refused assertion.TestClientAssertionAudienceStrategypins that a refused assertion never reaches the strategy below, which stands in for a caller-supplied one, and that requests without a client assertion pass through untouched.TestClientAssertionAudience_UnreadableEncodingspins that padded, space and tab variants are refused.wrong_subjectandexpiredrows inTestIntegration_PrivateKeyJWTDCRTokenExchangenow use the issuer asaud, so each fails for the reason in its name rather than onaud.Does this introduce a user-facing change?
Yes, and it is a breaking change for clients that send the token endpoint URL as
aud.private_key_jwtclient assertion was accepted withaudset to the issuer or to the token endpoint URL ({issuer}/oauth/token), as a string or inside an array with other values.audmust hold the issuer and nothing else, as"<issuer>"or["<issuer>"]. Anything else gets401 invalid_clientand the server logs a WARN line naming the cause.This applies at every endpoint that authenticates clients (token, token exchange, revocation, introspection, PAR). SPIFFE JWT-SVID client authentication and the
audchecks on JWT-bearer and ID-JAG grant assertions are unchanged.Migration: switch clients to send the issuer as
audbefore upgrading the server. The issuer form is accepted by earlier releases too, so this order needs no downtime. Spring Security and authlib use the token endpoint URL by default, so their clients need configuring. During a rolling upgrade of a deployment that shares Redis, replicas still on the old release accept the token URL and upgraded ones refuse it, so a client that has not switched sees intermittent 401s until the rollout finishes. The architecture docs have described the token URL form as deprecated, to be refused in a later release, since v0.58.0.Special notes for reviewers
audis the case RFC 10070 was written for, not only a conformance gap, so a grace period would keep the attack open for another release. The deprecation has been documented since v0.58.0.ClientAuthenticationStrategyon purpose, the same way the JWS guard does. No code in this repo or in Mecatl supplies one.