Remote Code Execution - CVE-2012-1823

ID

remote_code_execution_cve_2012_1823

Severity

critical

Kind

Remote Code Execution

CWE

20

Description

Some PHP versions, when configured to run using CGI, do not correctly handle query strings that lack an unescaped "=" character, enabling arbitrary code execution. In this case, an operating system command was caused to be executed on the web server, and the results were returned to the web browser.

Rationale

This vulnerability in PHP CGI configurations allows attackers to pass command-line arguments to the PHP interpreter through malformed query strings. By injecting arguments like -d allow_url_include=1 or -s, attackers can modify PHP configuration at runtime, expose source code, or execute arbitrary PHP code. Complete server compromise is possible by chaining this with other PHP features to execute operating system commands, read sensitive files, or establish persistent backdoors.

Remediation

Upgrade to the latest stable version of PHP, or use the Apache web server and the mod_rewrite module to filter out malicious requests using the "RewriteCond" and "RewriteRule" directives.