Rapid7 Vulnerability & Exploit Database

PHP CGI Argument Injection Remote Code Execution

Back to Search

PHP CGI Argument Injection Remote Code Execution

Disclosed
06/06/2024
Created
06/17/2024

Description

This module exploits a PHP CGI argument injection vulnerability affecting PHP in certain configurations on a Windows target. A vulnerable configuration is locale dependant (such as Chinese or Japanese), such that the Unicode best-fit conversion scheme will unexpectedly convert a soft hyphen (0xAD) into a dash (0x2D) character. Additionally a target web server must be configured to run PHP under CGI mode, or directly expose the PHP binary. This issue has been fixed in PHP 8.3.8 (for the 8.3.x branch), 8.2.20 (for the 8.2.x branch), and 8.1.29 (for the 8.1.x branch). PHP 8.0.x and below are end of life and have note received patches. XAMPP is vulnerable in a default configuration, and we can target the /php-cgi/php-cgi.exe endpoint. To target an explicit .php endpoint (e.g. /index.php), the server must be configured to run PHP scripts in CGI mode.

Author(s)

  • Orange Tsai
  • watchTowr
  • sfewer-r7

Platform

PHP,Windows

Architectures

php, cmd

Development

Module Options

To display the available options, load the module within the Metasploit console and run the commands 'show options' or 'show advanced':

msf > use exploit/windows/http/php_cgi_arg_injection_rce_cve_2024_4577
msf exploit(php_cgi_arg_injection_rce_cve_2024_4577) > show targets
    ...targets...
msf exploit(php_cgi_arg_injection_rce_cve_2024_4577) > set TARGET < target-id >
msf exploit(php_cgi_arg_injection_rce_cve_2024_4577) > show options
    ...show and set options...
msf exploit(php_cgi_arg_injection_rce_cve_2024_4577) > exploit

Time is precious, so I don’t want to do something manually that I can automate. Leveraging the Metasploit Framework when automating any task keeps us from having to re-create the wheel as we can use the existing libraries and focus our efforts where it matters.

– Jim O’Gorman | President, Offensive Security

;