PHP-FPM — 1 vulnerability check
noctis ships 1 vulnerability check for PHP-FPM, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
PHP-FPM env_path_info Underflow RCE
| CVE | CVE-2019-11043 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | rce — Remote code execution |
| Services | http, https |
| Detection | tcp_connect, script, match · highest QoD 70 |
| Feed | tests/vulnerabilities/php-fpm/CVE-2019-11043.yaml |
Detects nginx + PHP-FPM servers exposed to CVE-2019-11043. A control request for a non-existent /noctis-<token>.php/%0a must be answered by PHP-FPM itself (404 "File not found." + X-Powered-By), proving nginx forwards newline PATH_INFO URIs to FPM without a file-existence check; the exploit's trigger GET /index.php/%0a must then run PHP (200), with an affected PHP-FPM version (5.3.3-5.6, 7.0, 7.1 < 7.1.33, 7.2 < 7.2.24, 7.3 < 7.3.11). Non-intrusive: the exploitation itself (worker crash / persistent PHP_VALUE injection) is not run.
How noctis detects it
- Raw TCP (TLS on HTTPS), sent verbatim:
GET /noctis-{{oob_token}}.php/%0a HTTP/1.0 - Raw TCP (TLS on HTTPS), sent verbatim:
GET /index.php/%0a HTTP/1.0 - Parses / computes the next value with a Rhai script
- Checks
fpm.verdictfor^vulnerable$→ finding QoD 70: nginx forwards newline PATH_INFO URIs to PHP-FPM without a file-existence check (GET /noctis-<token>.php/%0a answered by FPM: 404 File not …
References:
- https://nvd.nist.gov/vuln/detail/CVE-2019-11043
- https://bugs.php.net/bug.php?id=78599
- https://github.com/neex/phuip-fpizdam
- https://www.php.net/ChangeLog-7.php#7.3.11
- https://www.cisa.gov/known-exploited-vulnerabilities-catalog
Feed source — tests/vulnerabilities/php-fpm/CVE-2019-11043.yaml
# PHP-FPM env_path_info Buffer Underflow RCE — CVE-2019-11043 ("phuip-fpizdam")
#
# In PHP-FPM < 7.1.33 / 7.2.x < 7.2.24 / 7.3.x < 7.3.11 (and the never-fixed EOL
# 5.x / 7.0 lines), init_request_info() in sapi/fpm/fpm/fpm_main.c computes
# path_info = env_path_info + pilen - slen
# without checking pilen > slen. Behind nginx with the common config
# fastcgi_split_path_info ^(.+?\.php)(/.*)$;
# fastcgi_param PATH_INFO $fastcgi_path_info;
# and no file-existence check (try_files / `if (!-f ...)`), a URI holding a
# newline (%0a) breaks the regex: PATH_INFO reaches PHP-FPM empty while
# cgi.fix_pathinfo still walks SCRIPT_FILENAME back to the real script. The
# pointer then underflows into the FastCGI variable buffer, and the public
# exploit (neex/phuip-fpizdam, Metasploit) uses it to overwrite PHP_VALUE and
# reach RCE. In CISA KEV, used by ransomware operators.
#
# Detection — authentic fingerprint, NOT an exploitation proof (deliberate):
# Every real exploitation of this bug is either a worker crash or a persistent
# change: phuip-fpizdam's detection phase hunts for the query-string length
# that makes a worker segfault (502), and its confirmation step injects
# PHP_VALUE `session.auto_start=1` — PHP_VALUE set over FastCGI stays in that
# FPM worker for every later request until php-fpm restarts (php bug #51983),
# so it silently reconfigures the target for real users. Neither is benign,
# so this feed stops at the preconditions the exploit needs, each checked
# with a raw request (tcp_connect, so the %0a is sent verbatim):
# 1. control — `GET /noctis-<token>.php/%0a` (a script that does not exist)
# is answered by PHP-FPM itself: 404 + X-Powered-By: PHP + FPM's own
# "File not found." / "No input file specified." body. Only a
# `location ~ \.php(/|$)` block that forwards newline PATH_INFO URIs to
# FPM without a file-existence check produces this — the exploitable
# config. A hardened config (try_files $fastcgi_script_name =404) gives
# nginx's own 404; the common front-controller config (WordPress /
# Laravel `try_files ... /index.php?$args` + `location ~ \.php$`) routes
# the newline URI to index.php (200 or an app 404 page); Apache mod_php /
# proxy_fcgi gives Apache's 404. None of them match.
# 2. reachability — `GET /index.php/%0a` (the exploit's trigger on a real
# script) is executed by PHP: 200 + X-Powered-By.
# 3. version — that X-Powered-By version is an affected PHP-FPM release.
# QoD 70 (the verdict still rests on a version string — see limits).
#
# Better than the Nuclei/OpenVAS-style checks it replaces: the Nuclei regex
# flags every 7.0–7.3 release (fixed ones included) and any front end, and its
# /index.php/%0a → 200 signal alone also fires on every front-controller site;
# a plain version check flags PHP that is not served through the vulnerable
# nginx path at all. This feed proves the unchecked nginx → FPM newline
# forwarding with a control probe, plus an exact affected version.
#
# Known limits: no finding when expose_php=Off hides the version, or when the
# site has no /index.php (the exploit works with any PHP script) (FN); distro
# packages that backport the fix while keeping an old version string (e.g.
# Debian 7.0.33-0+deb9u6, Ubuntu 7.0.33-0ubuntu0.16.04.x) are reported (FP) —
# confirm with the package version.
uid: 4a53f5f9-1508-4513-9947-fb845284cc17
name: "PHP-FPM env_path_info Underflow RCE (CVE-2019-11043)"
description: |
Detects nginx + PHP-FPM servers exposed to CVE-2019-11043. A control request
for a non-existent /noctis-<token>.php/%0a must be answered by PHP-FPM itself
(404 "File not found." + X-Powered-By), proving nginx forwards newline
PATH_INFO URIs to FPM without a file-existence check; the exploit's trigger
GET /index.php/%0a must then run PHP (200), with an affected PHP-FPM version
(5.3.3-5.6, 7.0, 7.1 < 7.1.33, 7.2 < 7.2.24, 7.3 < 7.3.11). Non-intrusive: the
exploitation itself (worker crash / persistent PHP_VALUE injection) is not run.
cves: [CVE-2019-11043]
cvss: 9.8
severity: critical
confidence_base: 0.25
category: rce
tags: [php, php-fpm, nginx, path-info, buffer-underflow, rce, cisa-kev, fingerprint]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2019-11043"
- "https://bugs.php.net/bug.php?id=78599"
- "https://github.com/neex/phuip-fpizdam"
- "https://www.php.net/ChangeLog-7.php#7.3.11"
- "https://www.cisa.gov/known-exploited-vulnerabilities-catalog"
steps:
# 1 — control: a non-existent script under a newline PATH_INFO.
- id: probe-control-missing-script
action: tcp_connect
port: "{{port}}"
timeout_secs: 10
send: "GET /noctis-{{oob_token}}.php/%0a HTTP/1.0\r\nHost: {{target_host}}\r\nUser-Agent: noctis\r\n\r\n"
store_as: ctl
# 2 — the exploit's trigger request on a real script.
- id: probe-newline-path-info
action: tcp_connect
port: "{{port}}"
timeout_secs: 10
send: "GET /index.php/%0a HTTP/1.0\r\nHost: {{target_host}}\r\nUser-Agent: noctis\r\n\r\n"
store_as: resp
# 3 — verdict: FPM's own 404 on the control, 200 from PHP on the trigger,
# affected X-Powered-By version.
- id: assess-php-fpm
action: script
store_as: fpm
code: |
let craw = if type_of(ctl.banner) == "string" { ctl.banner } else { "" };
let chead = eregmatch("^(?s)(.*?)\\r?\\n\\r?\\n(.*)$", craw);
let chdrs = if chead.len() > 2 { chead[1] } else { craw };
let cbody = if chead.len() > 2 { chead[2] } else { "" };
let fpm_forwards = ereg("^HTTP/[0-9.]+ 404", chdrs)
&& ereg("(?m)^X-Powered-By:[ \\t]*PHP/", chdrs, true)
&& ereg("^\\s*(File not found\\.|No input file specified\\.)\\s*$", cbody);
let raw = if type_of(resp.banner) == "string" { resp.banner } else { "" };
let head = eregmatch("^(?s)(.*?)\\r?\\n\\r?\\n", raw);
let hdrs = if head.len() > 1 { head[1] } else { raw };
let ok_status = ereg("^HTTP/[0-9.]+ 200", hdrs);
let v = eregmatch("(?m)^X-Powered-By:[ \\t]*PHP/([0-9]+)\\.([0-9]+)\\.([0-9]+)", hdrs, true);
let srv = eregmatch("(?m)^Server:[ \\t]*([^\\r\\n]*)", hdrs, true);
let server = if srv.len() > 1 { srv[1] } else { "" };
let version = "";
let affected = false;
if v.len() > 3 {
version = v[1] + "." + v[2] + "." + v[3];
let maj = int(v[1]);
let min = int(v[2]);
let pat = int(v[3]);
// FPM is bundled since 5.3.3
affected = (maj == 5 && (min > 3 || (min == 3 && pat >= 3)))
|| (maj == 7 && min == 0)
|| (maj == 7 && min == 1 && pat < 33)
|| (maj == 7 && min == 2 && pat < 24)
|| (maj == 7 && min == 3 && pat < 11);
}
let verdict = if fpm_forwards && ok_status && affected { "vulnerable" } else { "clean" };
#{ verdict: verdict, version: version, server: server }
- id: match-vulnerable
action: match
source: fpm.verdict
pattern: "^vulnerable$"
on_match:
finding:
confidence_delta: 0.40
qod: 70
evidence: "nginx forwards newline PATH_INFO URIs to PHP-FPM without a file-existence check (GET /noctis-<token>.php/%0a answered by FPM: 404 File not found. + X-Powered-By) and GET /index.php/%0a runs PHP (200, X-Powered-By: PHP/{{fpm.version}}, Server: {{fpm.server}}); PHP {{fpm.version}} predates the CVE-2019-11043 fix (7.1.33 / 7.2.24 / 7.3.11). Exploitation (worker crash / persistent PHP_VALUE injection) intentionally not attempted."
stop: true