Skip to content

fix!: bind DPoP proofs to the receiving endpoint, with listener marks for migration - #1002

Merged
osanderson merged 9 commits into
mainfrom
fix/dpop-request-target-v2
Nov 27, 2026
Merged

osanderson merged 9 commits into
mainfrom
fix/dpop-request-target-v2

Conversation

@osanderson

Copy link
Copy Markdown
Collaborator

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:

  • The authorization server accepted a proof for either an endpoint's primary URL or its mTLS alias.
  • The resource server accepted any ResourceURLs origin 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)

  • Removed: the either-endpoint check and dpop.VerifyRequest.AlternateURLs.
  • Added: server.EndpointRoute (PrimaryEndpoint, MTLSEndpointAlias), FormRequest.EndpointRoute and TokenEndpointRequest.SetEndpointRoute.
  • Route passed: every DPoP call site on main now passes the route. That covers PAR, CIBA begin, code exchange, refresh, client credentials, CIBA token, VerifyTokenRequestBinding and VerifyTokenRequestDPoP.
  • Kept: the DPoP replay-store outage still answers 500.

Softened migration

Authorization server (fix(server)):

  • No route: the proof is checked against the primary URL only, never either. A primary proof with no route is accepted. An alias proof with no route is refused with an ordinary 400 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.
  • An impossible route: the alias route with no MTLSEndpoints configured, or an unknown value, is a server misconfiguration. It answers 500, and the cause names the setters.
  • An unadvertised alias: the alias route at an endpoint with no alias of its own is the client calling a URL that was never advertised, so it answers 400.

Middleware:

  • server.WithEndpointRoute(route, next) (feat(server)) marks a listener's requests. Every *FromHTTP constructor 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's ResourceURLs entries.
  • cmd/conformance-as now uses both, in place of its bespoke wiring.

Resource server:

  • Overlapping origins: when several origins cover a path, a DPoP request still needs VerifyRequest.URL or the new mark. The origin is never taken from the Host header, since that would reopen E-11.
  • Errors: without either, the request gets 500, and the cause now names both fixes. A marked origin that matches no ResourceURLs entry 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

  • Coverage:
    • routes accepted and refused at the token endpoint, PAR and refresh, including the hint and each condition that suppresses it;
    • the impossible-route 500s and the unadvertised-alias 400;
    • the middleware marking PAR, token and CIBA requests;
    • the RS origin cases;
    • the conformance server's listener marks.
  • Without the changes: the tests fail when the port's old 500-on-unset rule is put back.
  • Not covered locally: client credentials and the CIBA token request pass the route but have no alias-route test, because there's no ready harness for mTLS client auth plus DPoP at the alias. Conformance covers those paths.
  • Mutants: 27 new and 2 re-anchored, all killed.
  • Suites: the race suite, every example module, the interop client and sqlstore pass, and lint is clean.

Conformance and all four interop suites are running, since this changes wire behaviour.

🤖 Generated with Claude Code

osanderson and others added 8 commits November 27, 2026 07:59
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

codecov Bot commented Nov 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.70199% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/conformance-as/wiring.go 66.66% 2 Missing and 2 partials ⚠️
fapitest/authserver.go 66.66% 1 Missing and 1 partial ⚠️
resource/target.go 94.87% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@osanderson
osanderson merged commit 3a395e1 into main Nov 27, 2026
33 checks passed
@osanderson
osanderson deleted the fix/dpop-request-target-v2 branch November 27, 2026 01:15
@sonarqubecloud

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant