critical CVSS 9.8 Actively exploited EPSS 100% Public exploit available

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

US · 35BR · 29JP · 22TW · 10SG · 9

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 php

Defensia 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

  1. Check installed PHP version: php -v or php -i | grep 'PHP Version'
  2. Verify if PHP is running as CGI: ps aux | grep php-cgi or check httpd/nginx configuration for php-cgi presence
  3. 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
  4. 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

CVE-2025-25174CVSS 10Improper Control of Filename for Include/Require Statement in PHP Program ('PHP Remote File Inclusion') vulnerability in beeteam368 BeeTeam368 Extensions beeteam368-extensions allows PHP Local File Inclusion.This issue affects BeeTeam368 Extensions: from n/a through <= 1.9.4.
CVE-2025-47916CVSS 10Invision Community 5.0.0 before 5.0.7 allows remote code execution via crafted template strings to themeeditor.php. The issue lies within the themeeditor controller (file: /applications/core/modules/front/system/themeeditor.php), where a protected method named customCss can be invoked by unauthenticated users. This method passes the value of the content parameter to the Theme::makeProcessFunction() method; hence it is evaluated by the template engine. Accordingly, this can be exploited by unauthenticated attackers to inject and execute arbitrary PHP code by providing crafted template strings.
CVE-2025-62521CVSS 10ChurchCRM is an open-source church management system. Prior to version 5.21.0, a pre-authentication remote code execution vulnerability in ChurchCRM's setup wizard allows unauthenticated attackers to inject arbitrary PHP code during the initial installation process, leading to complete server compromise. The vulnerability exists in `setup/routes/setup.php` where user input from the setup form is directly concatenated into a PHP configuration template without any validation or sanitization. Any parameter in the setup form can be used to inject PHP code that gets written to `Include/Config.php`, which is then executed on every page load. This is more severe than typical authenticated RCE vulnerabilities because it requires no credentials and affects the installation process that administrators must complete. Version 5.21.0 patches the issue.
CVE-2026-39337CVSS 10ChurchCRM is an open-source church management system. Prior to 7.1.0, critical pre-authentication remote code execution vulnerability in ChurchCRM's setup wizard allows unauthenticated attackers to inject arbitrary PHP code during the initial installation process, leading to complete server compromise. The "$dbPassword" variable is not sanitized. This vulnerability exists due to an incomplete fix for CVE-2025-62521. This vulnerability is fixed in 7.1.0.
CVE-2026-28289CVSS 10FreeScout is a free help desk and shared inbox built with PHP's Laravel framework. A patch bypass vulnerability for CVE-2026-27636 in FreeScout 1.8.206 and earlier allows any authenticated user with file upload permissions to achieve Remote Code Execution (RCE) on the server by uploading a malicious .htaccess file using a zero-width space character prefix to bypass the security check. The vulnerability exists in the sanitizeUploadedFileName() function in app/Http/Helper.php. The function contains a Time-of-Check to Time-of-Use (TOCTOU) flaw where the dot-prefix check occurs before sanitization removes invisible characters. This vulnerability is fixed in 1.8.207.

References

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