CVE-2024-4577
php: Argument Injection in PHP-CGI
Publication Date | 2024-06-07 |
---|---|
Severity | Critical |
Type | Cross-Site Request Forgery |
Affected PHP Versions |
|
Fixed Product Versions |
|
CVE Details
When using Apache and PHP-CGI on Windows, if the system is set up to use certain code pages, Windows may use the "Best-Fit" behavior to replace characters in the command line given to Win32 API functions. The PHP CGI module may misinterpret those characters as PHP options that allow a malicious user to pass options to the PHP binary being run, revealing the source code of scripts or running arbitrary PHP code on the server.
Recommendations
We strongly recommend upgrading to a known patched version of PHP immediately.
If you cannot, you can mitigate this attack in a couple of ways:
-
apply a mod_rewrite rule to block attacks, like the following:
RewriteEngine On RewriteCond %{QUERY_STRING} ^%ad [NC] RewriteRule .? – [F,L]
-
If you use XAMPP and do not need the PHP CGI feature, find the 'ScriptAlias' directive in the Apache configuration file (typically at 'C:/xampp/apache/conf/extra/httpd-xampp.conf') and comment it out.
Admins can determine if they use PHP-CGI using the phpinfo() function and checking the 'Server API' value in the output.
It is suggested that system administrators consider migrating from CGI to more secure alternatives, like FastCGI, PHP-FPM, and Mod-PHP.