# CVE-2019-11043: a buffer underflow in fpm_main.c can lead to RCE in php-fpm

Empty PATH_INFO FastCGI var underflows a pointer in fpm_main.c, giving a one-byte OOB write that escalates to RCE via Nginx regex bypass with %0a.

- Payout: $1,500
- Severity: critical
- Program: Internet Bug Bounty
- Found by (vendor credit): Emil Lerner
- Found by: neex
- Disclosed: 2020-11-09
- CVE: CVE-2019-11043
- Write-up quality: 8/10
- Original: https://hackerone.com/reports/722327
- Library page: https://bugbountylibrary.com/r/h1%3A722327
- Tags: area:oss domain:oss impact:rce kind:bounty platform:hackerone sev:critical tech:nginx tech:php technique:chained technique:source-review vuln:memory-corruption vuln:rce

**Target:** php-fpm (fpm_main.c) behind Nginx fastcgi_split_pathinfo
**Root cause:** Missing bounds check in fpm_main.c when PATH_INFO is empty causes pointer underflow in path_info calculation, leading to a single-byte out-of-bounds write.
**Steps:**
1. Configure Nginx with fastcgi_split_pathinfo regex that can be broken by an encoded newline `%0a` in the URL.
2. Send a request with `%0a` such that the regex fails and Nginx forwards an empty `PATH_INFO` FastCGI variable to php-fpm.
3. Trigger the underflow in fpm_main.c producing a one-byte OOB write at an attacker-influenced offset.
4. Use the phuip-fpizdam exploit to repeatedly hit the endpoint and corrupt PHP memory to achieve code execution.
**How found:** Researcher noticed missing bounds check in fpm_main.c when PATH_INFO is empty, then reasoned that Nginx's fastcgi_split_pathinfo regex could be broken with an encoded newline `%0a` to force an empty PATH_INFO from an HTTP-only attacker.
**Exploitation:** Attacker only needs HTTP access to Nginx; by crafting URLs with `%0a` to break the split_pathinfo regex, Nginx sends empty PATH_INFO to php-fpm, triggering the underflow. The phuip-fpizdam tool repeatedly requests the endpoint to turn the single-byte OOB write into controlled memory corruption and ultimately RCE with php-fpm privileges.
**Escalation:** Single-byte OOB write is amplified via repeated requests (phuip-fpizdam) into full code execution, bypassing the need for direct FastCGI socket access.
**Insight:** When a bug needs an unusual upstream variable value, look at how front-end proxies (Nginx regex directives) can be tricked into producing that value from ordinary HTTP input, e.g. encoded newlines breaking split_pathinfo.

## Write-ups of the same bug (oldest first)
- 2020-03-14: [Docker image with FPM is vulnerable to CVE-2019-11043](https://bugbountylibrary.com/r/h1%3A720306) — beched
- 2020-11-09: [CVE-2019-11043: a buffer underflow in fpm_main.c can lead to RCE in php-fpm](https://bugbountylibrary.com/r/h1%3A722327) — neex (this one)

