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
nginx-poolslip: New Zero-Day Bypasses ASLR for RCE, No Patch
Security researchers disclose nginx-poolslip, an unpatched zero-day in NGINX 1.31.0 that defeats ASLR protection. Millions of servers at risk with no CVE or fix available yet.
May 21, 2026Langflow Flaw Lets Anyone Execute Code on AI Workflow Servers
CVE-2026-10134 enables unauthenticated RCE in Langflow OSS through public flows. Attackers can run arbitrary Python on servers via the build endpoint.
Jul 7, 2026JetBrains Patches Critical Flaws Enabling IDE and Hub Takeover
JetBrains fixes CVSS 9.8 account takeover bug in Hub and multiple RCE vulnerabilities across IntelliJ, GoLand, and other IDEs. Update immediately.
Jul 7, 2026libssh2 Pre-Auth RCE (CVE-2026-55200) PoC Now Public
A critical memory corruption flaw in libssh2 lets malicious SSH servers execute code on connecting clients—no credentials needed. PoC dropped June 29.
Jun 30, 2026