NGINX Rift: 18-Year-Old Heap Overflow Enables RCE on Web Servers
CVE-2026-42945 is a critical heap buffer overflow in NGINX's rewrite module that went undetected since 2008. CVSS 9.2 with public PoC available—patch now.
A critical heap buffer overflow in NGINX sat undetected for 18 years, affecting every version of the world's most widely deployed web server since 0.6.27. Security researchers at depthfirst disclosed CVE-2026-42945—dubbed NGINX Rift—on May 14, 2026, with a CVSS v4 score of 9.2.
The vulnerability allows unauthenticated remote attackers to crash NGINX worker processes or, on systems without ASLR, achieve full remote code execution through a single crafted HTTP request. A proof-of-concept is now public on GitHub.
Technical Breakdown
The flaw lives in ngx_http_rewrite_module and triggers under specific configuration patterns. When a rewrite directive uses unnamed PCRE capture groups ($1, $2 syntax) with a question mark in the replacement string, followed by another rewrite, if, or set directive in the same scope, NGINX miscalculates buffer sizes.
The root cause: NGINX computes the destination buffer using one set of escaping assumptions but writes to it using another. Characters like +, %, and & each expand by two bytes during URI escaping. The bytes written past the allocation derive from the attacker's URI, making the corruption attacker-controlled rather than random.
A vulnerable configuration looks like this:
location /redirect {
rewrite ^/redirect/([0-9]+)$ /page?id=$1 last;
if ($arg_debug) {
# Second directive in same scope triggers the bug
set $debug_mode 1;
}
}
Exploitation Paths
Denial of Service: Trivial and reliable. One TCP connection, two packets, no authentication, no special headers—the targeted worker crashes immediately. NGINX respawns workers, but an attacker can sustain pressure to degrade service availability.
Remote Code Execution: More complex but achievable on systems using the Apache Portable Runtime with mmap allocator (default on Debian and official Docker images). Researchers demonstrated placing fake h2_stream structures at freed memory addresses, redirecting pool cleanup functions to system(). The depthfirst research includes a working PoC for controlled environments.
Massive Attack Surface
The vulnerability affects:
- NGINX Open Source: Versions 0.6.27 through 1.30.0
- NGINX Plus: R32 through R36
- NGINX Instance Manager: 2.16.0 through 2.21.1
- F5 WAF for NGINX: 5.9.0 through 5.12.1
- NGINX App Protect WAF: 4.9.0 through 4.16.0 and 5.1.0 through 5.8.0
- NGINX Gateway Fabric and Ingress Controller: Multiple versions
According to W3Techs data, NGINX powers roughly 34% of all websites globally. Organizations running older configurations accumulated over years of incremental changes face the highest exposure.
Mitigation Without Downtime
If immediate patching isn't possible, convert unnamed captures to named captures in your rewrite rules. This eliminates the vulnerable code path without requiring restarts:
# Before (vulnerable):
rewrite ^/users/([0-9]+)$ /profile.php?id=$1 last;
# After (safe):
rewrite ^/users/(?<user_id>[0-9]+)$ /profile.php?id=$user_id last;
This workaround was validated by the researchers and F5's security team.
Patch Information
- NGINX Open Source: Upgrade to 1.30.1 or 1.31.0
- NGINX Plus R36: Apply R36 P4
- NGINX Plus R32: Apply R32 P6
Three companion CVEs were disclosed alongside NGINX Rift:
- CVE-2026-42946 (CVSS 8.3): Memory allocation flaw in scgi/uwsgi modules
- CVE-2026-40701 (CVSS 6.3): Use-after-free in SSL module
- CVE-2026-42934 (CVSS 6.3): Out-of-bounds read in charset module
Why This Matters
An 18-year-old bug in foundational internet infrastructure is a sobering reminder that time doesn't equal security. The rewrite module is heavily used for URL routing, redirects, and access control—configurations that often accumulate complexity without regular audit.
This disclosure follows a pattern of critical web server vulnerabilities this month. Security teams should prioritize reviewing externally-facing NGINX configurations, especially those migrated from older deployments. For those unfamiliar with web server hardening, our online safety tips guide covers foundational security practices.
Related Articles
Exim 'Dead.Letter' Flaw Enables Unauthenticated RCE on Mail Servers
CVE-2026-45185 is a critical use-after-free vulnerability in Exim mail servers using GnuTLS. XBOW researchers call it one of the highest-caliber bugs found in Exim.
May 13, 2026Microsoft Fixes 120 Flaws in May Patch Tuesday, 17 Critical
Microsoft's May 2026 Patch Tuesday addresses 120 vulnerabilities including 17 critical RCE flaws. No zero-days, but Word preview pane attacks and Netlogon bugs demand immediate attention.
May 13, 2026Fortinet Patches Critical RCE in FortiSandbox, FortiAuthenticator
Fortinet discloses CVE-2026-44277 and CVE-2026-26083, unauthenticated RCE flaws affecting FortiSandbox and FortiAuthenticator. Patch now before attackers weaponize these.
May 12, 2026Cline AI Agent Flaw Let Any Website Execute Code on Developer Machines
CVE-2026-44211 (CVSS 9.7) allowed malicious websites to hijack Cline's Kanban WebSocket server, exfiltrate workspace data, and execute arbitrary commands through the AI agent. Patched in v0.1.66.
May 12, 2026