← Vulnerability feed

Vulnerability record · CVE-2012-2311 · published 11 May 2012

CVE-2012-2311: PHP-CGI query string option injection enables remote code execution

Php · Php

PHP versions before 5.3.13 and 5.4.x before 5.4.3, when run as a CGI script (php-cgi), mishandle query strings containing a %3D sequence without an equals sign. This lets remote attackers inject command-line options into the query string and execute arbitrary code. The flaw is an incomplete fix for CVE-2012-1823, so systems patched only for that earlier issue remain exposed.

7.5 CVSS 2.0 High EPSS 69% · top 0.7% CWE-89 · SQL injection
7.5CVSS 2.0 base score
69%EPSS exploitation probability, 30 days
NoNot in CISA KEV
1Affected product versions listed by NVD
34References
16 Jun 2026Last modified by NVD

Description

sapi/cgi/cgi_main.c in PHP before 5.3.13 and 5.4.x before 5.4.3, when configured as a CGI script (aka php-cgi), does not properly handle query strings that contain a %3D sequence but no = (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. NOTE: this vulnerability exists because of an incomplete fix for CVE-2012-1823.

AV:N/AC:L/Au:N/C:P/I:P/A:P

Automated analysis

Generated by VULONE's analysis model from the NVD record, CISA KEV and EPSS data on 19 September 2026. Confidence: high.

critical priorityUnauthenticated remote code execution with a very high EPSS score and a known incomplete-fix bypass makes this an urgent patching priority.

What it is

PHP versions before 5.3.13 and 5.4.x before 5.4.3, when run as a CGI script (php-cgi), mishandle query strings containing a %3D sequence without an equals sign. This lets remote attackers inject command-line options into the query string and execute arbitrary code. The flaw is an incomplete fix for CVE-2012-1823, so systems patched only for that earlier issue remain exposed.

Impact

An unauthenticated remote attacker can execute arbitrary code with the privileges of the php-cgi process, leading to full compromise of the web server or application host.

Attack surface

Reached over the network via HTTP requests to a php-cgi endpoint; no authentication or user interaction is required, as reflected by the AV:N/AC:L/Au:N vector.

Exploitation

Not listed in CISA KEV and no reference is tagged as exploit code, but EPSS is very high (0.69266, 99.3rd percentile), indicating strong likelihood of exploitation activity.

What to do

  • Upgrade PHP to 5.3.13 or 5.4.3 or later, which contain the complete fix for CVE-2012-1823 and this bypass.
  • If php-cgi cannot be patched immediately, disable the CGI SAPI and serve PHP through mod_php, php-fpm, or FastCGI instead.
  • Apply the vendor patch referenced in the PHP bug 61910 patch-display link if upgrading is not possible.
  • Restrict or block direct HTTP access to php-cgi binaries and remove any exposed cgi-bin PHP handlers.
  • Monitor vendor advisories (Debian, openSUSE, Apple, HP) for platform-specific fixed packages and apply them.

Detection

  • Inspect web and proxy logs for query strings containing %3D without an accompanying = character, especially with -d or other option-like tokens.
  • Alert on requests to php-cgi or cgi-bin paths that include command-line option patterns such as -d, -s, or -n in the query string.
  • Monitor php-cgi process behavior for unexpected child processes, file writes, or outbound connections following HTTP requests.
  • Audit hosts for PHP versions below 5.3.13 or 5.4.3 running the CGI SAPI.

This assessment is produced automatically and is not human-reviewed. Verify against the vendor advisory before acting on it.

Affected products

1 vulnerable configurations from NVD's CPE data, grouped by vendor and product.

References

LinkTags
http://eindbazen.net/2012/05/php-cgi-advisory-cve-2012-1823/
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
http://lists.opensuse.org/opensuse-security-announce/2012-05/msg00011.html
http://marc.info/?l=bugtraq&m=134012830914727&w=2
http://secunia.com/advisories/49014
http://secunia.com/advisories/49085
http://support.apple.com/kb/HT5501
http://www.debian.org/security/2012/dsa-2465
http://www.kb.cert.org/vuls/id/520827 US Government Resource
http://www.php.net/ChangeLog-5.php#5.4.3
http://www.php.net/archive/2012.php#id2012-05-08-1
http://www.securitytracker.com/id?1027022
https://bugs.php.net/bug.php?id=61910 Vendor Advisory
https://bugs.php.net/patch-display.php?bug_id=61910&patch=cgi.diff-fix-check.patch&revision=1336093719&display=1
https://h20564.www2.hp.com/portal/site/hpsc/public/kb/docDisplay?docId=emr_na-c03839862
http://eindbazen.net/2012/05/php-cgi-advisory-cve-2012-1823/
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
http://lists.opensuse.org/opensuse-security-announce/2012-05/msg00011.html
http://marc.info/?l=bugtraq&m=134012830914727&w=2
http://secunia.com/advisories/49014
http://secunia.com/advisories/49085
http://support.apple.com/kb/HT5501
http://www.debian.org/security/2012/dsa-2465
http://www.kb.cert.org/vuls/id/520827 US Government Resource
http://www.php.net/ChangeLog-5.php#5.4.3
http://www.php.net/archive/2012.php#id2012-05-08-1
http://www.securitytracker.com/id?1027022
https://bugs.php.net/bug.php?id=61910 Vendor Advisory
https://bugs.php.net/patch-display.php?bug_id=61910&patch=cgi.diff-fix-check.patch&revision=1336093719&display=1
https://h20564.www2.hp.com/portal/site/hpsc/public/kb/docDisplay?docId=emr_na-c03839862

Track CVE-2012-2311 inside VULONE

Watch it alongside the ransomware crews, C2 infrastructure and forum chatter that reference it, query it through the API and pull it into your SIEM over TAXII.

Start free Open in platform

Related vulnerabilities

Same products first, then exploited flaws of the same weakness class.

9.8CVE-2024-4577PHP-CGI on Windows argument injection leads to remote code executionPHP-CGI on Windows can misinterpret characters in the command line passed to Win32 API functions when certain code pages are configured, due to Windo…KEVEPSS 100%analysed9.8CVE-2019-11043PHP-FPM buffer overflow enables remote code executionPHP-FPM in certain configurations writes past allocated buffers into FCGI protocol data space, an out-of-bounds write (CWE-787, CWE-120). It affects …KEVEPSS 100%analysed9.8CVE-2012-1823PHP-CGI query string option injection enables remote code executionPHP versions before 5.3.12 and 5.4.x before 5.4.2, when run as a CGI script (php-cgi), mishandle query strings that lack an equals sign, allowing com…KEVEPSS 100%analysed10.0CVE-2015-0235glibc gethostbyname heap buffer overflow (GHOST)CVE-2015-0235 is a heap-based buffer overflow in the __nss_hostname_digits_dots function in glibc 2.2 and other 2.x versions before 2.18. It is reach…EPSS 95%analysed10.0CVE-2012-2688Php vulnerabilityUnspecified vulnerability in the _php_stream_scandir function in the stream implementation in PHP before 5.3.15 and 5.4.x before 5.4.5 has unknown im…EPSS 10%10.0CVE-2012-2376Php memory buffer overflow vulnerabilityBuffer overflow in the com_print_typeinfo function in PHP 5.4.3 and earlier on Windows allows remote attackers to execute arbitrary code via crafted …EPSS 20%10.0CVE-2011-3268Php memory buffer overflow vulnerabilityBuffer overflow in the crypt function in PHP before 5.3.7 allows context-dependent attackers to have an unspecified impact via a long salt argument, …EPSS 5.7%10.0CVE-2009-4143Php vulnerabilityPHP before 5.2.12 does not properly handle session data, which has unspecified impact and attack vectors related to (1) interrupt corruption of the S…EPSS 2.9%

Source: NIST National Vulnerability Database (record CVE-2012-2311), CISA KEV, FIRST EPSS (scores of 2026-09-26). This page is refreshed as NVD updates the record.