Nginx Buffer Overflow Bug Allows Remote Code Execution

Key Takeaways

- CVE-2026-42945 is a heap buffer overflow in Nginx's ngx_http_rewrite_module present since 2008
- The bug enables unauthenticated remote code execution on servers using rewrite and set directives
- Nginx Open Source users should upgrade to 1.31.0 or 1.30.1; Nginx Plus users need R36 P4, R35 P2, or R32 P6
The Bug That Hid for 16 Years
A critical security vulnerability in Nginx has been sitting in plain sight since 2008. Security researchers at DepthFirst discovered CVE-2026-42945, a heap buffer overflow in Nginx's ngx_http_rewrite_module that allows unauthenticated attackers to execute arbitrary code on vulnerable servers.
The flaw affects Nginx Open Source versions 0.6.27 through 1.30.0, and Nginx Plus versions R32 through R36. Given that Nginx powers roughly a third of the internet's web servers, the exposure is significant.
DepthFirst claims their autonomous security analysis system found this vulnerability, along with three other memory corruption issues, after simply onboarding the Nginx source code. The companion CVEs are CVE-2026-42946, CVE-2026-40701, and CVE-2026-42934.
How the Exploit Works
Nginx's script engine processes rewrite directives in two passes. First, it calculates the required buffer size. Then it copies data into that buffer. The vulnerability exploits a mismatch between these two passes.
When a rewrite replacement contains a question mark, Nginx sets an is_args flag on the main engine. But the length calculation runs on a fresh sub-engine where is_args is zero. The length pass returns the raw capture length. The copy pass sees is_args as 1 and calls ngx_escape_uri with NGX_ESCAPE_ARGS, which expands certain bytes to three bytes each.
The result: the copy operation overflows the undersized heap buffer with attacker-controlled URI data.
DepthFirst's proof of concept uses what they call cross-request heap feng shui. The attack corrupts an adjacent ngx_pool_t's cleanup pointer using POST bodies, since URI bytes cannot contain null bytes. This redirects execution to a fake ngx_pool_cleanup_s that invokes system() when the pool is destroyed.
Which Servers Are Vulnerable
Not every Nginx installation is at risk. The vulnerability specifically affects servers that use rewrite and set directives in their configuration. If your Nginx config does not use these features, you are not exposed to this particular attack.
That said, rewrite rules are extremely common. They handle URL redirects, clean URLs, proxy configurations, and countless other routing tasks. Most production Nginx deployments use them somewhere.
Patched Versions
F5, which maintains Nginx, has released patches for both product lines:
- Nginx Open Source: upgrade to 1.31.0 or 1.30.1
- Nginx Plus R36: upgrade to R36 P4
- Nginx Plus R35: upgrade to R35 P2
- Nginx Plus R32: upgrade to R32 P6
The full vendor advisory is available at F5's support portal under article K000160932.
Proof of Concept Is Public
DepthFirst has published a working proof of concept on GitHub. The exploit was tested on Ubuntu 24.04.3 LTS and includes a Docker setup for spinning up a vulnerable Nginx server. Running python3 poc.py --shell pops a shell on the target.
Public exploit code means this is not a theoretical risk. Anyone can download and run it. Organizations running unpatched Nginx installations should treat this as an active threat.
Logicity's Take
What to Do Now
- Check your Nginx version: run nginx -v on your servers
- Review your configs for rewrite and set directives to assess exposure
- Apply the patch or upgrade to a fixed version immediately
- Monitor access logs for unusual URI patterns in POST requests
- Consider WAF rules to block suspiciously long or escape-heavy URIs as a temporary mitigation
Another critical infrastructure vulnerability requiring urgent patching
Related security incident involving code exposure
Frequently Asked Questions
What is CVE-2026-42945?
CVE-2026-42945 is a critical heap buffer overflow vulnerability in Nginx's ngx_http_rewrite_module. It allows unauthenticated attackers to execute arbitrary code on vulnerable servers that use rewrite and set directives.
Which Nginx versions are affected by this vulnerability?
Nginx Open Source versions 0.6.27 through 1.30.0 and Nginx Plus versions R32 through R36 are affected. Fixed versions are Nginx Open Source 1.31.0 or 1.30.1, and corresponding Nginx Plus patches.
How do I know if my Nginx server is vulnerable?
Check your version with nginx -v. If you are running an affected version and your configuration uses rewrite or set directives, you are vulnerable. Review your nginx.conf and any included config files for these directives.
Is there a public exploit available for CVE-2026-42945?
Yes. DepthFirst has published a working proof of concept on GitHub that can pop a shell on vulnerable servers. This increases the urgency of patching.
How long has this Nginx vulnerability existed?
The vulnerability was introduced in 2008 with Nginx version 0.6.27, meaning it has been present in the codebase for approximately 16 years.
Need Help Implementing This?
Source: Hacker News: Best
Huma Shazia
Senior AI & Tech Writer
Related Articles
Browse all
Robotaxi Companies Are Hiding How Often Humans Take the Wheel
Autonomous vehicle firms like Waymo and Tesla are under scrutiny for refusing to disclose how often remote operators step in to control their self-driving cars. A Senate investigation reveals major gaps in transparency, raising safety and accountability concerns.

Wisconsin Governor Throws a Wrench in Age Verification Plans
Wisconsin Governor Tony Evers has vetoed a bill that would have required residents to verify their age before accessing adult content online, citing concerns over privacy and data security. This move comes as several other states have already implemented similar age check requirements. The veto has significant implications for the future of online age verification.

Apple's App Store Empire Under Siege: The Battle for the Future of Tech
The long-running feud between Apple and Epic Games has reached a boiling point, with Apple preparing to take its case to the Supreme Court. The tech giant is fighting to maintain control over its App Store, while Epic Games is pushing for more freedom for developers. The outcome could have far-reaching implications for the entire tech industry.

Tesla's Remote Parking Feature: The Investigation That Didn't Quite Park Itself
The US auto safety regulators have closed their investigation into Tesla's remote parking feature, but what does this mean for the future of autonomous driving? We dive into the details of the investigation and what it reveals about the technology. The National Highway Traffic Safety Administration found that crashes were rare and minor, but the investigation's closure doesn't necessarily mean the feature is completely safe.
Also Read

Hackers Demand $25K for Stolen Mistral AI Source Code
The TeamPCP hacker group claims to have stolen 450 internal repositories from Mistral AI after the Mini Shai-Hulud supply-chain attack. The hackers are threatening to leak the 5GB of source code publicly if no buyer is found within a week.

Fired IT Twins Forgot to Stop Teams Recording, Caught Themselves
Twin brothers Muneeb and Sohaib Akhter deleted 96 federal databases after being fired from an IT contractor. They accidentally recorded themselves doing it because they forgot to end the Microsoft Teams call from their termination meeting.

5 Smart Home Routines That Save Time, Not Just Show Off
Most smart home setups end up as expensive party tricks. A tech journalist shares five automation routines he actually uses daily, starting with a simple smart plug that makes his morning tea while he handles the chaos of getting kids to school.