Rapid7 Vulnerability & Exploit Database

PHP-FPM Underflow RCE

Back to Search

PHP-FPM Underflow RCE

Disclosed
10/22/2019
Created
03/05/2020

Description

This module exploits an underflow vulnerability in versions 7.1.x below 7.1.33, 7.2.x below 7.2.24 and 7.3.x below 7.3.11 of PHP-FPM on Nginx. Only servers with certains Nginx + PHP-FPM configurations are exploitable. This is a port of the original neex's exploit code (see refs.). First, it detects the correct parameters (Query String Length and custom header length) needed to trigger code execution. This step determines if the target is actually vulnerable (Check method). Then, the exploit sets a series of PHP INI directives to create a file locally on the target, which enables code execution through a query string parameter. This is used to execute normal payload stagers. Finally, this module does some cleanup by killing local PHP-FPM workers (those are spawned automatically once killed) and removing the created local file.

Author(s)

  • neex
  • cdelafuente-r7

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/multi/http/php_fpm_rce
msf exploit(php_fpm_rce) > show targets
    ...targets...
msf exploit(php_fpm_rce) > set TARGET < target-id >
msf exploit(php_fpm_rce) > show options
    ...show and set options...
msf exploit(php_fpm_rce) > 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

;