VulnWatch by ve1ve2
high 7.2 EPSS 1.11%

GHSA-c5f2-jwm7-mmq2 / CVE-2024-11234: Configuring a proxy in a stream context might allow for CRLF injection in URIs

Source:
PHP releases (GitHub php/php-src tags)
Published:
Fetched:
Updated:
Affects:
php php-src

https://github.com/php/php-src/security/advisories/GHSA-c5f2-jwm7-mmq2 ↗

repo-advisoryCWE-93securityrepo:php/php-srcstack

Configuring a proxy in a stream context might allow for CRLF injection in URIs ### Summary Configuring a proxy in a [stream context](https://www.php.net/manual/en/stream.contexts.php) might allow for CRLF injection in URIs, resulting in HTTP request smuggling attacks. ### Details When creating a stream using one of the available stream creation functions (e.g., `fopen`, `file`, `file_get_contents`...), developers can specify a custom stream context containing a set of parameters to use during the connection. One such parameter, in the case of HTTP and FTP streams, is `proxy`. The HTTP context options also include a `request_fulluri` boolean, which is required by some proxies to correctly forward the request. While a normal request to `http://example.com/path/to/file?query` would results in the following HTTP request: ```http GET /path/to/file?query HTTP/1.1 ``` when setting `request_fulluri` to `true` we obtain: ```http GET http://example.com/path/to/file?query HTTP/1.1 ``` The vulnerability lies in the [implementation of `request_fulluri`](https://github.com/php/php-src/blob/0d616d1b82ca7609a7ece762cb8688d9bed74370/ext/standard/http_fopen_wrapper.c#L393), which just inserts the raw URI into the HTTP request line. In particular, this bypasses the normal [control characters sanitization](https://github.com/php/php-src/blob/0d616d1b82ca7609a7ece762cb8688d9bed74370/ext/standard/url.c#L53) usually performed [when parsing the URL](https://github.com/php/php-src/blob/0d616d1b82ca7609a7ece762cb8688d9bed74370/ext/standard/url.c#L323). This means that, if the resource URI is under the partial control of an attacker, when the `request_fulluri` context parameter is true, a malicious actor could inject CRLF characters to perform a HTTP request smuggling attack. Furthermore, if a non-HTTP stream sets a `proxy` parameter in the context (right now only the FTP context supports this), the `request_fulluri` parameter gets [automatically silently enabled](https://github.com/php/php-src/blob/0d616d1b82ca7609a7ece762cb8688d9bed74370/ext/standard/http_fopen_wrapper.c#L164) without the developer ever knowing. Notice that, in the case of HTTP streams, setting a proxy is not strictly necessary, as the real issue is the `request_fulluri` parameter. ### PoC We can test the raw query performed by PHP by simply using netcat in listening mode (`nc -lvnp 1337`). When no proxy is configured, the malicious input is correctly sanitized (still producing an error due to the presence of unencoded spaces): ```php $userinput = " HTTP/1.1\r\nHost: localhost:1337\r\n\r\nGET /admin HTTP/1.1\r\nHost: adminpanel\r\n\r\nGET /"; file_get_contents("http://localhost:1337/$userinput"); ``` ```http GET / HTTP/1.1__Host: localhost:1337____GET /admin HTTP/1.1__Host: adminpanel____GET / HTTP/1.1 Host: localhost:1337 Connection: close ``` When using a proxy and setting `request_fulluri` to `true`, we get request smuggling: ```php $opts = ['http' => ['proxy' => 'tcp://localhost:1337', 'request_fulluri' => true Patched: 8.1.31, 8.2.26, 8.3.14

Linked vulnerabilities (2)

CVE-2024-11234 high 7.2 EPSS 1.11% (p67) NVDCVE.orgGHSA
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N

php8.2 - security update

CWE: CWE-93Aliases: CVE-2024-11233, CVE-2024-11236, CVE-2024-8929, CVE-2024-8932, GHSA-c5f2-jwm7-mmq2

Configuring a proxy in a stream context might allow for CRLF injection in URIs

CWE: CWE-93Aliases: CVE-2024-11234