Fix test_strip_headers_on_redirect's URL-embedded-credentials cases#3678
Merged
bdarnell merged 1 commit intoJul 4, 2026
Merged
Conversation
url.replace("http://", ...) replaced every occurrence of "http://" in
the fetched URL, including the one inside the "url" query parameter
that RedirectHandler uses as the redirect target. That accidentally
embedded the test credentials in the Location header's URL too, so
the "different origin" subtest was actually exercising "does libcurl
honor credentials the server explicitly put in the redirect target"
rather than "does libcurl strip credentials carried over from the
original request" - libcurl correctly does the former, which is not
a credential leak.
Limit the replacement to the first occurrence so only the outer,
fetched URL carries the test credentials.
Separately, the "same origin" subtest for this case now surfaces an
actual libcurl regression (still present in curl's git master as of
this writing): credentials embedded in the URL are dropped across a
same-origin redirect when the Location header is an absolute URL
(a relative Location correctly preserves them). This isn't a security
issue since nothing leaks to another origin, so that specific
assertion is skipped rather than asserted either way.
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
Updated the
test_strip_headers_on_redirecttest to correctly handle credential injection in redirect URLs and account for a known libcurl regression with same-origin redirects.Key Changes
"http://"instead of all occurrences. This prevents credentials from being added to both the outer URL being fetched and the redirect target URL in the query parameter, which would cause libcurl to honor the redirect's explicit credentials instead of stripping them.Implementation Details
str.replace()to limit replacements to the first occurrence onlyhttps://claude.ai/code/session_01TJzTuZ43muUDrzWjew2D3u
Fixes #3674