
CVE-2026-42945 is a critical heap buffer overflow vulnerability in the NGINX server, known as "NGINX Rift". The vulnerability exists in the processing logic of the rewrite and set directives in NGINX. When specific configuration conditions are met, an attacker can trigger a heap overflow by crafting a malicious request, leading to denial of service (DoS) and potentially remote code execution (RCE).
Vulnerability Type: Heap Buffer Overflow Risk Level: High CVE ID: CVE-2026-42945
It is recommended to upgrade immediately to one of the following versions:
The vulnerability is triggered by simultaneously satisfying the following two conditions:
Configuration Condition: NGINX configuration uses both:
rewrite directive (the replacement string contains the ? character)set directive (references rewrite regex capture groups like $1, $2)Request Condition: The request URI contains escapable characters (such as +, &, %, etc.)
Principle Explanation:
rewrite directive sets e->is_args = 1 (never reset)set directive uses a zeroed sub-engine (le.is_args = 0)%25 to %, but ngx_escape_uri re-encodes it as %25 (3 bytes)%25 character expands from 1 byte to 3 bytes, causing writes beyond the buffer boundary# 使用项目中的测试脚本
python3 CVE-2026-42945/CVE-2026-42945-test.py --host cve.test.com --port 80
%25 characters for a small-scale test.%25 characters (e.g., 2000) to trigger the buffer overflow.In a single-layer NGINX configuration, the test results will trigger the vulnerability:
Crash Log Analysis:
ngx_http_script_flush_no_cacheable_variables function.ngx_http_core_rewrite_phase.In a double-layer NGINX configuration (layer1 forwarding + layer2 service), the test results are as follows:
This project is for security research and educational purposes only. Users must comply with the laws and regulations of their respective countries and regions. The authors are not responsible for any unauthorized misuse.
Prohibited for illegal attacks!
Last Updated: 2026-05-19
| Configuration Scenario | layer1 Result | layer2 Result | Cause Analysis |
|---|
rewrite without break + proxy_pass | ❌ Triggered vulnerability (404) | ❌ No request reaches | After rewrite, set continues executing, triggers heap overflow, worker crashes. |
rewrite with break + proxy_pass | ✅ Normal (200) | ⚠️ May trigger vulnerability | break terminates set execution, request is forwarded normally to the backend. |
| File | Description |
|---|
CVE-2026-42945/CVE-2026-42945-test.py | Vulnerability testing PoC script, used to verify if the target is vulnerable. |
single_layer_test/single_layer_nginx.conf | Example NGINX configuration vulnerable under single-layer architecture. |
single_layer_test/image.png | Vulnerability principle diagram. |
single_layer_test/test.log | Test log file. |
double_layer_test/layer1_nginx.conf | NGINX configuration for the first layer (forwarding layer) of double-layer architecture. |
double_layer_test/layer2_nginx.conf | NGINX configuration for the second layer (service layer) of double-layer architecture. |