Repository navigation
http: do not forward credentials on a cross-origin redirect - #5298
Open
musthaf-bughunter wants to merge 1 commit into
Open
musthaf-bughunter wants to merge 1 commit into
musthaf-bughunter wants to merge 1 commit into
Conversation
HTTP_Client.request() followed redirects with the original Host and Path, and with any Authorization, Proxy-Authorization or Cookie header passed by the caller, even when the Location points to another host or scheme. AI-Assisted: yes (Claude Opus 5.5)
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5298 +/- ##
==========================================
+ Coverage 80.06% 80.66% +0.59%
==========================================
Files 375 375
Lines 98775 98788 +13
==========================================
+ Hits 79083 79686 +603
+ Misses 19692 19102 -590
🚀 New features to boost your workflow:
|
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
HTTP_Client.request()follows a 301/302 by calling itself with the same**headersdict, which already holds the originalHostandPathfromsetdefault()(http.py#L987-L988, #L1054-L1062). The redirected request is sent to theLocationhost with the oldHost/Pathand with anyAuthorization,Proxy_AuthorizationorCookiepassed by the caller, including on a https -> http redirect.HostandPathare now recomputed from theLocationURL, and the credential headers are dropped when the scheme, host or port changes. The new test covers a cross-origin redirect and a same-origin one.