Strip connection headers on cross-host redirect in HttpHook#70000
Strip connection headers on cross-host redirect in HttpHook#70000Samin061 wants to merge 2 commits into
Conversation
An HTTP connection's extra field is documented as a place to carry credentials, and requests only protects the Authorization name, so a secret under any other header name reached whatever host a redirect named.
nailo2c
left a comment
There was a problem hiding this comment.
This looks like the intended security behavior, I think we might need to write down a change log in somewhere to let users know about it.
For example, users who intentionally relied on connection extra headers being replayed to a different redirect host, such as a CDN, may need to update their flow or handle the redirect explicitly.
nailo2c
left a comment
There was a problem hiding this comment.
I'm not a committer, so I'd defer to others on whether this change and its scope look right. If so, I think we should open an issue to track the async part so it doesn't get lost.
|
Good call on both. Added a breaking-changes note at the top of Opened #70164 for the async side, and left a pointer to it next to the header handling in |
|
Linking to #70164 |
|
Quickest fix: git fetch upstream main && git rebase upstream/main
rm uv.lock && uv lock
git add uv.lock && git rebase --continue
git push --force-with-leaseAutomated nudge — ignore if you're not ready to rebase. This comment is updated in place on future |
An HTTP connection's
extrafield is documented as a place to put credentials ("Login and Password authentication can be used along with any authentication method using headers"), and those end up insession.headers, whilerun_and_checkfollows redirects by default.requestsstrips onlyAuthorizationonceshould_strip_authsees the host change, so a secret under any other name (X-API-Key,Private-Token) is replayed to the redirect target — whether that is an attacker's host reached through an open redirect on the API, or simply the CDN the API bounces downloads to. This gives the connection's own headers the same treatment asAuthorization; same-host redirects still carry them.HttpAsyncHookhas the same gap andaiohttpbehaves identically, but it offers no equivalent redirect hook, so covering it means reworking the async redirect handling rather than extending an existing one. I left it out to keep this reviewable, and I'm happy to follow up if you'd like it in scope.The
FakeSessionpatch targets in the sensor tests move to the new class because the hook now instantiates it.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 4.8) following the guidelines