CVE DatabaseCVE-2012-1823
한국어 권고문 →
CVE-2012-18239.8/CRITICALCISA KEVCWE-77CWE-77

PHP-CGI Remote Code Execution (RCE) Vulnerability Analysis and Mitigation Guide (CVE-2012-1823)

⚡ Jump to Patch
Affected Vendors
php
Affected Components
php
Published Date
2012-05-11
CVSS v3.1
9.8
CRITICAL
EPSS (30d)
100.0%
FIRST.org
CISA KEV
Exploited

Executive & SecOps Summary

SECOPS ASSESSMENT
Affected Scope

PHP versions before 5.3.12 and 5.4.x before 5.4.2, configured to run as a CGI script (php-cgi)

Impact

Unauthenticated remote attackers can execute arbitrary code by injecting command-line options via HTTP query strings

Mitigation

Upgrade to patched PHP versions or configure web server rewrite rules to block malicious query strings

Affected Products & Version Scope

PHP versions prior to 5.3.12 and 5.4.x prior to 5.4.2 when configured as a CGI script

Remediation & Live Workaround Commands

PATCH & WORKAROUND

1. Official Patch & Version Upgrade Commands

The recommended solution is to upgrade PHP to version 5.3.12, 5.4.2, or higher. Use the system package manager to apply the updates.

bash
# For Debian/Ubuntu-based systems
sudo apt-get update
sudo apt-get install --only-upgrade php5-cgi

# For CentOS/RHEL-based systems
sudo yum update php-cli php-common

2. Temporary Workaround & Hardening Configuration

If upgrading is not immediately feasible, configure your web server to reject requests containing query strings that start with a hyphen (-) and lack an equals sign (=).

nginx
# Add to the server block in Nginx configuration (nginx.conf)
if ($query_string ~* '^\-[sdcr]') {
    return 403;
}

3. Log Audit & IoC Verification Commands

Use the following commands to inspect web server access logs for potential exploitation attempts and verify the active PHP-CGI version.

bash
# Search access logs for common exploitation patterns
grep -Ei 'allow_url_include|auto_prepend_file|cgi_main' /var/log/nginx/access.log /var/log/apache2/access.log 2>/dev/null

# Verify the installed PHP-CGI version
php-cgi -v
Interactive SecOps Remediation Checklist
0/4 (0%)
Recommended Security Control & Mitigation Partner
Cloudflare Enterprise & Pro WAF
Immediately upgrade legacy PHP installations to supported versions and restrict direct access to the PHP-CGI binary.

Block Exploits Instantly with Managed Virtual Patching Rules

Can't patch production immediately? Deploy managed WAF rules at the edge to intercept RCE, SQLi, and deserialization payloads before they hit your origin server.

3-min setup · Automated Zero-Day Managed Rules
Practice Exploiting & Patching This Web Vulnerability in an Interactive Lab
Launch Hands-On Security Lab

Technical Root Cause & Exploitation Mechanics

1. Vulnerability Overview & Root Cause

This vulnerability exists in the CGI SAPI (sapi/cgi/cgi_main.c) of PHP. According to RFC 3875, query strings that do not contain an equals sign (=) must be passed to the CGI script as command-line arguments. However, PHP-CGI fails to properly filter these arguments, allowing command-line options (such as -d, -s, -c) to be parsed directly by the PHP binary.

2. Exploitation Mechanics & Attack Scenario

An attacker sends an HTTP request with a query string containing command-line arguments instead of standard parameters (e.g., '-d+allow_url_include=on+-d+auto_prepend_file=php://input'). This dynamically alters the PHP configuration for that request. By sending malicious PHP code in the POST request body, the attacker forces the server to execute the payload via the 'php://input' wrapper, achieving full Remote Code Execution (RCE).

3. Infrastructure & Business Impact

Listed in the CISA KEV catalog with an EPSS score of 1.0, this vulnerability is highly active in the wild. Successful exploitation grants the attacker the privileges of the web server user, leading to potential database compromise, web shell deployment, lateral movement, and complete infrastructure takeover.

Official Vendor Advisories & References

Frequently Asked SecOps Questions (CVE-2012-1823)

FAQ

Q1. How critical is CVE-2012-1823 and is it actively exploited in the wild?

CVE-2012-1823 is rated CVSS 9.8 (CRITICAL) with a 30-day EPSS exploitation probability of 100.0%. It is listed in the CISA Known Exploited Vulnerabilities (KEV) catalog, requiring immediate emergency remediation.

Q2. Which vendors and products are affected by CVE-2012-1823?

Primary impacted vendors include php across php. Scope summary: PHP versions prior to 5.3.12 and 5.4.x prior to 5.4.2 when configured as a CGI script

Q3. What temporary mitigations or workarounds exist for CVE-2012-1823 before patching?

[Mitigation] Upgrade to patched PHP versions or configure web server rewrite rules to block malicious query strings Follow the CLI remediation commands and interactive SecOps checklist on this page to restrict exposure prior to your maintenance window.

SECOPS WORKBENCH INTEGRATION

Generate an Internal Engineering Notice or CISO Report for CVE-2012-1823

Instantly format this advisory into an executive CISO summary or engineering patch ticket.

Generate Report →

🔗 Related Advisories in Similar Stack (php)

View Category →
SecOps Advisory Dispatch & RSS Feed

Subscribe to Daily Vulnerability Briefings & KEV Alerts

Concise morning briefings for SecOps, DevSecOps, and SRE teams covering newly exploited CVEs and mitigation priorities.

Slack / Teams / RSS Feed:
PatchKO
CVE-2012-1823 PHP-CGI Remote Code Execution (RCE) Vulnerability Analysis and Mitigation Guide (CVE-2012-1823) (CVSS 9.8) - Patch & Workaround | CVE Pulse