Vulnerabilities > CVE-2012-2311 - SQL Injection vulnerability in PHP
Attack vector
UNKNOWN Attack complexity
UNKNOWN Privileges required
UNKNOWN Confidentiality impact
UNKNOWN Integrity impact
UNKNOWN Availability impact
UNKNOWN Summary
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.
Vulnerable Configurations
Common Weakness Enumeration (CWE)
Common Attack Pattern Enumeration and Classification (CAPEC)
- Command Line Execution through SQL Injection An attacker uses standard SQL injection methods to inject data into the command line for execution. This could be done directly through misuse of directives such as MSSQL_xp_cmdshell or indirectly through injection of data into the database that would be interpreted as shell commands. Sometime later, an unscrupulous backend application (or could be part of the functionality of the same application) fetches the injected data stored in the database and uses this data as command line arguments without performing proper validation. The malicious data escapes that data plane by spawning new commands to be executed on the host.
- Object Relational Mapping Injection An attacker leverages a weakness present in the database access layer code generated with an Object Relational Mapping (ORM) tool or a weakness in the way that a developer used a persistence framework to inject his or her own SQL commands to be executed against the underlying database. The attack here is similar to plain SQL injection, except that the application does not use JDBC to directly talk to the database, but instead it uses a data access layer generated by an ORM tool or framework (e.g. Hibernate). While most of the time code generated by an ORM tool contains safe access methods that are immune to SQL injection, sometimes either due to some weakness in the generated code or due to the fact that the developer failed to use the generated access methods properly, SQL injection is still possible.
- SQL Injection through SOAP Parameter Tampering An attacker modifies the parameters of the SOAP message that is sent from the service consumer to the service provider to initiate a SQL injection attack. On the service provider side, the SOAP message is parsed and parameters are not properly validated before being used to access a database in a way that does not use parameter binding, thus enabling the attacker to control the structure of the executed SQL query. This pattern describes a SQL injection attack with the delivery mechanism being a SOAP message.
- Expanding Control over the Operating System from the Database An attacker is able to leverage access gained to the database to read / write data to the file system, compromise the operating system, create a tunnel for accessing the host machine, and use this access to potentially attack other machines on the same network as the database machine. Traditionally SQL injections attacks are viewed as a way to gain unauthorized read access to the data stored in the database, modify the data in the database, delete the data, etc. However, almost every data base management system (DBMS) system includes facilities that if compromised allow an attacker complete access to the file system, operating system, and full access to the host running the database. The attacker can then use this privileged access to launch subsequent attacks. These facilities include dropping into a command shell, creating user defined functions that can call system level libraries present on the host machine, stored procedures, etc.
- SQL Injection This attack exploits target software that constructs SQL statements based on user input. An attacker crafts input strings so that when the target software constructs SQL statements based on the input, the resulting SQL statement performs actions other than those the application intended. SQL Injection results from failure of the application to appropriately validate input. When specially crafted user-controlled input consisting of SQL syntax is used without proper validation as part of SQL queries, it is possible to glean information from the database in ways not envisaged during application design. Depending upon the database and the design of the application, it may also be possible to leverage injection to have the database execute system-related commands of the attackers' choice. SQL Injection enables an attacker to talk directly to the database, thus bypassing the application completely. Successful injection can cause information disclosure as well as ability to add or modify data in the database. In order to successfully inject SQL and retrieve information from a database, an attacker:
Exploit-Db
description Apache / PHP 5.x - cgi-bin Remote Code Execution Exploit. CVE-2012-1823,CVE-2012-2311,CVE-2012-2336. Remote exploit for linux platform id EDB-ID:29290 last seen 2016-02-03 modified 2013-10-29 published 2013-10-29 reporter kingcope source https://www.exploit-db.com/download/29290/ title Apache / PHP 5.x - cgi-bin Remote Code Execution Exploit description Apache + PHP 5.x - Remote Code Execution (Multithreaded Scanner) (2). CVE-2012-1823,CVE-2012-2311,CVE-2012-2336. Remote exploit for php platform id EDB-ID:29316 last seen 2016-02-03 modified 2013-10-31 published 2013-10-31 reporter noptrix source https://www.exploit-db.com/download/29316/ title Apache + PHP 5.x - Remote Code Execution Multithreaded Scanner 2 description PHP CGI Argument Injection Exploit. CVE-2012-1823,CVE-2012-2311,CVE-2012-2336. Remote exploit for php platform id EDB-ID:18836 last seen 2016-02-02 modified 2012-05-05 published 2012-05-05 reporter rayh4c source https://www.exploit-db.com/download/18836/ title PHP CGI Argument Injection Exploit description PHP CGI Argument Injection. CVE-2012-1823,CVE-2012-2311,CVE-2012-2336. Remote exploit for php platform id EDB-ID:18834 last seen 2016-02-02 modified 2012-05-04 published 2012-05-04 reporter metasploit source https://www.exploit-db.com/download/18834/ title PHP CGI Argument Injection description Apache + PHP < 5.3.12 / < 5.4.2 - Remote Code Execution (Multithreaded Scanner) (2). CVE-2012-1823,CVE-2012-2311,CVE-2012-2336. Remote exploit for PHP ... id EDB-ID:40233 last seen 2016-08-13 modified 2013-11-01 published 2013-11-01 reporter noptrix title Apache + PHP < 5.3.12 / < 5.4.2 - Remote Code Execution (Multithreaded Scanner) (2)
Nessus
NASL family SuSE Local Security Checks NASL id SUSE_APACHE2-MOD_PHP5-8114.NASL description This update fixes several security issues in PHP5 : - A directory traversal bug has been fixed in php5. (CVE-2012-1172) - A command injection was possible when PHP5 was operated in CGI mode using commandline options. This problem does not affect PHP5 in the normal Apache module mode setup. (CVE-2012-1823 / CVE-2012-2311) - Also a pack/unpacking bug on big endian 64bit architectures (ppc64 and s390x) has been fixed. bnc#753778 last seen 2020-06-05 modified 2012-05-09 plugin id 59053 published 2012-05-09 reporter This script is Copyright (C) 2012-2020 and is owned by Tenable, Inc. or an Affiliate thereof. source https://www.tenable.com/plugins/nessus/59053 title SuSE 10 Security Update : PHP5 (ZYPP Patch Number 8114) NASL family CGI abuses NASL id PHP_CGI_QUERY_STRING_CODE_EXECUTION.NASL description The PHP installation on the remote web server contains a flaw that could allow a remote attacker to pass command-line arguments as part of a query string to the PHP-CGI program. This could be abused to execute arbitrary code, reveal PHP source code, cause a system crash, etc. last seen 2020-06-01 modified 2020-06-02 plugin id 59088 published 2012-05-14 reporter This script is Copyright (C) 2012-2018 and is owned by Tenable, Inc. or an Affiliate thereof. source https://www.tenable.com/plugins/nessus/59088 title PHP PHP-CGI Query String Parameter Injection Arbitrary Code Execution NASL family Fedora Local Security Checks NASL id FEDORA_2012-7567.NASL description The releases complete a fix for a vulnerability in CGI-based setups (CVE-2012-2311). Note that Tenable Network Security has extracted the preceding description block directly from the Fedora security advisory. Tenable has attempted to automatically clean and format it as much as possible without introducing additional issues. last seen 2020-03-17 modified 2012-05-29 plugin id 59265 published 2012-05-29 reporter This script is Copyright (C) 2012-2020 and is owned by Tenable, Inc. or an Affiliate thereof. source https://www.tenable.com/plugins/nessus/59265 title Fedora 15 : maniadrive-1.2-32.fc15.5 / php-5.3.13-1.fc15 / php-eaccelerator-0.9.6.1-9.fc15.5 (2012-7567) NASL family SuSE Local Security Checks NASL id OPENSUSE-2012-261.NASL description when used in CGI mode remote attackers could inject command line arguments to php last seen 2020-06-05 modified 2014-06-13 plugin id 74616 published 2014-06-13 reporter This script is Copyright (C) 2014-2020 and is owned by Tenable, Inc. or an Affiliate thereof. source https://www.tenable.com/plugins/nessus/74616 title openSUSE Security Update : php5 (openSUSE-SU-2012:0590-1) NASL family SuSE Local Security Checks NASL id SUSE_11_APACHE2-MOD_PHP53-120504.NASL description This update fixes several security issues in PHP5 : - A directory traversal bug has been fixed in PHP5. (CVE-2012-1172) - A command injection was possible when PHP5 was operated in CGI mode using commandline options. This problem does not affect PHP5 in the normal Apache module mode setup. (CVE-2012-1823 / CVE-2012-2311) last seen 2020-06-05 modified 2013-01-25 plugin id 64103 published 2013-01-25 reporter This script is Copyright (C) 2013-2020 and is owned by Tenable, Inc. or an Affiliate thereof. source https://www.tenable.com/plugins/nessus/64103 title SuSE 11.2 Security Update : PHP5 (SAT Patch Number 6251) NASL family Fedora Local Security Checks NASL id FEDORA_2012-7628.NASL description The releases complete a fix for a vulnerability in CGI-based setups (CVE-2012-2311). PHP 5.4.3 fixes a buffer overflow vulnerability in the apache_request_headers() (CVE-2012-2329). Note that Tenable Network Security has extracted the preceding description block directly from the Fedora security advisory. Tenable has attempted to automatically clean and format it as much as possible without introducing additional issues. last seen 2020-03-17 modified 2012-05-29 plugin id 59268 published 2012-05-29 reporter This script is Copyright (C) 2012-2020 and is owned by Tenable, Inc. or an Affiliate thereof. source https://www.tenable.com/plugins/nessus/59268 title Fedora 17 : maniadrive-1.2-40.fc17 / php-5.4.3-1.fc17 (2012-7628) NASL family Gentoo Local Security Checks NASL id GENTOO_GLSA-201209-03.NASL description The remote host is affected by the vulnerability described in GLSA-201209-03 (PHP: Multiple vulnerabilities) Multiple vulnerabilities have been discovered in PHP. Please review the CVE identifiers referenced below for details. Impact : A remote attacker could execute arbitrary code with the privileges of the process, cause a Denial of Service condition, obtain sensitive information, create arbitrary files, conduct directory traversal attacks, bypass protection mechanisms, or perform further attacks with unspecified impact. Workaround : There is no known workaround at this time. last seen 2020-06-01 modified 2020-06-02 plugin id 62236 published 2012-09-24 reporter This script is Copyright (C) 2012-2018 and is owned by Tenable, Inc. or an Affiliate thereof. source https://www.tenable.com/plugins/nessus/62236 title GLSA-201209-03 : PHP: Multiple vulnerabilities NASL family MacOS X Local Security Checks NASL id MACOSX_10_8_2.NASL description The remote host is running a version of Mac OS X 10.8.x that is prior to 10.8.2. The newer version contains multiple security-related fixes for the following components : - BIND - Data Security - LoginWindow - Mobile Accounts - PHP last seen 2020-06-01 modified 2020-06-02 plugin id 62215 published 2012-09-20 reporter This script is Copyright (C) 2012-2018 Tenable Network Security, Inc. source https://www.tenable.com/plugins/nessus/62215 title Mac OS X 10.8.x < 10.8.2 Multiple Vulnerabilities NASL family MacOS X Local Security Checks NASL id MACOSX_SECUPD2012-004.NASL description The remote host is running a version of Mac OS X 10.6 that does not have Security Update 2012-004 applied. This update contains multiple security-related fixes for the following components : - Apache - Data Security - DirectoryService - ImageIO - International Components for Unicode - Mail - PHP - QuickLook - QuickTime - Ruby last seen 2020-06-01 modified 2020-06-02 plugin id 62213 published 2012-09-20 reporter This script is Copyright (C) 2012-2018 Tenable Network Security, Inc. source https://www.tenable.com/plugins/nessus/62213 title Mac OS X Multiple Vulnerabilities (Security Update 2012-004) (BEAST) NASL family Web Servers NASL id HPSMH_7_2_1_0.NASL description According to the web server last seen 2020-06-01 modified 2020-06-02 plugin id 69020 published 2013-07-23 reporter This script is Copyright (C) 2013-2019 and is owned by Tenable, Inc. or an Affiliate thereof. source https://www.tenable.com/plugins/nessus/69020 title HP System Management Homepage < 7.2.1.0 Multiple Vulnerabilities (BEAST) NASL family Fedora Local Security Checks NASL id FEDORA_2012-7586.NASL description The releases complete a fix for a vulnerability in CGI-based setups (CVE-2012-2311). Note that Tenable Network Security has extracted the preceding description block directly from the Fedora security advisory. Tenable has attempted to automatically clean and format it as much as possible without introducing additional issues. last seen 2020-03-17 modified 2012-05-29 plugin id 59266 published 2012-05-29 reporter This script is Copyright (C) 2012-2020 and is owned by Tenable, Inc. or an Affiliate thereof. source https://www.tenable.com/plugins/nessus/59266 title Fedora 16 : maniadrive-1.2-32.fc16.5 / php-5.3.13-1.fc16 / php-eaccelerator-0.9.6.1-9.fc16.5 (2012-7586) NASL family FreeBSD Local Security Checks NASL id FREEBSD_PKG_59B68B1E9C7811E1B5E0000C299B62E1.NASL description The PHP Development Team reports : The release of PHP 5.4.13 and 5.4.3 complete a fix for the vulnerability in CGI-based setups as originally described in CVE-2012-1823. (CVE-2012-2311) Note: mod_php and php-fpm are not vulnerable to this attack. PHP 5.4.3 fixes a buffer overflow vulnerability in the apache_request_headers() (CVE-2012-2329). last seen 2020-06-01 modified 2020-06-02 plugin id 59084 published 2012-05-14 reporter This script is Copyright (C) 2012-2019 and is owned by Tenable, Inc. or an Affiliate thereof. source https://www.tenable.com/plugins/nessus/59084 title FreeBSD : php -- multiple vulnerabilities (59b68b1e-9c78-11e1-b5e0-000c299b62e1) NASL family CGI abuses NASL id PHP_5_4_3.NASL description According to its banner, the version of PHP installed on the remote host is 5.4.x earlier than 5.4.3. It is, therefore, potentially affected the following vulnerabilities : - The fix for CVE-2012-1823 does not completely correct the CGI query parameter vulnerability. Disclosure of PHP source code and code execution are still possible. Note that this vulnerability is exploitable only when PHP is used in CGI-based configurations. Apache with last seen 2020-06-01 modified 2020-06-02 plugin id 59057 published 2012-05-09 reporter This script is Copyright (C) 2012-2018 Tenable Network Security, Inc. source https://www.tenable.com/plugins/nessus/59057 title PHP 5.4.x < 5.4.3 Multiple Vulnerabilities NASL family Debian Local Security Checks NASL id DEBIAN_DSA-2465.NASL description De Eindbazen discovered that PHP, when run with mod_cgi, will interpret a query string as command line parameters, allowing to execute arbitrary code. Additionally, this update fixes insufficient validation of upload name which lead to corrupted $_FILES indices. last seen 2020-03-17 modified 2012-05-10 plugin id 59059 published 2012-05-10 reporter This script is Copyright (C) 2012-2020 and is owned by Tenable, Inc. or an Affiliate thereof. source https://www.tenable.com/plugins/nessus/59059 title Debian DSA-2465-1 : php5 - several vulnerabilities NASL family CGI abuses NASL id PHP_CGI_REMOTE_CODE_EXECUTION.NASL description The PHP installation on the remote web server contains a flaw that could allow a remote attacker to pass command-line arguments as part of a query string to the PHP-CGI program. This could be abused to execute arbitrary code, reveal PHP source code, cause a system crash, etc. last seen 2020-06-01 modified 2020-06-02 plugin id 70728 published 2013-11-01 reporter This script is Copyright (C) 2013-2019 and is owned by Tenable, Inc. or an Affiliate thereof. source https://www.tenable.com/plugins/nessus/70728 title Apache PHP-CGI Remote Code Execution NASL family SuSE Local Security Checks NASL id SUSE_11_APACHE2-MOD_PHP5-120504.NASL description This update fixes several security issues in PHP5 : - A directory traversal bug has been fixed in PHP5. (CVE-2012-1172) - A command injection was possible when PHP5 was operated in CGI mode using commandline options. This problem does not affect PHP5 in the normal apache module mode setup. (CVE-2012-1823 / CVE-2012-2311) - Also a pack/unpacking bug on big endian 64bit architectures (ppc64 and s390x) has been fixed. (bnc#753778) last seen 2020-06-05 modified 2013-01-25 plugin id 64099 published 2013-01-25 reporter This script is Copyright (C) 2013-2020 and is owned by Tenable, Inc. or an Affiliate thereof. source https://www.tenable.com/plugins/nessus/64099 title SuSE 11.1 Security Update : PHP5 (SAT Patch Number 6252) NASL family Ubuntu Local Security Checks NASL id UBUNTU_USN-1437-1.NASL description It was discovered that PHP, when used as a stand alone CGI processor for the Apache Web Server, did not properly parse and filter query strings. This could allow a remote attacker to execute arbitrary code running with the privilege of the web server. Configurations using mod_php5 and FastCGI were not vulnerable. This update addresses the issue when the PHP CGI interpreter is configured using mod_cgi and mod_actions as described in /usr/share/doc/php5-cgi/README.Debian.gz; however, if an alternate configuration is used to enable PHP CGI processing, it should be reviewed to ensure that command line arguments cannot be passed to the PHP interpreter. Please see CVE-2012-2311 for more details and potential mitigation approaches. Note that Tenable Network Security has extracted the preceding description block directly from the Ubuntu security advisory. Tenable has attempted to automatically clean and format it as much as possible without introducing additional issues. last seen 2020-06-01 modified 2020-06-02 plugin id 59016 published 2012-05-07 reporter Ubuntu Security Notice (C) 2012-2019 Canonical, Inc. / NASL script (C) 2012-2019 and is owned by Tenable, Inc. or an Affiliate thereof. source https://www.tenable.com/plugins/nessus/59016 title Ubuntu 8.04 LTS / 10.04 LTS / 11.04 / 11.10 / 12.04 LTS : php5 vulnerability (USN-1437-1) NASL family CGI abuses NASL id PHP_5_3_13.NASL description According to its banner, the version of PHP installed on the remote host is 5.3.x earlier than 5.3.13 and, as such, is potentially affected by a remote code execution and information disclosure vulnerability. The fix for CVE-2012-1823 does not completely correct the CGI query vulnerability. Disclosure of PHP source code and code execution via query parameters are still possible. Note that this vulnerability is exploitable only when PHP is used in CGI-based configurations. Apache with last seen 2020-06-01 modified 2020-06-02 plugin id 59056 published 2012-05-09 reporter This script is Copyright (C) 2012-2018 Tenable Network Security, Inc. source https://www.tenable.com/plugins/nessus/59056 title PHP 5.3.x < 5.3.13 CGI Query String Code Execution NASL family MacOS X Local Security Checks NASL id MACOSX_10_7_5.NASL description The remote host is running a version of Mac OS X 10.7.x that is prior to 10.7.5. The newer version contains multiple security-related fixes for the following components : - Apache - BIND - CoreText - Data Security - ImageIO - Installer - International Components for Unicode - Kernel - Mail - PHP - Profile Manager - QuickLook - QuickTime - Ruby - USB last seen 2020-06-01 modified 2020-06-02 plugin id 62214 published 2012-09-20 reporter This script is Copyright (C) 2012-2018 Tenable Network Security, Inc. source https://www.tenable.com/plugins/nessus/62214 title Mac OS X 10.7.x < 10.7.5 Multiple Vulnerabilities (BEAST)
References
- https://bugs.php.net/bug.php?id=61910
- http://www.kb.cert.org/vuls/id/520827
- http://www.php.net/ChangeLog-5.php#5.4.3
- https://bugs.php.net/patch-display.php?bug_id=61910&patch=cgi.diff-fix-check.patch&revision=1336093719&display=1
- http://eindbazen.net/2012/05/php-cgi-advisory-cve-2012-1823/
- http://www.php.net/archive/2012.php#id2012-05-08-1
- http://secunia.com/advisories/49014
- http://marc.info/?l=bugtraq&m=134012830914727&w=2
- http://lists.apple.com/archives/security-announce/2012/Sep/msg00004.html
- http://support.apple.com/kb/HT5501
- http://www.securitytracker.com/id?1027022
- http://secunia.com/advisories/49085
- https://h20564.www2.hp.com/portal/site/hpsc/public/kb/docDisplay?docId=emr_na-c03839862
- http://lists.opensuse.org/opensuse-security-announce/2012-05/msg00002.html
- http://www.debian.org/security/2012/dsa-2465
- http://lists.opensuse.org/opensuse-security-announce/2012-05/msg00011.html
- http://lists.opensuse.org/opensuse-security-announce/2012-05/msg00007.html