---
id: "CVE-2026-42945"
kind: "vulnerability"
aliases: ["CVE-2026-42945"]
title: "NGINX: rewrite module heap overflow lets remote requests crash workers or run code"
severity: "critical"
cvss: 9.2
epss: 0.03396
exploited: false
status: "open"
category: "runtime"
products: [{"name": "f5 dos", "fixed": [], "affected": ">= 4.3.0, <= 4.7.0", "ecosystem": "vendor"}, {"name": "f5 dos", "fixed": [], "affected": "= 4.8.0", "ecosystem": "vendor"}, {"name": "f5 nginx gateway fabric", "fixed": [], "affected": ">= 1.3.0, <= 1.6.2", "ecosystem": "vendor"}, {"name": "f5 nginx gateway fabric", "fixed": [], "affected": ">= 2.0.0, <= 2.5.1", "ecosystem": "vendor"}, {"name": "f5 nginx ingress controller", "fixed": [], "affected": ">= 3.5.0, <= 3.7.2", "ecosystem": "vendor"}, {"name": "f5 nginx ingress controller", "fixed": [], "affected": ">= 4.0.0, <= 4.0.1", "ecosystem": "vendor"}, {"name": "f5 nginx ingress controller", "fixed": [], "affected": ">= 5.0.0, <= 5.4.1", "ecosystem": "vendor"}, {"name": "f5 nginx instance manager", "fixed": [], "affected": ">= 2.16.0, <= 2.21.1", "ecosystem": "vendor"}, {"name": "f5 nginx open source", "fixed": [], "affected": ">= 0.6.27, <= 1.30.0", "ecosystem": "vendor"}, {"name": "f5 nginx plus", "fixed": [], "affected": ">= r32, <= r36", "ecosystem": "vendor"}, {"name": "f5 waf", "fixed": [], "affected": ">= 4.9.0, <= 4.16.0", "ecosystem": "vendor"}, {"name": "f5 waf", "fixed": [], "affected": ">= 5.1.0, <= 5.8.0", "ecosystem": "vendor"}, {"name": "f5 waf", "fixed": [], "affected": ">= 5.9.0, <= 5.12.1", "ecosystem": "vendor"}]
ecosystems: ["vendor"]
tags: ["api-gateway", "cloudflare", "ingress", "kubernetes", "lab-disclosure", "nginx", "runtime", "self-hosted"]
not_affected_if: ["default-config", "no-rewrite-with-query-string"]
published_at: "2026-05-13T16:16:50+00:00"
first_seen_at: "2026-10-24T18:56:54+00:00"
updated_at: "2026-10-25T12:38:49+00:00"
sources: [{"source": "lab", "url": "https://developers.cloudflare.com/changelog/post/2026-05-15-emergency-waf-release/", "first_seen_at": "2026-10-24T18:56:54+00:00"}, {"source": "nvd", "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-42945", "first_seen_at": "2026-10-24T19:23:38+00:00"}, {"source": "epss", "url": "https://api.first.org/data/v1/epss?cve=CVE-2026-42945", "first_seen_at": "2026-10-25T12:38:49+00:00"}]
---

# NGINX: rewrite module heap overflow lets remote requests crash workers or run code

A crafted URI with escapable characters makes NGINX's rewrite module write past a heap buffer, because the length and copy passes disagree in ngx_http_script_copy_capture_code(). The result is a worker process crash, and with heap manipulation possibly remote code execution.

_Summary, check and fix written by a model from the sources; labelled as such._

## Affected

- vendor:f5 dos affected >= 4.3.0, <= 4.7.0 fixed ?
- vendor:f5 dos affected = 4.8.0 fixed ?
- vendor:f5 nginx gateway fabric affected >= 1.3.0, <= 1.6.2 fixed ?
- vendor:f5 nginx gateway fabric affected >= 2.0.0, <= 2.5.1 fixed ?
- vendor:f5 nginx ingress controller affected >= 3.5.0, <= 3.7.2 fixed ?
- vendor:f5 nginx ingress controller affected >= 4.0.0, <= 4.0.1 fixed ?
- vendor:f5 nginx ingress controller affected >= 5.0.0, <= 5.4.1 fixed ?
- vendor:f5 nginx instance manager affected >= 2.16.0, <= 2.21.1 fixed ?
- vendor:f5 nginx open source affected >= 0.6.27, <= 1.30.0 fixed ?
- vendor:f5 nginx plus affected >= r32, <= r36 fixed ?
- vendor:f5 waf affected >= 4.9.0, <= 4.16.0 fixed ?
- vendor:f5 waf affected >= 5.1.0, <= 5.8.0 fixed ?
- vendor:f5 waf affected >= 5.9.0, <= 5.12.1 fixed ?

## How to check

- Run `nginx -v` and compare against the fixed versions listed in the fix field.
- Search configs for `rewrite` directives whose replacement string contains `?` followed by `set` or `if` that reference capture groups.
- For NGINX Ingress, NGINX Gateway Fabric, or NGINX Instance Manager, check the controller or product version rather than the nginx binary.

## Fix

- NGINX Open Source: upgrade to `1.30.1` or later.
- NGINX Plus: move to the fixed release from F5's advisory (unknown in the sources).
- NGINX Ingress Controller, NGINX Gateway Fabric, NGINX Instance Manager, F5 WAF and DOS: the fixed versions are unknown in the sources.
- Interim mitigation if upgrading is not possible: avoid `rewrite` directives with `?` in the replacement string followed by `set` or `if` that reference capture groups.

## Timeline

- 2026-10-24T18:56:54+00:00 lab https://developers.cloudflare.com/changelog/post/2026-05-15-emergency-waf-release/ — Cloudflare: WAF Release - 2026-05-15 - Emergency · Changelog
- 2026-10-24T19:23:38+00:00 nvd https://nvd.nist.gov/vuln/detail/CVE-2026-42945
- 2026-10-25T12:38:49+00:00 epss https://api.first.org/data/v1/epss?cve=CVE-2026-42945

## Documents

- [advisory] Cloudflare: WAF Release - 2026-05-15 - Emergency · Changelog https://developers.cloudflare.com/changelog/post/2026-05-15-emergency-waf-release/

## From the sources

WAF Release - 2026-05-15 - Emergency · Changelog

# Changelog

New updates and improvements at Cloudflare.

May 15, 2026

## WAF Release - 2026-05-15 - Emergency

This emergency release introduces two new rules to detect nginx heap buffer overflow and heap spray exploitation attempts targeting the rewrite module's `is_args` stale-state bug (CVE-2026-42945).

Key Findings

CVE-2026-42945: nginx Heap Buffer Overflow via Stale `is_args` in Rewrite Module

Successful exploitation allows remote attackers to trigger a heap buffer overflow in nginx's rewrite module by sending crafted URIs containing escapable characters. A length/copy pass mismatch in `ngx_http_script_copy_capture_code()` causes the copy pass to write escaped data into an undersized buffer, leading to heap corruption. This enables denial of service (worker process crash) and, with heap feng shui techniques, potential remote code execution.

We strongly recommend upgrading to nginx 1.30.1 (or later) immediately to address the underlying vulnerability. If you cannot upgrade immediately, avoid `rewrite` directives with `?` in the replacement string followed by `set` or `if` referencing capture groups.

| Ruleset | Rule ID | Legacy Rule ID | Description | Previous Action | New Action | Comments |
| --- | --- | --- | --- | --- | --- | --- |
| Cloudflare Managed Ruleset | ...7e52be73 | N/A | nginx - Remote Code Execution - Buffer Overread - CVE:CVE-2026-42945 | N/A | Block | This is a new detection. |
| Cloudflare Managed Ruleset | ...9df0ee6c | N/A | nginx - Remote Code Execution - Heap Spray - CVE:CVE-2026-42945 | N/A | Block | This is a new detection. |

---

_Free to read at a human pace. An API with keys and an MCP server are in preparation; early access: hello@infrastack.ai_
