PHP vulnerability that enables code execution when operating in CGI mode

In PHP identified vulnerability (CVE-2024-4577), allowing you to execute your code on the server or view the source code of a PHP script if you use PHP in CGI mode on the Windows platform (configurations with mod_php, php-fpm and FastCGI are not vulnerable). Issue fixed in releases PHP 8.3.8, 8.2.20 and 8.1.29.

The vulnerability is a special case of CVE-2012-1823, which was fixed in 2012, for which the added protection was not sufficient to block the attack on the Windows platform. The attack method boils down to the possibility of substituting a command line argument when starting the PHP interpreter through manipulating the request parameters to a PHP script.

In the old vulnerability CVE-2012-1823, for exploitation it was enough to specify command line options instead of query parameters, for example, ” to show the source code of the script. The new vulnerability is based on the fact that the Windows platform provides automatic character conversion, which allows you to bypass previously added protection by specifying characters that are present in some encodings and are replaced by the “-” character (for example,

The vulnerability has been confirmed in configurations with locales for Traditional Chinese (cp950), Simplified Chinese (cp936) and Japanese (cp932), but it is possible that it may occur in other locales. The problem appears in the default configuration in the set XAMPP (Apache + MariaDB + PHP + Perl), as well as in any Apache configurations in which php-cgi is set as a CGI script handler using the 'Action cgi-script “/cgi-bin/php-cgi.exe” setting or 'Action application/x-httpd-php-cgi “/php-cgi/php-cgi.exe”', or when directly placing the php interpreter in “/cgi-bin” and any other directories where CGI execution is allowed scripts via the ScriptAlias ​​directive.

In addition, PHP updates 8.3.8, 8.2.20 and 8.1.29 eliminated three more vulnerabilities:

  • CVE-2024-5458 – Possibility of filter bypass
    FILTER_VALIDATE_URLused when calling the function filter_var.
  • CVE-2024-5585 is an alternative attack vector for the vulnerability. CVE-2024-1874which allows you to bypass previously added protection and perform command substitution when calling bat and cmd files through the proc_open function on the Windows platform (BatBadBut vulnerability).
  • The openssl_private_decrypt function is susceptible to the Marvin attack.

Thanks for reading: