CVE-2012-1823

CRITICAL KEV NUCLEI LAB

PHP < 5.3.12 and 5.4.x < 5.4.2 - Remote Code Execution via CGI Query String

Title source: llm
STIX 2.1

Exploitation Summary

CVE-2012-1823 is actively exploited and listed in the CISA Known Exploited Vulnerabilities (KEV) catalog, added March 25, 2022. EIP tracks 17 public exploits from researchers including 0xl0k1, Unix13, tardummy01, including a Metasploit module exploits/multi/http/php_cgi_arg_injection. A Nuclei detection template is also available.

AI-analyzed exploit summary This repository contains a functional exploit for CVE-2012-1823, which leverages PHP CGI argument injection to achieve remote code execution. The exploit uses a crafted query string to inject PHP code via the `allow_url_include` and `auto_prepend_file` directives.

Description

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.

Exploits (17)

nomisec WORKING POC 11 stars
by 0xl0k1 · remote
https://github.com/0xl0k1/CVE-2012-1823

This repository contains a functional exploit for CVE-2012-1823, which leverages PHP CGI argument injection to achieve remote code execution. The exploit uses a crafted query string to inject PHP code via the `allow_url_include` and `auto_prepend_file` directives.

Classification
Working Poc 95%
Attack Type
Rce
Complexity
Trivial
Reliability
Reliable
Target: PHP < 5.3.12 or < 5.4.2 (configured as CGI)
No auth needed
Prerequisites: Target must be running vulnerable PHP version as CGI · Network access to the target
devstral-2 · analyzed Feb 16, 2026 Full analysis →
nomisec WORKING POC 4 stars
by Unix13 · poc
https://github.com/Unix13/metasploitable2

This PHP script establishes a reverse shell connection to a specified IP and port, then executes arbitrary commands received from the remote server. It uses multiple socket methods for redundancy and reads a length-prefixed payload for execution via eval().

Classification
Working Poc 90%
Attack Type
Rce
Complexity
Moderate
Reliability
Reliable
Target: PHP-based applications (likely targeting Metasploitable2 or similar vulnerable environments)
No auth needed
Prerequisites: Network access to the target · PHP execution environment on the target · Outbound connectivity to attacker's IP:port
devstral-2 · analyzed Feb 16, 2026 Full analysis →
nomisec WORKING POC 3 stars
by tardummy01 · remote
https://github.com/tardummy01/oscp_scripts-1

This repository contains multiple Python scripts demonstrating HTTP request handling, network socket operations, and basic enumeration techniques. The scripts include examples of HTTP GET/HEAD/OPTIONS requests, TCP/UDP client-server implementations, and a simple enumeration script.

Classification
Working Poc 90%
Attack Type
Other
Complexity
Trivial
Reliability
Reliable
Target: Generic HTTP servers and network services
No auth needed
Prerequisites: Python 2.x environment · Network connectivity to target services
devstral-2 · analyzed Feb 16, 2026 Full analysis →
nomisec WRITEUP 1 stars
by hackherMind-Pixel · poc
https://github.com/hackherMind-Pixel/Vulnerable-Lab-Exploitation

This repository is a writeup documenting the exploitation of CVE-2012-1823, a PHP-CGI argument injection vulnerability, using Metasploit to achieve remote code execution on a Metasploitable 2 target. It includes steps for lab setup, reconnaissance, exploitation, and post-exploitation.

Classification
Writeup 100%
Attack Type
Rce
Complexity
Trivial
Reliability
Reliable
Target: PHP-CGI (versions before 5.3.12 and 5.4.2)
No auth needed
Prerequisites: Outdated PHP-CGI installation · Network access to the target · Metasploit Framework
devstral-2 · analyzed Feb 16, 2026 Full analysis →
nomisec SCANNER 1 stars
by Dmitri131313 · poc
https://github.com/Dmitri131313/CVE-2012-1823-exploit-for-https-user-password-web

The repository contains two Python scripts: one for checking vulnerabilities (CVE-2012-1823 and CVE-2021-2291) and another for exploiting CVE-2012-1823 via PHP CGI argument injection. The exploit script sends a GET request with a command injection payload to a target URL.

Classification
Scanner 80%
Attack Type
Rce
Complexity
Trivial
Reliability
Reliable
Target: PHP CGI (versions affected by CVE-2012-1823)
Auth required
Prerequisites: Target URL with vulnerable PHP CGI · Valid credentials for HTTP Basic Auth
devstral-2 · analyzed Feb 16, 2026 Full analysis →
nomisec WORKING POC 1 stars
by cyberharsh · poc
https://github.com/cyberharsh/PHP_CVE-2012-1823

This repository contains a working proof-of-concept for CVE-2012-1823, a PHP-CGI remote code execution vulnerability. It includes a Docker-based test environment and demonstrates how to exploit the vulnerability by injecting command-line arguments via the query string to achieve arbitrary code execution.

Classification
Working Poc 100%
Attack Type
Rce
Complexity
Trivial
Reliability
Reliable
Target: PHP < 5.3.12 or PHP < 5.4.2
No auth needed
Prerequisites: PHP running in CGI mode · Access to the target web server
devstral-2 · analyzed Feb 16, 2026 Full analysis →
nomisec SCANNER 1 stars
by drone789 · remote
https://github.com/drone789/CVE-2012-1823

This script checks for CVE-2012-1823, a PHP CGI vulnerability, by sending a crafted request to common PHP CGI paths and verifying if the target is vulnerable by checking for a specific response string.

Classification
Scanner 90%
Attack Type
Rce
Complexity
Trivial
Reliability
Reliable
Target: PHP CGI (versions before 5.3.12 and 5.4.2)
No auth needed
Prerequisites: PHP CGI installed and accessible via common paths
devstral-2 · analyzed Feb 16, 2026 Full analysis →
nomisec WORKING POC
by tryj · poc
https://github.com/tryj/CVE-2012-1823---PHP-CGI---RCE

This repository contains a functional Python exploit for CVE-2012-1823, which targets PHP-CGI configurations to achieve remote code execution by injecting command-line arguments via the query string. The exploit leverages the `-d` directive to override PHP settings and execute arbitrary commands.

Classification
Working Poc 95%
Attack Type
Rce
Complexity
Trivial
Reliability
Reliable
Target: PHP-CGI (versions prior to fixes for CVE-2012-1823)
No auth needed
Prerequisites: PHP running in CGI mode · Access to a vulnerable endpoint
devstral-2 · analyzed Apr 10, 2026 Full analysis →
nomisec WRITEUP
by waburig · poc
https://github.com/waburig/Open-Worldwide-Application-Security-Project-OWASP-

This repository is a writeup describing the use of OWASP ZAP to assess vulnerabilities in DVWA, specifically referencing CVE-2012-1823 for Remote Code Execution. It does not contain actual exploit code or a proof-of-concept.

Classification
Writeup 90%
Attack Type
Rce
Complexity
Moderate
Reliability
Theoretical
Target: DVWA (Damn Vulnerable Web Application)
No auth needed
Prerequisites: OWASP ZAP installed · Access to DVWA instance
devstral-2 · analyzed Feb 16, 2026 Full analysis →
nomisec WRITEUP
by nulltrace1336 · poc
https://github.com/nulltrace1336/PHP-CGI-Argument-Injection-Exploit

This is a writeup for exploiting CVE-2012-1823 using Metasploit's php_cgi_arg_injection module. It provides step-by-step instructions for targeting a vulnerable PHP CGI configuration.

Classification
Writeup 100%
Attack Type
Rce
Complexity
Trivial
Reliability
Reliable
Target: PHP CGI (versions prior to 5.3.12 and 5.4.2)
No auth needed
Prerequisites: Vulnerable PHP CGI configuration · Network access to the target
devstral-2 · analyzed Feb 16, 2026 Full analysis →
nomisec STUB
by Jimmy01240397 · poc
https://github.com/Jimmy01240397/CVE-2012-1823-Analyze

The repository contains minimal setup scripts for Apache with CGI modules enabled, likely intended to replicate a vulnerable environment for CVE-2012-1823 (PHP CGI argument injection). However, no actual exploit code or payload is present.

Classification
Stub 80%
Attack Type
Rce
Complexity
Trivial
Reliability
Theoretical
Target: PHP CGI (versions prior to 5.3.12 or 5.4.2)
No auth needed
Prerequisites: Apache with CGI enabled · PHP CGI installed and misconfigured
devstral-2 · analyzed Feb 16, 2026 Full analysis →
vulncheck_xdb WRITEUP
remote
https://github.com/lh-dang/anninhweb

This repository provides a detailed technical analysis of CVE-2012-1823, a PHP-CGI argument injection vulnerability leading to Remote Code Execution (RCE). It includes explanations of the exploit mechanism, payload construction, and practical exploitation steps using tools like curl and Metasploit.

Classification
Writeup 95%
Attack Type
Rce
Complexity
Moderate
Reliability
Reliable
Target: PHP (versions ≤ 5.3.12 or 5.4.2) in CGI mode
No auth needed
Prerequisites: PHP running in CGI mode · PHP version ≤ 5.3.12 or 5.4.2 · Server not configured with --no-header or --force-cgi-redirect
devstral-2 · analyzed Feb 25, 2026 Full analysis →
exploitdb WORKING POC
pythonremotephp
https://www.exploit-db.com/exploits/18836

This exploit leverages PHP CGI argument injection (CVE-2012-1823) by sending a crafted HTTP POST request with malicious query parameters to enable remote code execution via PHP directives. The payload injects PHP code through the `auto_prepend_file` directive, demonstrating the vulnerability.

Classification
Working Poc 95%
Attack Type
Rce
Complexity
Trivial
Reliability
Reliable
Target: PHP CGI (versions before 5.3.12 and 5.4.2)
No auth needed
Prerequisites: PHP CGI mode enabled · Network access to the target server
devstral-2 · analyzed Feb 19, 2026 Full analysis →
exploitdb WORKING POC
rubyremotephp
https://www.exploit-db.com/exploits/18834

This Metasploit module exploits CVE-2012-1823, a PHP CGI argument injection vulnerability, by leveraging the -d flag to manipulate php.ini directives and achieve remote code execution. It sends a crafted POST request with malicious PHP code in the body, which is executed due to the misconfigured directives.

Classification
Working Poc 100%
Attack Type
Rce
Complexity
Moderate
Reliability
Reliable
Target: PHP up to 5.3.12 and 5.4.2 (when run as CGI)
No auth needed
Prerequisites: Target must be running PHP as a CGI binary · Access to a CGI-handled PHP script
devstral-2 · analyzed Feb 19, 2026 Full analysis →
exploitdb WORKING POC
pythonremotephp
https://www.exploit-db.com/exploits/29316

This exploit targets CVE-2012-1823, a remote code execution vulnerability in PHP CGI configurations. It crafts a malicious HTTP POST request to trigger arbitrary command execution via PHP's query string parameter handling. The script supports vulnerability scanning, command execution, and reverse shell payloads.

Classification
Working Poc 95%
Attack Type
Rce
Complexity
Moderate
Reliability
Reliable
Target: PHP CGI (versions 5.3.x and 5.4.x with certain configurations)
No auth needed
Prerequisites: PHP installed as CGI · Exposed PHP CGI binary · Network access to target
devstral-2 · analyzed Feb 19, 2026 Full analysis →
exploitdb WORKING POC
cremotephp
https://www.exploit-db.com/exploits/29290

This exploit targets CVE-2012-1823, a vulnerability in PHP CGI implementations where improper handling of command-line arguments allows bypassing security checks. The exploit crafts a malicious POST request to execute arbitrary PHP code, leading to remote command execution.

Classification
Working Poc 100%
Attack Type
Rce
Complexity
Moderate
Reliability
Reliable
Target: PHP (versions prior to 5.3.12 and 5.4.2)
No auth needed
Prerequisites: PHP CGI installed and accessible via /cgi-bin/php or /cgi-bin/php5 · Apache web server
devstral-2 · analyzed Feb 19, 2026 Full analysis →
metasploit WORKING POC EXCELLENT
by egypt, hdm, jjarmoc, kingcope, juan vazquez · rubypocphp
https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/multi/http/php_cgi_arg_injection.rb

This Metasploit module exploits CVE-2012-1823, an argument injection vulnerability in PHP CGI up to versions 5.3.12 and 5.4.2. It leverages the -d flag to manipulate php.ini directives and achieve remote code execution by injecting malicious PHP code via the auto_prepend_file directive.

Classification
Working Poc 100%
Attack Type
Rce
Complexity
Moderate
Reliability
Reliable
Target: PHP CGI (versions up to 5.3.12 and 5.4.2)
No auth needed
Prerequisites: Target must be running PHP as a CGI · Access to a CGI-handled PHP script
devstral-2 · analyzed Feb 16, 2026 Full analysis →

Nuclei Templates (1)

PHP CGI v5.3.12/5.4.2 Remote Code Execution
HIGHby pikpikcu
Shodan: cpe:"cpe:2.3:a:php:php"

References (31)

Core 31
Core References
Third Party Advisory
http://support.apple.com/kb/HT5501
Exploit, Patch, Release Notes
http://www.php.net/ChangeLog-5.php#5.4.2
Mailing List, Third Party Advisory vendor-advisory
http://lists.opensuse.org/opensuse-security-announce/2012-05/msg00011.html
Broken Link, Third Party Advisory, VDB Entry vdb-entry
http://www.securitytracker.com/id?1027022
Mailing List, Third Party Advisory vendor-advisory
http://lists.opensuse.org/opensuse-security-announce/2012-05/msg00002.html
Third Party Advisory vendor-advisory
http://rhn.redhat.com/errata/RHSA-2012-0546.html
Third Party Advisory vendor-advisory
http://rhn.redhat.com/errata/RHSA-2012-0568.html
Third Party Advisory vendor-advisory
http://rhn.redhat.com/errata/RHSA-2012-0569.html
Broken Link third-party-advisory
http://secunia.com/advisories/49014
Third Party Advisory vendor-advisory
http://rhn.redhat.com/errata/RHSA-2012-0570.html
Mailing List, Third Party Advisory vendor-advisory
http://lists.opensuse.org/opensuse-security-announce/2012-05/msg00007.html
Third Party Advisory, US Government Resource third-party-advisory
http://www.kb.cert.org/vuls/id/673343
Third Party Advisory vendor-advisory
http://rhn.redhat.com/errata/RHSA-2012-0547.html
Mailing List, Third Party Advisory vendor-advisory
http://lists.apple.com/archives/security-announce/2012/Sep/msg00004.html
Broken Link third-party-advisory
http://secunia.com/advisories/49065
Exploit, Third Party Advisory, US Government Resource third-party-advisory
http://www.kb.cert.org/vuls/id/520827
Third Party Advisory vendor-advisory
http://www.debian.org/security/2012/dsa-2465
Broken Link third-party-advisory
http://secunia.com/advisories/49085
Broken Link third-party-advisory
http://secunia.com/advisories/49087

Scores

CVSS v3 9.8
EPSS 0.9436
EPSS Percentile 100.0%
Attack Vector NETWORK
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

CISA SSVC

Vulnrichment
Exploitation active
Automatable yes
Technical Impact total

Details

CISA KEV 2022-03-25
VulnCheck KEV 2012-06-19
InTheWild.io 2022-03-25
ENISA EUVD EUVD-2012-1833
CWE
CWE-77
Status published
Products (27)
apple/mac_os_x 10.6.8 - 10.7.5
debian/debian_linux 6.0
fedoraproject/fedora 39
fedoraproject/fedora 40
hp/hp-ux b.11.23
hp/hp-ux b.11.31
opensuse/opensuse 11.4
opensuse/opensuse 12.1
php/php < 5.3.12
redhat/application_stack 2.0
... and 17 more
Published May 11, 2012
KEV Added Mar 25, 2022
Tracked Since Feb 18, 2026