
这是一个面向防守和内网排查的 CVE-2026-42945 静态检测工具,用于检查 NGINX ngx_http_rewrite_module 相关配置是否存在高风险 rewrite 组合。
This is a CVE-2026-42945 static detection tool for defense and internal network investigation, used to check whether there are high-risk rewrite combinations in NGINX ngx_http_rewrite_module related configurations.
This project does not provide exploit code, does not send malicious HTTP requests, and does not attempt to trigger crashes or remote code execution. It only reads local NGINX configuration files to help security teams determine whether an upgrade or configuration overhaul is needed.
CVE-2026-42945 is a heap buffer overflow vulnerability in NGINX Open Source and NGINX Plus ngx_http_rewrite_module.
The risk scenarios described in the public advisory roughly include:
rewrite directive;rewrite, if, or set directive;$1, $2;?.The fixed versions for NGINX Open Source include 1.30.1, 1.31.0 and later. For NGINX Plus, refer to the fixed versions in the vendor advisory.
Reference links:
Only Python 3 is required, no third-party dependencies.
python3 --version
It is recommended to first export the fully rendered NGINX configuration:
nginx -T > nginx-rendered.conf
python3 cve_2026_42945_checker.py nginx-rendered.conf
You can also directly scan the configuration directory:
python3 cve_2026_42945_checker.py /etc/nginx
Output JSON:
python3 cve_2026_42945_checker.py --json nginx-rendered.conf
If the exported configuration does not contain NGINX version information, you can manually specify the version for auxiliary judgment:
python3 cve_2026_42945_checker.py --json --nginx-version 1.30.0 nginx-rendered.conf
Output SARIF, convenient for importing into GitHub code scanning or internal security platforms:
python3 cve_2026_42945_checker.py --sarif nginx-rendered.conf > cve-2026-42945.sarif
0: No high-risk configuration pattern found;1: At least one high-risk configuration pattern found;2: Failed to read input file or path.Key fields in the detection results include:
versions: NGINX version identified from configuration or parameters and the judgment result;findings: Matched risk configuration locations, reasons, and evidence;summary: Number of scanned files, number of findings, and highest risk level.Example risk results will indicate evidence like:
rewrite ... ?$1; -> set ... $1;
This indicates that the configuration pattern is similar to the risk conditions described in the public advisory and requires priority review.
Prioritize upgrading NGINX to a fixed version:
1.30.1, 1.31.0 or later;At the same time, it is recommended to review rewrite rules:
$1, $2;nginx -T before external release.This tool is a static configuration detector, not a full vulnerability validator. It may not cover:
Please use it as an auxiliary tool for internal investigation and configuration auditing, not as the sole basis for vulnerability assessment.
Run tests:
python -m pytest
The repository already contains a GitHub Actions workflow that will automatically run tests on push and pull requests.