Published 2026-09-30 · Updated 2026-09-30
NGINX Rift, CVE-2026-42945: An 18-Year-Old Bug in the Rewrite Module
A bug that sat unnoticed in nginx's rewrite module for roughly 18 years turned out to be a critical, unauthenticated, remotely triggerable heap buffer overflow. CVE-2026-42945, nicknamed NGINX Rift, is rated CVSS 4.0 9.2 and CVSS 3.1 8.1, and affects every version of nginx Open Source from 0.6.27 through 1.30.0, plus nginx Plus R32 through R36. Proof-of-concept exploit code is already public, and security researchers have reported exploitation attempts following the patch release. This is a useful case in exactly how narrow a trigger condition a critical vulnerability can have, and why patch speed matters even for a bug that requires a very specific configuration pattern to reach.
In this article
What NGINX Rift actually is What triggers the overflow Why an 18-year-old bug surfaced now Who is affected How to check your configuration How to fix it The broader lesson Frequently asked questionsQuick win (5 minutes)
- Check your nginx version:
nginx -v. Anything from 0.6.27 through 1.30.0, or Plus R32 through R36, is potentially affected. - Search your configs for the trigger pattern:
grep -rn "rewrite.*\$[0-9].*?" /etc/nginx/, then check whether the matched location also has a following rewrite, if, or set directive. - If your version is affected, treat this as a patch-now priority rather than routine maintenance, the same way you would treat any entry on CISA's KEV catalog.
- After upgrading, confirm the new version actually took effect:
nginx -vagain, andsystemctl status nginxto confirm it restarted cleanly.
What NGINX Rift actually is
CVE-2026-42945 is a heap-based buffer overflow (CWE-122) in the ngx_http_rewrite_module, the part of nginx responsible for URL rewriting and redirection logic. According to F5's own advisory, an unauthenticated attacker can send a specially crafted request that triggers a mismatch between how nginx calculates the size of a destination buffer and how it actually writes data into it, overflowing the buffer on the heap. At minimum this crashes the affected nginx worker process, which nginx then restarts, causing a denial-of-service condition. On a system where address space layout randomization is disabled, or where an attacker has a way to defeat it, the same overflow can be leveraged for remote code execution.
What triggers the overflow
The vulnerable pattern is specific: a rewrite directive that uses an unnamed PCRE capture group, such as $1 or $2, in a replacement string that contains a question mark, followed in the same location block by another rewrite, if, or set directive. When that sequence occurs, nginx computes the size needed for the destination buffer using one escaping method, but writes the actual output using a different escaping method, and the two disagree about how much space is required. That mismatch is what overflows the buffer. It is a narrow, specific pattern, not a flaw in URL rewriting generally, which is exactly why it went unnoticed through 18 years of otherwise heavy real-world use of the rewrite module.
Why an 18-year-old bug surfaced now
Bugs like this are typically found through fuzzing or targeted code auditing of widely deployed software, not through normal usage, since the trigger condition depends on a configuration detail that most administrators would never think to test deliberately. Once F5 and the nginx project disclosed the flaw and shipped a fix, proof-of-concept exploit code followed quickly, and multiple sources reported exploitation attempts shortly after. This is the same pattern our patch management guide covers in depth: the moment a fix is public, so is enough information for attackers to build a working exploit, and the clock on how long an unpatched server stays safe starts running immediately.
Who is affected
Every release of nginx Open Source from 0.6.27 through 1.30.0 is affected, along with nginx Plus releases R32 through R36. Given how far back 0.6.27 dates, this covers effectively every nginx deployment that has not been kept current, not a narrow recent release window. According to AlmaLinux's advisory, most major Linux distributions moved quickly to backport the fix into their maintained nginx packages once it was available upstream.
Not sure what your nginx configuration actually does?
A free, read-only server check reviews nginx version, configuration and exposed services without making any changes.
Get your free server check Talk to a security engineerHow to check your configuration
nginx -v
grep -rn "rewrite" /etc/nginx/
Look through the matched rewrite directives for one that uses an unnamed capture group, $1, $2, and so on, inside a replacement string containing a question mark, and check whether the same location block also contains a following rewrite, if, or set directive. If you find that exact combination on an affected version, treat it as confirmed exposure. If you do not find it, the specific code path is not reachable even on an unpatched version, though upgrading remains the correct move since new configuration changes could introduce the pattern later without anyone noticing.
How to fix it
Upgrade to nginx 1.30.1 or later if you track the stable branch, or 1.31.0 or later on mainline. On Debian and Ubuntu, sudo apt update && sudo apt install nginx applies the fix once your distribution has backported it into its maintained package; on RHEL-family systems, sudo dnf upgrade nginx is the equivalent. Always verify the installed version afterward with nginx -v rather than assuming the upgrade succeeded, and confirm the service restarted cleanly with systemctl status nginx.
If an immediate upgrade is not possible, removing or rewriting the specific triggering configuration pattern, an unnamed capture with a question mark followed by another rewrite, if, or set directive in the same location, closes the exposure without touching the nginx binary itself, though this is a stopgap and not a substitute for patching.
The broader lesson
NGINX Rift is a good example of why "we have always run this configuration and never had a problem" is not the same thing as "this configuration is safe." The vulnerable code path in this case had been present since 0.6.27 and had nothing to do with unusual or exotic setups; it depended on a specific but not particularly rare pattern in rewrite directives that plenty of real configurations use for clean URLs, redirects, and query string handling. Keeping nginx itself current, not just the configuration around it, is the only reliable defense against a class of bug that lives in code nobody has reason to suspect until someone specifically goes looking for it. Our nginx security best practices guide covers the configuration side in depth; this CVE is a reminder that the software underneath the configuration needs the same attention.
Frequently asked questions
What is NGINX Rift, CVE-2026-42945?
NGINX Rift is a critical heap-based buffer overflow in the ngx_http_rewrite_module, rated CVSS 4.0 9.2 (critical) and CVSS 3.1 8.1 (high). It lets an unauthenticated attacker send a crafted request that crashes an nginx worker process, and can lead to remote code execution on systems where address space layout randomization is disabled or bypassed.
What actually triggers CVE-2026-42945?
The bug needs a specific configuration pattern: a rewrite directive using an unnamed PCRE capture group, such as $1 or $2, in a replacement that contains a question mark, followed in the same location by another rewrite, if, or set directive. nginx calculates the size of the destination buffer using one escaping method but writes the actual result using a different one, producing a mismatch that overflows the buffer.
Which nginx versions are affected?
Every version of nginx Open Source from 0.6.27 through 1.30.0, and nginx Plus releases R32 through R36. The flaw has existed in the rewrite module for roughly 18 years. It is fixed in nginx 1.30.1 (stable branch) and 1.31.0 (mainline).
Is CVE-2026-42945 being actively exploited?
Proof-of-concept exploit code was published shortly after F5 and the nginx project disclosed the vulnerability, and multiple security researchers reported observing exploitation attempts following the patch release, which is the common pattern for a well-publicized, easily triggered vulnerability.
How do I check if my nginx configuration is vulnerable?
Search your configuration files for rewrite directives that use an unnamed capture group with a question mark in the replacement, followed immediately by another rewrite, if, or set directive in the same location block. If none of your configuration files use this specific pattern, the vulnerable code path is not reachable even on an unpatched nginx version, though upgrading is still recommended.
How do I fix CVE-2026-42945?
Upgrade to nginx 1.30.1 or later on the stable branch, or 1.31.0 or later on mainline. Most Linux distributions have backported the fix into their maintained nginx packages, so a standard package manager upgrade, such as sudo apt update && sudo apt install nginx on Debian or Ubuntu, applies it once available.
Not sure where your server stands?
Get a free, read-only security check, or talk to a security engineer about managed protection.
Get your free server check Talk to a security engineer