CVE-2023-32681: Unintended leak of Proxy-Authorization header in requests
(updated )
Since Requests v2.3.0, Requests has been vulnerable to potentially leaking Proxy-Authorization
headers to destination servers, specifically during redirects to an HTTPS origin. This is a product of how rebuild_proxies
is used to recompute and reattach the Proxy-Authorization
header to requests when redirected. Note this behavior has only been observed to affect proxied requests when credentials are supplied in the URL user information component (e.g. https://username:password@proxy:8080
).
Current vulnerable behavior(s):
- HTTP → HTTPS: leak
- HTTPS → HTTP: no leak
- HTTPS → HTTPS: leak
- HTTP → HTTP: no leak
For HTTP connections sent through the proxy, the proxy will identify the header in the request itself and remove it prior to forwarding to the destination server. However when sent over HTTPS, the Proxy-Authorization
header must be sent in the CONNECT request as the proxy has no visibility into further tunneled requests. This results in Requests forwarding the header to the destination server unintentionally, allowing a malicious actor to potentially exfiltrate those credentials.
The reason this currently works for HTTPS connections in Requests is the Proxy-Authorization
header is also handled by urllib3 with our usage of the ProxyManager in adapters.py with proxy_manager_for
. This will compute the required proxy headers in proxy_headers
and pass them to the Proxy Manager, avoiding attaching them directly to the Request object. This will be our preferred option going forward for default usage.
References
- github.com/advisories/GHSA-j8r2-6x86-q33q
- github.com/psf/requests
- github.com/psf/requests/commit/74ea7cf7a6a27a4eeb2ae24e162bcc942a6706d5
- github.com/psf/requests/releases/tag/v2.31.0
- github.com/psf/requests/security/advisories/GHSA-j8r2-6x86-q33q
- github.com/pypa/advisory-database/tree/main/vulns/requests/PYSEC-2023-74.yaml
- lists.debian.org/debian-lts-announce/2023/06/msg00018.html
- lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/AW7HNFGYP44RT3DUDQXG2QT3OEV2PJ7Y
- lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/KOYASTZDGQG2BWLSNBPL3TQRL2G7QYNZ
- nvd.nist.gov/vuln/detail/CVE-2023-32681
- security.gentoo.org/glsa/202309-08
Detect and mitigate CVE-2023-32681 with GitLab Dependency Scanning
Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →