ZeroHour

CVE-2012-1823

KEVmass

PHP-CGI Query String Parsing Flaw Enables Unauthenticated Remote Code Execution

CISA: PHP-CGI Query String Parameter Vulnerability

CVSS
EPSS
100%p100
Published
KEV added
AI analysis

PHP, when the interpreter is exposed through the CGI (php-cgi) interface, mishandles query strings (CWE-20 improper input validation), allowing attackers to pass command-line switches such as -d and -s directly to the interpreter. A remote, unauthenticated attacker triggers the flaw by sending a crafted query string beginning with a dash (including URL-encoded forms) to any URL handled by php-cgi. Successful exploitation allows arbitrary code execution under the web server's privileges, as well as disclosure of script source code or phpinfo output, with no authentication required. Only deployments that invoke PHP via CGI/FastCGI (common in legacy shared hosting and bundled software stacks) are affected; PHP running as an Apache module or via PHP-FPM is not exposed. The flaw was added to CISA's Known Exploited Vulnerabilities catalog on 2022-03-25 with EPSS at 100%, indicating active in-the-wild exploitation; any ransomware association is not yet confirmed.

What to do: Upgrade PHP to at least 5.3.13/5.4.3 or, preferably, a currently supported PHP branch, and stop exposing the php-cgi binary directly by moving to mod_php or PHP-FPM. As an interim mitigation, block or rewrite requests whose query string begins with a dash (e.g., -d, -s, or URL-encoded dash characters) and review web server logs for such patterns to detect prior exploitation.

Affected
PHPDeployments running PHP through the CGI (php-cgi) interface at the time of disclosure; per public advisories this includes versions prior to 5.3.12/5.4.2, fixed
Estimated exposure
masshundreds of thousands of internet-exposed php-cgi endpoints (a subset of the tens of millions of PHP-powered websites) — PHP has historically powered the majority of web-facing sites, and legacy CGI/FastCGI deployments remain common in long-tail shared hosting and bundled software, so the affected subset plausibly exceeds 100,000 exposed systems based on…

Order-of-magnitude estimate by the model from install counts, market share and public scan data it knows; verify before quoting.

Description

sapi/cgi/cgi_main.c in PHP, when configured as a CGI script, does not properly handle query strings, which allows remote attackers to execute arbitrary code.

CISA Known Exploited Vulnerability
Affected
PHP PHP
Required action
Apply updates per vendor instructions.
Due date
Ransomware use
Unknown
Vendors
PHP
Products
PHP
Weakness
CWE-20

In the news