PoC Archive PoC Archive
CVE-2026-42533 category: web CVSS 9.8 (CRITICAL)
Unverified

nginx PCRE Capture Variable Heap Overflow to Pre-Auth RCE (CVE-2026-42533)

Published: 2026-08-16 • Researcher: 0xCyberstan

Target software nginx 1.30.1 (and likely earlier versions)
Affected versions nginx 1.30.1 with PCRE regex capture variables in map directives
Status Patched
Severity Critical · CVSS 9.8
CVSS 9.8/10
Severity
Critical
CVE
CVE-2026-42533
Category
web
Affected product
nginx 1.30.1 (and likely earlier versions)
Affected versions
nginx 1.30.1 with PCRE regex capture variables in map directives
Disclosed
2026-08-16
Patch status
Unverified
On this page

Metadata

FieldValue
Date Added2026-08-16
Last Updated2026-08-16
Author / Researcher0xCyberstan
CVE / AdvisoryCVE-2026-42533
Categoryweb
SeverityCritical
CVSS Score9.8 (pre-auth remote RCE)
StatusPatched
Tagsnginx, pcre, heap-overflow, rce, preauth, info-leak, capture-variable, map-directive, aslr-bypass, CVE-2026-42533
Related

Affected Target

FieldValue
Software / Systemnginx 1.30.1 (and likely earlier versions)
Versions Affectednginx 1.30.1 with PCRE regex capture variables in map directives
Language / PlatformPython 3 (exploit suite)
Authentication RequiredNone – pre-authentication
Network Access RequiredRemote – HTTP access to nginx instance

Summary

CVE-2026-42533 is a heap buffer overflow in nginx triggered by PCRE regex capture variable handling. When two map directives share the same capture group name, a length/value mismatch occurs in the internal variable copy code (ngx_http_script_copy_capture_code and ngx_http_script_copy_var_code). The first map sets the captured length, the second map overwrites the captured value with different content, but the copy code uses the stale (shorter) length for allocation while writing the full (longer) value, causing a heap overflow.

The exploit suite includes: crash PoC (heap corruption), info leak (libc and heap address disclosure from uninitialized heap residue), single-shot RCE chain (66% success rate), deterministic RCE variant, calibration tool for build-specific offsets, and a 13-site ASan test harness covering all affected code paths across HTTP and stream modules.

Vulnerability Details

Root Cause

When nginx evaluates map directives with regex captures, the capture variable length is recorded during the first match but the value pointer may be overwritten by a subsequent map evaluation. The copy functions (ngx_http_script_copy_capture_code, ngx_http_script_copy_var_code) allocate based on the recorded length but memcpy based on the actual (potentially longer) value, overflowing the heap buffer.

Attack Flow

  1. Info leak: Send crafted GET request with long URI matching a capture group; the response body contains uninitialized heap residue with libc and heap pointers
  2. ASLR bypass: Extract libc base and heap pointer from leaked data, compute system() address
  3. Heap spray: Open multiple connections to shape heap layout, create and free a hole at a predictable position
  4. Overflow trigger: POST request with body matching the regex triggers the heap overflow, corrupting pool cleanup structures
  5. RCE: Corrupted cleanup handler points to system() with attacker-controlled command argument; fires on connection close

Source Repository

FieldValue
Original URLhttps://github.com/0xCyberstan/CVE-2026-42533-POC
Archive Date2026-08-16
Stars at Archive0