This one’s from 2024, but if PHP has ever run on a Windows box of yours, XAMPP included, it’s worth a quick check.
At a glance
- CVE: CVE-2024-4577, a bypass of an old PHP-CGI bug (CVE-2012-1823). Orange Tsai of DEVCORE found it.
- Severity: 9.8 (Critical). No login needed, and it ends with an attacker’s code running on your server.
- Affected: PHP on Windows running as CGI, in versions before 8.1.29, 8.2.20 and 8.3.8. PHP on Linux and macOS isn’t affected. End-of-life branches (8.0, 7.x, 5.x) never got a fix.
- Known exploited: Yes. CISA added it to its KEV list on 2024-06-12, and the KEV entry says it’s been used in ransomware campaigns.
What’s going on
Back in 2012, PHP fixed a bug (CVE-2012-1823) where Apache could hand parts of a URL’s query string to php-cgi as command-line options. The fix was a simple check: if the query string starts with a hyphen, don’t treat it as options.
The catch is how Windows handles text. When a program gets its command line, Windows converts it to the system’s code page, and a feature called “Best-Fit” swaps characters it can’t show for ones that look close. On the Japanese (932), Simplified Chinese (936) and Traditional Chinese (950) code pages, the soft hyphen (0xAD) gets swapped for a regular hyphen. So an attacker sends %AD instead of -, PHP’s check doesn’t see a hyphen, and php-cgi.exe reads it as one anyway. From there they can pass PHP options like allow_url_include and auto_prepend_file and run their own PHP code, or simply dump your scripts’ source.
So who’s actually at risk? You need all three of these:
- Windows. PHP on Linux and macOS isn’t affected by this one.
- PHP running as CGI. That means Apache handing requests to
php-cgi.exe(for example through anActiondirective), or the PHP binary itself being reachable over the web, say through aScriptAliasto the PHP folder orphp-cgi.execopied intocgi-bin. - An affected code page. DEVCORE confirmed it on Windows set to Traditional Chinese, Simplified Chinese or Japanese. For other locales, such as English, Korean and Western European, they said they couldn’t rule out every attack path, so don’t assume you’re safe just because your server’s in English.
XAMPP for Windows is the big one. Its default config exposes the PHP folder with ScriptAlias /php-cgi/ "C:/xampp/php/", so DEVCORE says every Windows XAMPP install was vulnerable out of the box. The attacker only needs to reach Apache over HTTP, so an XAMPP that’s reachable from the internet or your office network is the one to worry about most. DEVCORE’s write-up doesn’t list mod_php, FastCGI or PHP-FPM setups as affected; in fact, it recommends moving to them.
Timeline
- Reported to PHP: 2024-05-07 (by DEVCORE)
- Patch released: 2024-06-06 (PHP 8.3.8, 8.2.20 and 8.1.29), the same day DEVCORE published its alert
- CVE published at NVD: 2024-06-09
- Added to CISA KEV: 2024-06-12
== UPDATE ==
Patches have been out since June 2024, so this is really about catching the Windows machines that slipped through.
- Patch available: Yep.
- Fixed in: PHP 8.1.29, 8.2.20, 8.3.8. PHP 8.4 came out later and isn’t listed as affected. Bear in mind 8.1 itself reached end of life on 31 Dec 2025, so it’s time to move off it anyway.
- How to apply: Check what you’re running with
php -v(on a default XAMPP install, that’sC:\xampp\php\php.exe -v). For a standalone PHP on Windows, grab a current build from windows.php.net, swap it in (keep yourphp.ini), and restart Apache. For XAMPP, move to a current XAMPP package: the Windows downloads on apachefriends.org now ship PHP 8.3.37, 8.4.28 and 8.5.13. While you’re at it, go to the newest release on your branch rather than the bare minimum. As of this write-up those are 8.2.36, 8.3.37, 8.4.28 and 8.5.13, and they include later security fixes too. - If you can’t patch yet: DEVCORE suggests a few stopgaps.
On XAMPP, if you don’t need PHP-CGI, open
C:/xampp/apache/conf/extra/httpd-xampp.conf, put a#in front of theScriptAlias /php-cgi/ "C:/xampp/php/"line, and restart Apache.For PHP-CGI behind Apache, this mod_rewrite rule blocks query strings that start with
%ad. DEVCORE only offers it as a temporary measure for the Chinese and Japanese locales:RewriteEngine On RewriteCond %{QUERY_STRING} ^%ad [NC] RewriteRule .? - [F,L]Longer term, move off PHP-CGI to mod_php, FastCGI or PHP-FPM. And if you’re still on PHP 8.0 or older, there’s no patch coming for those, so upgrading is the real fix.
References
- https://github.com/php/php-src/security/advisories/GHSA-3qgc-jrrr-25jv
- https://www.php.net/ChangeLog-8.php#8.3.8
- https://devco.re/blog/2024/06/06/security-alert-cve-2024-4577-php-cgi-argument-injection-vulnerability-en/
- https://blog.orange.tw/2024/06/cve-2024-4577-yet-another-php-rce.html
- https://nvd.nist.gov/vuln/detail/CVE-2024-4577
- https://www.cisa.gov/known-exploited-vulnerabilities-catalog
- https://www.apachefriends.org/download.html
- https://windows.php.net/download/
- https://www.php.net/eol.php
- http://www.openwall.com/lists/oss-security/2024/06/07/1
- https://arstechnica.com/security/2024/06/php-vulnerability-allows-attackers-to-run-malicious-code-on-windows-servers/
- https://github.com/watchtowrlabs/CVE-2024-4577
- https://github.com/rapid7/metasploit-framework/pull/19247