NGINX Rift, CVE-2026-42945: An 18-Year-Old Heap Overflow in the Rewrite Module

Every NGINX Open Source build from 0.6.27 to 1.30.0 now matches a CVE scored 9.2. That match cannot tell you which ones are exposed, because CVE-2026-42945 also needs a particular rewrite pattern in the config. Nor does it find the copies inside images nobody has opened since they were built. You need both answers, and they live in different places.
| Item | Detail |
|---|---|
| Identifier | CVE-2026-42945 (CWE-122), named "NGINX Rift" by its finders |
| Affected | NGINX Open Source 0.6.27 to 1.30.0; NGINX Plus R32 to R36 before the patched builds |
| Fixed in | Open Source 1.30.1 and 1.31.0; NGINX Plus R32 P6 and R36 P4 |
| Severity | F5: CVSS 4.0 9.2 Critical, CVSS 3.1 8.1 High. nginx.org: medium |
| Exploited as of 2026-05-15 | None of the sources cited here reports exploitation as of 15 May. Public proof of concept exists. Not in CISA KEV |
| Disclosed | 2026-05-13 |
What has to line up
F5's CVE record gives the conditions: a rewrite directive followed by a rewrite, if or set directive, an unnamed PCRE capture such as $1 or $2, and a replacement string containing a question mark. F5 says an unauthenticated attacker, along with conditions beyond its control, can exploit this with crafted HTTP requests, which may overflow the heap in a worker process and lead to a restart.
The upstream fix commit opens with this configuration, which it says resulted in incorrect escaping of $1 and a possible segfault. The rewrite regex holds the unnamed group, and its replacement holds the ? and no $1 reference. The reference appears only in the set that follows, so a search for $1 in rewrite replacements will miss it.
location / {
rewrite ^(.*) /new?c=1;
set $myvar $1;
return 200 $myvar;
}
The name and the 18-year framing come from the finders by way of The Hacker News, and the Cloud Security Alliance note dates the code to 2008. nginx.org uses neither and lists 0.6.27 as the first vulnerable version. F5 credits Zhenpeng (Leo) Lin.
Why the buffer comes up short
The fix commit states the cause, and the 1.30.0 source shows the path. The CVE record stops at the conditions above.
In src/http/ngx_http_script.c, a ? in the replacement makes ngx_http_script_start_args_code set e->is_args = 1 on the script engine, and nothing resets it. When a later set references a capture group, ngx_http_script_complex_value_code computes the destination length using a freshly zeroed sub-engine, where ngx_http_script_copy_capture_len_code measures the capture as raw bytes. The copy then runs on the main engine, where is_args is still 1, so ngx_http_script_copy_capture_code escapes the capture through ngx_escape_uri with the NGX_ESCAPE_ARGS flag.
The buffer was sized for the raw bytes. The output is longer, because Security Affairs reports that characters like +, % and & each expand by two bytes during the copy. The write runs past the allocation, and the finders, quoted by The Hacker News, say the bytes written past it are derived from the attacker's URI, so the corruption is shaped by the attacker rather than random. Length computed under one escaping assumption, data written under another.
How bad is it
The scores disagree. F5 says 9.2 Critical and 8.1 High. nginx.org says medium. I would not spend time reconciling them, because neither score has read your config.
F5's advisory, as quoted by The Hacker News, says code execution is possible on systems with ASLR disabled. The finders, in the same article, lead with unauthenticated remote code execution. The Cloud Security Alliance note fits both: crash and denial of service in all configurations, code execution demonstrated only with ASLR disabled, and reliability with ASLR on an open question. My position: if you have the pattern, treat it as a remote crash today and as code execution on any host where ASLR is off.
None of the sources cited here reports exploitation as of 15 May. Security Affairs says there were no reports of exploitation in the wild at the time of disclosure, CISA's SSVC enrichment in the CVE record says Exploitation none, Automatable no, Technical Impact total, and the KEV catalog has no entry. The CSA note says a public proof of concept was on GitHub as of 13 May, so treat that quiet as a snapshot.
What to do now
-
Patch Open Source. Go to 1.30.1 (stable) or 1.31.0 (mainline), both released 13 May, and restart so workers load the new binary. The Hacker News lists no fix planned for 0.6.27 to 0.9.7, so builds that old have to move to a fixed release.
-
Patch NGINX Plus. Go to R32 P6 or R36 P4. The CVE record lists R37 as unaffected and names no patched build for R33 to R35, so check your branch with F5. It also says versions past End of Technical Support are not evaluated, so absence from the list does not clear you.
-
Check other F5 products. The Hacker News lists NGINX Instance Manager, F5 WAF for NGINX, App Protect, F5 DoS for NGINX, Gateway Fabric and NGINX Ingress Controller. Take the ranges from K000161019. The sources here do not address the community project from the ingress-nginx post, and that silence is not clearance.
-
Find the copies in images. CSA says to inventory NGINX in containers, sidecars and Kubernetes ingress controllers. Rebuild and redeploy those, because a patched host package changes nothing inside an image.
-
Audit the config. List every
rewritewhose replacement contains a?, then read its regex and therewrite,ifandsetdirectives that follow it in the same scope for unnamed captures. Do not grep only for$1in the replacement, because the fix commit's own configuration has the group(.*)in therewriteregex and references$1only in theset. -
If you cannot patch yet, use named captures. This is the interim workaround from The Hacker News: replace unnamed captures with named captures in every affected
rewritedirective. This is the safe form of the example in Security Affairs.rewrite ^/users/(?<user_id>[0-9]+)$ /profile.php?id=$user_id last; -
Watch for crashes, and do not lean on the WAF. CSA treats WAF rules and rate limiting as supplementary, and suggests access logging and watching requests to URI paths handled by rewrite-and-set combinations. The other signal is the failure F5 describes, a worker process restart, so look for unexpected worker exits in the error log. A crash proves nothing alone, and neither does a quiet log.
The wider lesson
A version match overstates this bug. A config review alone understates it, because it only sees the NGINX you remembered to review. The real answer is the join: which artifacts contain a vulnerable build, and which of those carry the pattern.
I would still patch everything. A vulnerable binary without the pattern is one config change from exposed, so config should set the order of work and never excuse skipping it. Audit what is deployed as well as what is in the repository, which is the argument of scanning the artifact you ship.
This is the problem Dwaar works on: discovering what you ship from source control, registries and cloud accounts, scanning it, and keeping one findings list with EPSS and KEV signals.
Take every image you run, mark the ones holding a vulnerable NGINX, and run that audit against the config each one uses. Whatever matches both goes first.
References
- CVE-2026-42945 record, CVE.org (F5, CISA ADP), 2026-05-13
- nginx security advisories, nginx.org, rolling page
- Changes with nginx 1.30.1, nginx.org, 2026-05-13
- Changes with nginx 1.31.0, nginx.org, 2026-05-13
- K000161019, F5, 2026-05-13
- Rewrite: fixed escaping and possible buffer overrun, nginx on GitHub, committed 2026-05-13
- ngx_http_script.c at release 1.30.0, nginx on GitHub, tagged 2026-04-14
- 18-year-old NGINX rewrite module flaw, The Hacker News, 2026-05-14
- CSA Research Note: NGINX Rift, Cloud Security Alliance, 2026-05-14
- NGINX Rift: an 18-year-old flaw in the world's most deployed web server just came to light, Security Affairs, 2026-05-14
- Known Exploited Vulnerabilities catalog, CISA, rolling catalog
