Skip to content
Memory corruption Write-up Advanced

Needle in a haystack: measuring the impact of two nginx RCEs

Two heap buffer overflows in nginx's rewrite engine (CVE-2026-42945 and CVE-2026-9256) arise when the engine sizes a buffer in one pass and fills it in another, so certain directive combinations write past the allocation. An attacker could send a crafted request to a vulnerable configuration to trigger an unauthenticated heap overflow, leading to denial of service or potentially worse.

blog.calif.io

Published on blog.calif.io

We had a lot of fun hacking nginx earlier this year. We know from experience that finding a real RCE in nginx is hard, especially one that triggers in a default or commonly-used configuration.

Calif, on blog.calif.io

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the rewrite script engine measures the needed buffer size in one pass and copies data in another, and the two passes disagree because a stale escaping flag or an undercounted escape budget makes the copy larger than the allocation.

Impact

The text states these are unauthenticated heap overflows and that one vulnerable config in production is enough to cause denial of service or worse, though it judges real-world impact likely low because the required patterns almost never appear in production.

What the attacker needed

Nginx below 1.31.1; flagless rewrite with ? in replacement; later set or if using positional captures; request with escapable characters

The fix

The bugs were fixed by resetting the stale escaping flag and by correcting the escape-space budget in the length calculation.

How it was found

  1. Send a request whose captured portion contains characters that expand under URI escaping, such as plus signs.
  2. Let a flagless rewrite containing a question mark set the escaping flag and continue to the next directive.
  3. Have a later set or if directive copy the positional capture with the stale flag still set.
  4. Observe the copy pass write escaped bytes beyond the buffer sized for raw bytes.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

nginx is a web server that can rewrite incoming URLs using rules. These two bugs mean that for some unusual rule combinations, nginx reserves too little memory and then writes more than fits, corrupting memory. A remote attacker who sends a specially crafted URL to such a setup could crash the server or possibly run their own code.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.