curl_auth not cleared on downgrade in guzzle/guzzle


Reported on

Jun 15th 2022


Guzzle recently fixed a vulnerability related to "Authorization" handling on downgrade here - However, there also exists another code path, for which Guzzle uses a Authorization header located when it uses digest authorization, as it uses curl_auth which as of now only checks for same-domain.

The same-domain part was fixed in, but since then, it has not been extended to fix the same-scheme part when fixing

Proof of Concept


require 'vendor/autoload.php';

use GuzzleHttp\Client;

$client = new Client([
  'base_uri' => '',
  'auth' => ['username', 'password', 'digest']

$response = $client->request('GET', '/redirect-to?url=', [
    'debug' => TRUE

$body = $response->getBody();

See that on the debug output, guzzle attempts to use digest auth when it is redirected from to

* Connected to ( port 80 (#1)
* Server auth using Digest with user 'username'
> GET / HTTP/1.1
User-Agent: GuzzleHttp/7


Same as

We are processing your report and will contact the guzzle team within 24 hours. 22 days ago
We have contacted a member of the guzzle team and are waiting to hear back 21 days ago
19 days ago


In particular this line is not using shouldStripSensitiveHeaders() -

 // If authorization is handled by curl, unset it if host is different.
if ($request->getUri()->getHost() !== $nextRequest->getUri()->getHost()
We have sent a follow up to the guzzle team. We will try again in 7 days. 18 days ago
Graham Campbell validated this vulnerability 18 days ago

Thanks for the report. I agree this is an issue.

haxatron has been awarded the disclosure bounty
The fix bounty is now up for grabs
The researcher's credibility has increased: +7
Graham Campbell
18 days ago


Please review the following advisory draft, @haxatron:

### Impact

`Authorization` headers on requests are sensitive information. When using our Curl handler, it is possible to use the `CURLOPT_HTTPAUTH` option to specify an `Authorization` header. On making a request which responds with a redirect to a URI with a different origin (change in host, scheme or port), if we choose to follow it, we should remove the `CURLOPT_HTTPAUTH` option before continuing, stopping curl from appending the `Authorization` header to the new request.

### Patches

Affected Guzzle 7 users should upgrade to Guzzle 7.4.5 as soon as possible. Affected users using any earlier series of Guzzle should upgrade to Guzzle 6.5.8 or 7.4.5. Note that a partial fix was implemented in Guzzle 7.4.2, where a change in host would trigger removal of the curl-added Authorization header, however this earlier fix did not cover change in scheme or change in port.

### Workarounds

If you do not require or expect redirects to be followed, one should simply disable redirects all together. Alternatively, one can specify to use the Guzzle steam handler backend, rather than curl.

### References

* [RFC9110 Section 15.4](
* [CVE-2022-27776](

### For more information

If you have any questions or comments about this advisory, please get in touch with us in `#guzzle` on the [PHP HTTP Slack]( Do not report additional security advisories in that public channel, however - please follow our [vulnerability reporting process](
Graham Campbell confirmed that a fix has been merged on a52f04 17 days ago
Graham Campbell has been awarded the fix bounty
Graham Campbell
17 days ago


We have been allocated CVE-2022-31090.

to join this conversation