Repository navigation
fix(resource): refuse a request with more than one Authorization header - #513
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
VerifyRequestFromHTTP read the Authorization header with Header.Get, which silently takes the first of several, and net/http doesn't reject repeats. A proxy or gateway in front that acts on another one (the last, or a merged value) would then disagree with the resource server about which credential the request carried. It already refused more than one DPoP header, and the client's backchannel notification endpoint refuses repeated Authorization headers. VerifyRequestFromHTTP now marks such a request, and Verify refuses it with a 400 invalid_request. The Authorization field's doc tells an adapter that fills the struct itself to refuse repeats first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
osanderson
force-pushed
the
fix/resource-repeated-authorization
branch
from
October 2, 2026 06:31
ce91ae4 to
17dc93b
Compare
|
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.



Summary
This fixes the pre-release security review's L2.
resource.VerifyRequestFromHTTP(#504, unreleased) usedr.Header.Get("Authorization"), which silently takes the first of several headers, andnet/httpdoesn't reject repeats. If a proxy, gateway or WAF in front acts on a different one (the last, or a merged value), it and the resource server disagree about which credential the request carried.It was also inconsistent with existing behaviour:
Authorizationheaders (client/backchannel_notification.go).Fix:
VerifyRequestFromHTTPmarks a request with more than oneAuthorizationheader, using an unexported field onVerifyRequest, so the struct's public shape doesn't change.Verifyrefuses a marked request with a 400invalid_request("multiple Authorization headers are not permitted"). The refusal comes after the method and URL checks, before the scheme is parsed.Authorizationfield's doc now says the header isn't a list (RFC 9110 §5.3). An adapter filling the struct itself must refuse repeats first rather than pass one on.It isn't breaking: one header behaves as before.
Tests
TestVerifyRefusesRepeatedAuthorization: throughVerifyRequestFromHTTPandVerify, one header verifies, and two headers (DPoP …+Bearer other) give a 400invalid_request*resource.Error.go test -race ./resource/... ./serverresource/...passes.🤖 Generated with Claude Code