{"vuln_id":"CVE-2024-4577","aliases":["GHSA-3qgc-jrrr-25jv","CVE-2012-1823"],"description":"PHP RCE: A Bypass of CVE-2012-1823, Argument Injection in PHP-CGI","published_at":"2024-06-09T20:15:09.550000Z","modified_at":"2026-06-17T08:02:11.493000Z","first_seen_at":"2026-11-21T19:15:06.076901Z","severity":"critical","severity_source":"nvd","cvss_score":9.8,"cvss_vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","cwe":["CWE-20","CWE-78"],"vendor":"PHP Group","product":"PHP","kev":{"is_kev":true,"date_added":"2024-06-12","due_date":"2024-07-03","ransomware":true},"epss":0.99985,"epss_percentile":0.99982,"nvd_status":"Analyzed","enriched_at":"2026-11-24T17:20:46.375765Z","links":{"nvd":"https://nvd.nist.gov/vuln/detail/CVE-2024-4577"},"matched_alias":null,"items":[{"id":487,"source":{"id":"debian-php","name":"Debian 12 php8.2 (package vulnerabilities)"},"title":"php8.2 (Debian:12): DEBIAN-CVE-2024-8926 / CVE-2024-8926 - In PHP versions 8.1.* before 8.1.30, 8.2.* before 8.2.24, 8.3.* before 8.3.12, when using a certain non-standard configurations of Windows codepages, the fixes…","summary":"In PHP versions 8.1.* before 8.1.30, 8.2.* before 8.2.24, 8.3.* before 8.3.12, when using a certain non-standard configurations of Windows codepages, the fixes for  CVE-2024-4577 https://github.com/advisories/GHSA-vxpp-6299-mxw3  may still be bypassed and the same command injection related to Windows \"Best Fit\" codepage behavior can be achieved. This may allow a malicious user to pass options to PHP binary being run, and thus reveal the source code of scripts, run arbitrary PHP code on the server, etc.\n\nAffected: Debian:12:php8.2\n\nFixed in: 8.2.24-1~deb12u1\n\nReferences:\nhttps://security-tracker.debian.org/tracker/CVE-2024-8926","url":"https://osv.dev/vulnerability/DEBIAN-CVE-2024-8926","published_at":"2024-10-08T04:15:10.637000Z","updated_at":"2026-11-02T12:03:15.963839Z","fetched_at":"2026-11-21T19:15:05.963735Z","severity":"critical","cvss_score":9.8,"epss":0.99985,"is_kev":true,"has_exploit":true,"kev_due_date":"2024-07-03","vendor":"php","product":"php8.2","vuln_id":"CVE-2024-8926","vuln_ids":["CVE-2012-1823","CVE-2024-4577","CVE-2024-8925","CVE-2024-8926","CVE-2024-8927","CVE-2024-9026","DEBIAN-CVE-2024-8926","GHSA-3QGC-JRRR-25JV","GHSA-P99J-RFP4-XQVQ","GHSA-VXPP-6299-MXW3"],"tags":["package-watch","pkg:php8.2","fix-available"],"cluster_id":376,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/487","html":"https://vulnwatch.ve1ve2.com/item/487"}},{"id":12667,"source":{"id":"gh-php-src","name":"PHP releases (GitHub php/php-src tags)"},"title":"GHSA-3qgc-jrrr-25jv / CVE-2024-4577: PHP RCE: A Bypass of CVE-2012-1823, Argument Injection in PHP-CGI","summary":"PHP RCE: A Bypass of CVE-2012-1823, Argument Injection in PHP-CGI\n\nHi, \r\n\r\nI am Orange Tsai from DEVCORE Research Team. We recently found a vulnerability on PHP. We have reproduced the issues in the latest version of PHP 8.3.6 and would like to report it to you. Please check the attached document for details.\r\n\r\nThis advisory is in accordance with our vulnerability disclosure policy, which will be publicly disclosed after 90 days. Our aim is to ensure that vulnerabilities can be patched in a timely manner. Although it’s not a hard deadline, we still hope you can fix this vulnerability before August 04, 2024.\r\n\r\nPlease let me know if you have any questions, thanks!\r\n\r\n\r\n# Impact\r\n\r\nAn attacker can execute arbitrary PHP code on the remote server. This vulnerability affects the PHP built with Windows.\r\n\r\n\r\n\r\n\r\n# Details\r\n\r\nThe PHP-CGI which configured under Apache HTTP Server accepts the command-line arguments by default. This behavior was prove to vulnerable, and tracked as [CVE-2012-1823](https://bugs.php.net/bug.php?id=61910) before. The PHP published the following code to patch the vulnerability:\r\n\r\n***# Path: sapi/cgi/cgi_main.c:1801** https://github.com/php/php-src/blob/php-8.0.30/sapi/cgi/cgi_main.c#L1801*\r\n\r\n```c\r\n/* {{{ main */\r\nint main(int argc, char *argv[])\r\n{\r\n\tint free_query_string = 0;\r\n\tint exit_status = SUCCESS;\r\n\tint cgi = 0, c, i;\r\n\tsize_t len;\r\n\tzend_file_handle file_handle;\r\n\tchar *s;\r\n    \r\n\t// ...\r\n    \r\n\t// [1] this is the patch of CVE-2012-1823\r\n\tif((query_string = getenv(\"QUERY_STRING\")) != NULL && strchr(query_string, '=') == NULL) {\r\n\t\t/* we've got query string that has no = - apache CGI will pass it to command line */\r\n\t\tunsigned char *p;\r\n\t\tdecoded_query_string = strdup(query_string);\r\n\t\tphp_url_decode(decoded_query_string, strlen(decoded_query_string));\r\n\t\tfor (p = (unsigned char *)decoded_query_string; *p &&  *p <= ' '; p++) {\r\n\t\t\t/* skip all leading spaces */\r\n\t\t}\r\n\t\tif(*p == '-') {\r\n\t\t\tskip_getopt = 1;\r\n\t\t}\r\n\t\tfree(decoded_query_string);\r\n\t}\r\n    \r\n\twhile (!skip_getopt && (c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) {\r\n\t\tswitch (c) {\r\n\t\t\t// process the arguments\r\n        }\r\n        \r\n    }\r\n```\r\n\r\nThis argument `argv` is based on the `QUERY_STRING`, and the patch checks for no leading hyphen on the `QUERY_STRING` to ensure there are no dangerous arguments. However, if the binding between `argv` and `QUERY_STRING` is broken, the vulnerability of PHP-CGI Argument Injection would reappear!\r\n\r\nThis patch will fail under the Windows system. Internally, Windows uses UCS-2 as its character set. Any characters passed to the ANSI Win32 API (such as `GetCommandLineA`), especially those with code point greater than 0x80, will be mapped to the corresponding UCS-2 code points by the current code page.\r\n\r\nThe Windows internal also introduces a \"Best-Fit\" feature that replace the character if there is a more suitable character to display in the destination code page. \r\n\r\nThe description and specification can be found here:\r\n* [WindowsBestFit/readme.txt](https://ww\nPatched:  8.3.8,  8.2.20,  8.1.29","url":"https://github.com/php/php-src/security/advisories/GHSA-3qgc-jrrr-25jv","published_at":"2024-09-28T17:37:20Z","updated_at":"2024-09-28T17:37:20Z","fetched_at":"2026-11-22T14:05:37.431197Z","severity":"critical","cvss_score":9.8,"epss":0.99999,"is_kev":true,"has_exploit":true,"kev_due_date":"2022-04-15","vendor":"php","product":"php-src","vuln_id":"CVE-2024-4577","vuln_ids":["CVE-2012-1823","CVE-2024-4577","GHSA-3QGC-JRRR-25JV"],"tags":["repo-advisory","CWE-20","security","repo:php/php-src","stack"],"cluster_id":11775,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/12667","html":"https://vulnwatch.ve1ve2.com/item/12667"}},{"id":12669,"source":{"id":"gh-php-src","name":"PHP releases (GitHub php/php-src tags)"},"title":"GHSA-p99j-rfp4-xqvq / CVE-2024-8926: PHP CGI Parameter Injection Vulnerability (CVE-2024-4577 bypass)","summary":"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","url":"https://github.com/php/php-src/security/advisories/GHSA-p99j-rfp4-xqvq","published_at":"2024-09-27T17:50:38Z","updated_at":"2024-09-27T17:50:38Z","fetched_at":"2026-11-22T14:05:37.431198Z","severity":"critical","cvss_score":9.8,"epss":0.99985,"is_kev":true,"has_exploit":true,"kev_due_date":"2024-07-03","vendor":"php","product":"php-src","vuln_id":"CVE-2024-8926","vuln_ids":["CVE-2012-1823","CVE-2024-4577","CVE-2024-8925","CVE-2024-8926","CVE-2024-8927","CVE-2024-9026","GHSA-3QGC-JRRR-25JV","GHSA-P99J-RFP4-XQVQ","GHSA-VXPP-6299-MXW3"],"tags":["repo-advisory","security","repo:php/php-src","stack"],"cluster_id":11778,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/12669","html":"https://vulnwatch.ve1ve2.com/item/12669"}},{"id":13545,"source":{"id":"cisa-kev","name":"CISA Known Exploited Vulnerabilities"},"title":"CVE-2024-4577 added to KEV: PHP-CGI OS Command Injection Vulnerability","summary":"PHP, specifically Windows-based PHP used in CGI mode, contains an OS command injection vulnerability that allows for arbitrary code execution. This vulnerability is a patch bypass for CVE-2012-1823.\nRequired action: Apply mitigations per vendor instructions or discontinue use of the product if mitigations are unavailable.\nDue date: 2024-07-03\nKnown ransomware campaign use","url":"https://cisa.gov/known_exploited_vulnerabilities_catalog?search_api_fulltext=CVE-2024-4577","published_at":"2024-06-12T00:00:00Z","updated_at":null,"fetched_at":"2026-11-22T19:20:09.656241Z","severity":"critical","cvss_score":9.8,"epss":0.99999,"is_kev":true,"has_exploit":true,"kev_due_date":"2022-04-15","vendor":"PHP Group","product":"PHP","vuln_id":"CVE-2024-4577","vuln_ids":["CVE-2012-1823","CVE-2024-4577","GHSA-3QGC-JRRR-25JV"],"tags":["kev","ransomware"],"cluster_id":385,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/13545","html":"https://vulnwatch.ve1ve2.com/item/13545"}}]}