Proxy-Authorization header not stripped on cross-origin redirects leaks proxy credentials
Description
When following a redirect to a different origin, BaseClient._redirect_headers() strips Authorization and Cookie from the outgoing request, but leaves Proxy-Authorization in place. A client that carries Proxy-Authorization in its client or request headers forwards that credential to the redirect target.
Details
When follow_redirects=True, BaseClient._redirect_headers() copies all headers from the previous request onto the redirect request. When url.origin != request.url.origin, it pops Authorization (outside same-host HTTP-to-HTTPS upgrades) and unconditionally pops Cookie before rebuilding cookies from the jar, but never removes Proxy-Authorization - even though httpx2 already classifies proxy-authorization in SENSITIVE_HEADERS.
Proxy credentials configured through the documented proxy="http://user:pass@host" parameter are not affected: httpcore2 stores those credentials in connection-level proxy headers and never adds them to request.headers. A manually set Proxy-Authorization header already reaches every origin contacted without a forward proxy, so redirects add exposure specifically when the initial request traverses a forward proxy that consumes the header and the redirect target is reached without that proxy (for example, an http:// request routed through an HTTP proxy redirecting to an unproxied https:// target).
Impact
An attacker who controls an HTTP response that redirects the client (the contacted origin, or an on-path attacker on plain HTTP) can capture the proxy credential.
An application is affected when all of the following hold:
follow_redirects=Trueis enabled (the default isFalse).Proxy-Authorizationis passed manually in client or requestheadersrather than viaproxy=.- The redirect target is not routed through the same forward proxy that stripped
Proxy-Authorizationon the initial request.
Because the documented proxy authentication API is unaffected and all three conditions are required, realistic exposure is narrow. This is the same class of issue as CVE-2024-37891 in urllib3 and CVE-2025-4673 in Go's net/http.
Mitigation
Upgrade to httpx2 2.18.0 or later, which strips Proxy-Authorization whenever a redirect changes origin (including same-host HTTP-to-HTTPS upgrades).
If upgrading is not immediately possible, configure proxy credentials via proxy="http://user:pass@host" instead of passing Proxy-Authorization in headers, or leave follow_redirects=False.