Repository navigation
fix!: bind DPoP proofs to the receiving endpoint, with listener marks for migration - #1002
Merged
Merged
Conversation
RFC 9449 section 4.3 binds a DPoP proof to the URI of the request it is sent with. The authorization server accepted a proof naming either an endpoint's primary URL or its mTLS alias, and the resource server accepted one naming any configured origin covering the request path, so where the two routes keep separate replay records one unused captured proof could be spent once at each. Each DPoP request is now checked against one target. The authorization server takes it from the new FormRequest.EndpointRoute (PrimaryEndpoint or MTLSEndpointAlias; TokenEndpointRequest.SetEndpointRoute for a request read with TokenEndpointRequestFromHTTP) at PAR, the token endpoint, extension grants and the backchannel authentication endpoint. The resource server requires VerifyRequest.URL when several of Config.ResourceURLs cover a DPoP request's path, and the internal verifier no longer takes alternate URLs. The conformance server supplies both from the listener that accepted the connection. BREAKING CHANGE: a DPoP proof is accepted only for the one endpoint URL that received it. A server with a distinct mTLS alias must set FormRequest.EndpointRoute on DPoP requests, and a resource server whose configured origins overlap must set VerifyRequest.URL. See UPGRADING.md for the migration. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A DPoP request with no endpoint route, at an endpoint with a distinct mTLS alias, was answered 500 server_error: every DPoP request to such a server failed until each listener set a route, including the ones that only ever serve the primary URL. Such a request is now checked against the endpoint's primary URL only, never either. A proof naming the alias, sent where no route was set, is refused like any other proof for another URL: 400 invalid_dpop_proof, with the generic public description and a cause that names the route setters for the deployment's logs. One target per request still holds, so a captured proof can't be spent once at each URL. The alias route at an endpoint configuring no alias of its own, on a server advertising aliases for others, is a URL the client wasn't given: 400 invalid_dpop_proof. The alias route on a server with no mTLS alias at all, or a route value the package doesn't define, stays a 500, and its cause now names FormRequest.EndpointRoute and TokenEndpointRequest.SetEndpointRoute. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A deployment with mTLS aliases had to set FormRequest.EndpointRoute, or call TokenEndpointRequest.SetEndpointRoute, in every PAR, token and backchannel authentication handler, from listener state it had to carry through the request context itself. WithEndpointRoute(route, next) marks every request a listener receives with its route, and FormRequestFromHTTP, so every *FromHTTP request constructor, reads the route from that mark. Wrapping the handler of the listener serving Config.MTLSEndpoints in WithEndpointRoute(MTLSEndpointAlias, mux) is then the whole migration. A route set on a request after it is read still takes precedence. The 500 for a route the server can't serve now names WithEndpointRoute among the setters. The conformance server marks its two listeners this way instead of setting the route in each handler. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A DPoP request whose path several of Config.ResourceURLs' origins cover is refused as a 500 unless the deployment says which origin received it, since the Host header the client sends can't. The only way to say so was VerifyRequest.URL, rebuilt by hand from the listener's origin and the escaped path in every handler, and the 500's cause named only that. WithResourceOrigin(origin, next) marks every request a listener receives with its origin, and VerifyRequestFromHTTP takes the mark: Verify then places the escaped path only under the ResourceURLs at that origin, keeping the path checks VerifyRequestFromHTTP's requests already get. A mark naming an origin none of ResourceURLs is at is the deployment's mistake, a 500; an explicit VerifyRequest.URL still takes precedence. The ambiguous-target 500 now names WithResourceOrigin and VerifyRequest.URL, and the request path it couldn't place. The conformance server marks each listener's origin this way instead of building VerifyRequest.URL itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
UPGRADING.md's v0.88.0 section described the first cut of the change, under which an unrouted DPoP request at a server with mTLS aliases was a 500. It now says who is affected, what is refused and with which status, and that wrapping the alias listener in WithEndpointRoute, or each resource server listener in WithResourceOrigin, is the migration. GETTING_STARTED, the mTLS and DPoP guides and the doc comments on server.MTLSEndpoints and resource.Config.ResourceURLs show the listener marks, and the conformance notes record that the either-URL retry they describe was replaced. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A refresh at the token endpoint's mTLS alias verifies a proof for the alias only on a request marked as received there. A copy of a token endpoint request made before SetEndpointRoute keeps its route, and an unmarked resource request no prefix covers is still the client's 400. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Listing the protected endpoints at the mTLS alias origin added a parse and its error check to newServerMux, already the conformance server's most complex function. protectedResourceURLs now builds the list, and the comment saying why each listener marks its origin moves with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each new branch of the endpoint route check, the route hint, both listener marks and the route each DPoP call site passes has a mutant. Two existing mutants are re-anchored on code the change moved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Breaking. A DPoP proof now verifies only for the one URL that received the request (RFC 9449 §4.3). This closes the audit's E-11. It supersedes #886: #886's commit is carried here, rebased onto
main, and the migration is softened.Before:
ResourceURLsorigin covering the path.With separate replay stores, one captured, unused proof could be spent once at each.
fix!:bind DPoP proofs to the receiving endpoint (#886, ported)dpop.VerifyRequest.AlternateURLs.server.EndpointRoute(PrimaryEndpoint,MTLSEndpointAlias),FormRequest.EndpointRouteandTokenEndpointRequest.SetEndpointRoute.mainnow passes the route. That covers PAR, CIBA begin, code exchange, refresh, client credentials, CIBA token,VerifyTokenRequestBindingandVerifyTokenRequestDPoP.Softened migration
Authorization server (
fix(server)):invalid_dpop_proof, not a 500 on all DPoP traffic. The hint naming the three ways to set the route goes only in the error's cause, which logs show and the client doesn't.MTLSEndpointsconfigured, or an unknown value, is a server misconfiguration. It answers 500, and the cause names the setters.Middleware:
server.WithEndpointRoute(route, next)(feat(server)) marks a listener's requests. Every*FromHTTPconstructor picks the route up, and a route set explicitly still wins.resource.WithResourceOrigin(origin, next)(feat(resource)) marks a listener's origin. With it, the RS considers only that origin'sResourceURLsentries.cmd/conformance-asnow uses both, in place of its bespoke wiring.Resource server:
VerifyRequest.URLor the new mark. The origin is never taken from theHostheader, since that would reopen E-11.ResourceURLsentry is also a 500.Docs: UPGRADING.md has two sections under v0.88.0, one for the server and one for the resource server. GETTING_STARTED, the mTLS and DPoP guides, and the relevant doc comments show the middleware.
What's left open
A deployment that doesn't mark its alias listener still accepts a primary proof sent to the alias. With separate replay stores, a captured primary proof could then be spent once on each listener. Legitimate alias traffic fails visibly (400) in such a deployment, so the misconfiguration gets noticed. Marking the listener closes the gap.
Tests
Conformance and all four interop suites are running, since this changes wire behaviour.
🤖 Generated with Claude Code