Skip to content
RCE Write-up Advanced

An analysis and thought about recently PHP-FPM RCE (CVE-2019-11043)

PHP-FPM incorrectly handles PATH_INFO when parsing a URI with a newline, leading to a buffer underflow that allows writing a null byte before the PATH_INFO buffer. This can corrupt CGI environment variables and, with specific Nginx configurations, be leveraged to overwrite PHP_VALUE and achieve remote code execution.

blog.orange.tw

Published on blog.orange.tw

First of all, this is such a really interesting bug! From a small memory defect to code execution.

The author, on blog.orange.tw

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the fastcgi_split_path_info directive mishandles URIs containing newlines, causing env_path_info to become empty and leading to a buffer underflow when calculating path_info.

Impact

An attacker could achieve remote code execution, but only if the server uses a vulnerable Nginx configuration that supports PATH_INFO and lacks file existence checks.

What the attacker needed

Nginx with PATH_INFO support; PHP-FPM vulnerable version; No file existence check (try_files)

How it was found

  1. Send a request with a newline in the URI to trigger the buffer underflow.
  2. Craft the request so that the null-byte write corrupts the fcgi_data_seg->pos pointer.
  3. Use a specially named HTTP header (e.g., HTTP_EBUT) with the same hash as PHP_VALUE to prepare for overwriting.
  4. Trigger the vulnerability to overwrite the header name to PHP_VALUE, injecting PHP configuration.
  5. Use the injected PHP_VALUE to set directives that lead to code execution.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

PHP-FPM is a component that runs PHP scripts for web servers. A bug in how it processes certain web addresses (URLs) can cause it to write data in the wrong place in memory. An attacker could exploit this to change settings and run their own code on the server, but only if the server is configured in a specific, common but not default way.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.