CVE-2012-1823·PHP vulnerability
sapi/cgi/cgi_main.c in PHP before 5.3.12 and 5.4.x before 5.4.2, when configured as a CGI script (aka php-cgi), does not properly handle query strings that lack an = (equals sign) character, which allows remote attackers to execute arbitrary code by placing command-line options in the query string, related to lack of skipping a certain php_getopt for the 'd' case.
- Severity
- critical
- Software
- PHP
- Fixed in
- 10.8.2
- Published
How Defensia detected this
Defensia agents read the web server logs of the Linux servers they protect and match incoming requests against exploitation signatures. When the same CVE is matched across enough independent servers, from enough distinct networks, it is recorded as being actively exploited. That threshold was crossed for CVE-2012-1823 starting , across 12% of the servers Defensia monitors, from 30 distinct attacking IP addresses.
Every CVE we currently measure under active exploitation is listed together, with the share of servers targeted and how long each has been running.
Where the attacks came from
Aggregated across every server Defensia monitors, over 12 days of observation, last measured . Counts are of distinct servers and distinct source addresses, not of requests. No customer, host or domain is identified.
How likely is exploitation
FIRST's Exploit Prediction Scoring System puts the probability of this CVE being exploited in the next 30 days at 100% — among the highest-scoring CVEs ever published. EPSS is an independent forecast of exploitation, not a severity rating: it says nothing about how much damage a successful attack does, which is what a CVSS score measures.
Affected versions
From: 10.8.0
Until: 10.8.2
Fixed in: 10.8.2
How to fix this CVE
PHP versions before 5.3.12 and 5.4.x before 5.4.2 contain a critical remote code execution vulnerability when running as a CGI application. Upgrade to PHP 5.3.12, 5.4.2, or later immediately. If you are running PHP-CGI directly (not through Apache mod_php or PHP-FPM), this vulnerability poses an immediate risk to your application.
sudo dnf update phpDefensia detects this vulnerability
What an exploitation attempt looks like
Sample log line indicative of exploitation attempts:
GET or POST requests containing query strings with patterns like ?-d=allow_url_include=on or ?-r=phpinfo matching regex: \?-[drts](?:=|\s|$)WAF mitigation (if patching is not yet possible)
Add this rule to your WAF to block exploitation attempts while you schedule the patch.
Block HTTP requests where the query string contains parameters that lack an equals sign and begin with a hyphen (e.g., ?-d or ?-r). Additionally, restrict access to PHP-CGI endpoints if not strictly required, and consider using PHP-FPM with a reverse proxy instead of direct CGI execution.How to check if you are affected
- Check installed PHP version: php -v or php -i | grep 'PHP Version'
- Verify if PHP is running as CGI: ps aux | grep php-cgi or check httpd/nginx configuration for php-cgi presence
- Search web server logs for query strings without '=' characters followed by suspicious parameters like -d or -r: grep -E '\?[a-zA-Z-]+' /var/log/apache2/access.log or equivalent nginx logs
- Confirm the patch was applied: php -v should show version 5.3.12+, 5.4.2+, or 5.5.0+ depending on your branch
FAQ
What is CVE-2012-1823?
This vulnerability allows attackers to execute arbitrary PHP code through malformed query strings when PHP is deployed as a CGI application. By omitting the equals sign in query parameters, attackers can inject PHP command-line options to modify script behavior and achieve remote code execution.
Is CVE-2012-1823 being actively exploited?
While CVE-2012-1823 is not currently listed in the CISA Known Exploited Vulnerabilities catalog, it received significant attention at the time of disclosure and remains a critical risk for legacy PHP-CGI deployments due to its ease of exploitation.
What versions of PHP are affected by CVE-2012-1823?
PHP versions before 5.3.12 and all 5.4.x versions before 5.4.2 are vulnerable. PHP 5.3.12, 5.4.2, and all versions of 5.5.0 and later are patched.
How do I check if my server is vulnerable to CVE-2012-1823?
Run php -v to check your version. If it reports 5.3.x below 5.3.12 or 5.4.0–5.4.1, you are vulnerable. Additionally, confirm PHP is running as CGI with ps aux | grep php-cgi.
Does Defensia detect CVE-2012-1823?
Yes — Defensia's CVE advisory scanner compares installed package versions against the NVD database. If PHP is installed on a monitored server, CVE-2012-1823 will appear in your dashboard with remediation steps.
Related PHP CVEs
References
- http://eindbazen.net/2012/05/php-cgi-advisory-cve-2012-1823/
- http://h20000.www2.hp.com/bizsupport/TechSupport/Document.jsp?objectID=c03360041
- http://lists.apple.com/archives/security-announce/2012/Sep/msg00004.html
- http://lists.opensuse.org/opensuse-security-announce/2012-05/msg00002.html
- http://lists.opensuse.org/opensuse-security-announce/2012-05/msg00007.html
Track CVEs across your fleet automatically
Defensia scans your Linux servers and tells you exactly which ones are running vulnerable versions — including CVE-2012-1823. Free for 1 server.
Get started free