GHSA-HPVQ-6RRX-PC47
Malformed bracketed host can bypass host-based checks in guzzlehttp/guzzle
Texto original en inglés · Ver en español
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:L/I:L/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-HPVQ-6RRX-PC47 divulgada · CVSS 5.4 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
In affected versions, the request host validation added for GHSA-v5mv-p594-2x33 accepts a bracketed URI host that is not an IP literal, such as `[::1]:8080]`, `[127.0.0.1]` or `[localhost]`. `StreamHandler` passes the URI to PHP as text, and PHP connects to the text inside the first pair of brackets, on the port written after them if there is one, whatever `Uri::getHost()` and `Uri::getPort()` report. The issue is fixed in `7.16.3`.
Details
GHSA-v5mv-p594-2x33 listed unbalanced brackets among the hosts that the built-in handlers reject since `7.15.2`, but on the 7 line that check only requires a host that contains a bracket to begin with `[` and end with `]`. `guzzlehttp/psr7` before `2.13.4` reports the host `[::1]:8080]` for `http://user@[::1]:8080]:80/` and for the network-path reference `//[::1]:8080]:80/`, which a redirect `Location` can carry too, and `Uri::withHost()` and other PSR-7 implementations supply bracketed hosts directly.
PHP's stream transport reads `[::1]:8080]` as host `::1`, port `8080`, and connects to `[127.0.0.1]` and `[localhost]` as `127.0.0.1` and `localhost`. Through the cURL handlers, libcurl `7.52.1` also connects to the inner host and port, `7.52.1`, `7.61.1` and `7.64.0` connect to a bracketed IPv4 address, and `7.74.0` and `8.14.1` reject all of these hosts.
This is a summary; the patches are the authority. The issue is fixed in `7.16.3`, which rejects a request URI host containing a bracket unless it is a bracketed IPv6 or IPvFuture literal, the rule Guzzle 8 applies. `guzzlehttp/psr7` `2.13.4` (GHSA-jwvc-hj95-82hh) rejects a host that continues after its closing bracket but still holds `[127.0.0.1]` and `[localhost]`, so it does not replace this release. One case stays open on `7.16.3` and on Guzzle 8: an IPvFuture literal such as `[v1.example]` is a valid URI host, and the stream handler resolves `v1.example` as a name. Guzzle 8 is not affected, because it already has stronger input validation, introduced as part of a breaking change: every `8.x` release requires `guzzlehttp/psr7` 3, whose `Uri` accepts a bracketed host only if it is an IPv6 or IPvFuture literal, and since `8.0.1` the handlers apply the same rule to every PSR-7 implementation. Versions before `7.16.3` are affected. Versions before `7.15.2` are also covered by GHSA-v5mv-p594-2x33, as is `8.0.0`, the one Guzzle 8 release whose handlers validate no hosts.
Proof of concept
A vulnerable flow, reproduced over a real socket on `7.15.2` and `7.16.2`, is:
- An application checks the host or port of an untrusted URL before fetching it: it refuses loopback and private addresses, for example, or allows only ports 80 and 443.
- It sends the request through `StreamHandler`: the cURL extension is unavailable, the handler is configured explicitly, or the request uses the `stream` option, which the default handler stack routes to it even when cURL is installed.
- The attacker supplies `http://user@[127.0.0.1]:6379]:80/`.
- `Uri::getHost()` returns `[127.0.0.1]:6379]` and `Uri::getPort()` returns `null`. The host is not an IP address, and the port appears to be the default.
- The stream handler connects to `127.0.0.1` on port `6379` and sends the request with `Host: [127.0.0.1]:6379]`.
Impact
An attacker who influences a fetched URI or a redirect target can reach a host or a port that the application's own check excluded, and read whatever the application exposes of the response. The checks concerned are denylists, private-range and IP-literal checks, as in GHSA-v5mv-p594-2x33, and also a port restriction that reads `Uri::getPort()`.
Exploitation requires the application to build a request URI from untrusted input, to make a host or port decision before handing it to Guzzle, and to send the request through the stream handler or with a libcurl as old as described above. Applications that only fetch URIs they construct themselves are not affected, and an exact allowlist of hosts fails closed.
If you cannot upgrade, reject a request URI whose host contains `[` or `]` unless the text between one leading `[` and one trailing `]` passes `filter_var()` with `FILTER_VALIDATE_IP` and `FILTER_FLAG_IPV6`, before handing the URI to Guzzle and on every redirect hop.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
Packagistguzzlehttp/guzzle |
Corregida | 7.16.3 | — | — |
7.16.3Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/guzzle/guzzle/security/advisories/GHSA-hpvq-6rrx-pc47Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
