PHP-CGI on Windows: an exploited flaw that ransomware uses

CVE-2024-4577 lets an attacker run code on a Windows server that runs PHP as CGI, without logging in. It was fixed in June 2024, added to the CISA list of exploited vulnerabilities three days later, and is known to be used in ransomware attacks. Old XAMPP installs on Windows are a common case.

  • CVECVE-2024-4577
  • SeverityCVSS 9.8 Critical
  • ProductPHP on Windows
  • ExploitationActively exploited (CISA KEV)

What happened

In 2012 PHP fixed CVE-2012-1823, a flaw that let parts of a web request reach php-cgi as command-line options. CVE-2024-4577 is a way around that old fix. On Windows, with certain system code pages, the old protection no longer holds. The researchers at Devcore name the Chinese and Japanese locales.

The result is code execution without a login. NVD rates it 9.8 under CVSS 3.1. CISA added it to its Known Exploited Vulnerabilities catalog on 12 June 2024 and lists ransomware use as known.

Who is affected

PHP branchVulnerableRecommended version
8.1Before 8.1.29Move to a supported branch
8.2Before 8.2.208.2.36 or later
8.3Before 8.3.88.3.37 or later
8.4 and 8.5Not named in this CVE8.4.28 or 8.5.13 or later
8.0 and olderYes, and no fix will comeMove to a supported branch

The recommended versions are the November 2026 releases. They also fix php2shell, so do not stop at the 2024 versions.

The flaw needs Windows, with Apache running PHP as CGI so that php-cgi.exe can be reached, and certain system code pages. The default XAMPP for Windows was set up this way. Linux servers and Windows servers using PHP-FPM or mod_php are not affected by this CVE.

How to check your server

Check the PHP version, then look in the Apache configuration for signs of CGI mode.

php -v
findstr /S /I /N "ScriptAlias php-cgi.exe x-httpd-php" C:\xampp\apache\conf\*.conf
# Look for ScriptAlias, "Action application/x-httpd-php" or php-cgi.exe

Adjust the path to where your Apache configuration lives. If httpd.conf or an included file points PHP requests at php-cgi.exe, the server runs PHP as CGI.

How to fix it

  • Upgrade PHP to a supported branch: 8.2.36, 8.3.37, 8.4.28 or 8.5.13 or later.
  • Stop running PHP as CGI. Use mod_php, or FastCGI with PHP-FPM.
  • Do not use XAMPP in production. It is built for local development.
  • Restart Apache and confirm the PHP version through the web server, not only the command line.
  • If you run PHP 8.1 or older, plan the move to 8.3 or 8.4 now.

What to look for

Because this flaw is used by ransomware groups, a vulnerable server that faced the internet should be checked carefully. Look for new or changed PHP files in the web root, unknown Windows user accounts, new scheduled tasks and services, and outbound connections from the web server process. A web application security test covers PHP setup and exposed endpoints.

Questions

My server uses an English locale. Am I safe?

The known cases depend on certain code pages, such as Chinese and Japanese. Other locales may be less exposed, but do not rely on that. Upgrade PHP and stop using CGI mode.

Does this affect PHP on Linux?

No. This CVE is specific to Windows. PHP on Linux still needs current versions for other flaws, such as php2shell.

We only use XAMPP for testing. Do we need to act?

Yes, if the machine can be reached from a network you do not fully trust. Update XAMPP and keep it off the internet.

This article is written for defenders and contains no exploit code. It reflects the vendor advisories on the date above; always check the vendor advisory for the latest fixed versions.

Not sure whether you are affected?

We check your servers and applications for this vulnerability and others like it, and give you a clear report with fixes.

Request an assessmentWeb Application Penetration Testing