
Cloud Vulnerability DB
A community-led vulnerabilities database
In affected versions, the client can parse a URI string twice: as given, and again from the string form of the URI it built. When another PSR-7 implementation supplies that URI, through the uri_factory option or a base_uri object, it can hold a host that is not a valid URI host, and the second parse can then read another host or port. The request is sent there. The issue is fixed in 8.5.5.
The second parse was added in 8.0.0 with the uri_factory option. The client parses a URI string with the configured factory, resolves it against any base_uri, converts its host when idn_conversion is enabled, and adds a missing scheme; when that produces a new URI object, it hands the object's string form back to the factory. An invalid host gets into that object in two ways. With idn_conversion set to true, or to an IDNA_* bitmask without IDNA_USE_STD3_RULES, the conversion maps some characters to URI delimiters, such as @ to @, / to / and : to :, so http://evil.example/.good.example/ is sent to evil.example. Without idn_conversion, a library built on PHP's parse_url() reads //127.0.0.1:6379:80/x as the host 127.0.0.1:6379 and the port 80, and prints it without the default port, so port 6379 is read the second time; this needs a string without a scheme, or a client with a base_uri. GuzzleHttp\Psr7\Uri refuses both hosts, but the URIs of Nyholm, Laminas Diactoros, Slim and HttpSoft accept them, from the uri_factory or as a base_uri object with the default factory.
The issue is fixed in 8.5.5, which throws an InvalidArgumentException when idn_conversion produces an invalid host, and before parsing a URI again when its host is invalid. One case stays open on 8.5.5: a host that converts as a whole to another valid host is still converted, so fullwidth digits can become an IPv4 address, and a policy belongs on the converted host. A request URI given as an object, or a redirect target that names a host, is not parsed again, so an invalid host stays in the URI and the request is rejected. Guzzle 7 is not affected for the same reason: it never parses a URI twice. Versions 8.0.0 through 8.5.4 are affected, with or without the fix for GHSA-v5mv-p594-2x33, which 8.0.0 alone lacks.
A vulnerable flow, reproduced over a real socket on 8.5.4 with each built-in handler and the nyholm/psr7 factory, is:
uri_factory and with idn_conversion enabled..trusted.example.http://127.0.0.1/.trusted.example/x.127.0.0.1/.trusted.example, which passes the check. Converting the host first gives 127.0.0.1/.trusted.example, which passes too.GET /.trusted.example/x to 127.0.0.1, with Host: 127.0.0.1.
With idn_conversion disabled, //127.0.0.1:6379:80/x reached port 6379 in the same setup, past a check that allows only ports 80 and 443.An attacker who influences a fetched URI can reach a host or a port that the application's own check excluded, and read whatever the application exposes of the response. Through the conversion this defeats denylists, IP-literal checks, port restrictions, allowlists that match a suffix or a pattern, and a check made on the converted host. Without it, only denylists, IP-literal checks and port restrictions are exposed, since the host that the application reads is itself malformed.
Exploitation requires the application to use another PSR-7 implementation whose URIs accept such a host, as its uri_factory or for a base_uri object, to build a request URI string or that base_uri from untrusted input, and to make a host or port decision before handing it over. Applications that leave uri_factory unset and give base_uri as a string, or that only fetch URIs they construct themselves, are not affected, and an exact allowlist of hosts fails closed.
If you cannot upgrade, leave uri_factory unset and give base_uri as a string, or pass request URIs as objects, which are not parsed again.
Source: NVD
Free Vulnerability Assessment
Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.
Get a personalized demo
"Best User Experience I have ever seen, provides full visibility to cloud workloads."
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
"We know that if Wiz identifies something as critical, it actually is."