Repository navigation
fix(http): consider port in redirect handler same origin check - #817
Merged
Vincent Biret (baywet) merged 1 commit intoOct 20, 2026
Conversation
|
Contributor
Author
|
Hi Vincent Biret (@baywet), submitted this PR to ensure |
Vincent Biret (baywet)
approved these changes
Oct 20, 2026
Vincent Biret (baywet)
left a comment
Member
There was a problem hiding this comment.
Thanks for the contribution!
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.



Description
In
RedirectHandler._same_origin, origin equivalence was checked solely via:Per RFC 6454 (The Web Origin Concept), the origin tuple consists of
(scheme, host, port). When redirecting across different ports on the same host (e.g.https://example.com:443tohttps://example.com:8443):_same_originpreviously returnedTrue, failing to recognize the cross-origin transition._same_originreturnedTrue, theHostheader was not updated (if not self._same_origin(url, request.url): new_request.headers["Host"] = url.netloc.decode("ascii")), leaving a staleHost: example.comrather thanHost: example.com:8443.options.scrub_sensitive_headerscorrectly checksoriginal_url.port != new_url.port, creating an inconsistency where sensitive headers were scrubbed but theHostheader was not updated.Changes Made
RedirectHandler._same_originto includeand url.port == other.port.test_not_same_origin_different_port: verifies_same_originevaluates toFalsefor differing ports.test_redirect_to_different_port_updates_host_header: verifies that redirecting to a different port updates theHostheader to include the new port.cc Vincent Biret (@baywet)