zip -T:通过精心构造的归档文件名实现操作系统命令注入| CVE | CVE-2026-130335(Debian DSA,bugs.debian.org/1143866) |
| 组件 | Info-ZIP Zip 3.0(以及 3.1 beta – 3.1c)——zip.c 中的 check_zipfile() |
| 受影响版本 | Zip 3.0、3.1b–3.1c;已在 Debian zip/3.0-16 中修复(fix-command-injection.patch) |
| 修复于 | 真正的 Debian/Info-ZIP 修复——quote_arg() 正确引用(本实验的修复侧) |
| CWE | CWE-78(操作系统命令注入) |
| 影响 | 以运行 zip -T 的用户的权限执行任意命令,前提是该用户处理受攻击者影响的归档文件名——CI 流水线、打包服务、上传验证流程 |
| 向量 | 本地/排队:攻击者控制归档文件名;受害者(或流水线)运行 zip -T <name>;CVE 指出没有常见场景会将不受信任的文件名传给 zip -T——本实验如实建模了该前提条件 |
| 触发条件 | 包含单引号的归档文件名,例如 a.zip';id>pwned;# |
zip -T 通过构建 shell 命令并调用 system() 来验证刚写入的归档:
/* zip 3.0 check_zipfile() — the UNIX branch wraps the name in SINGLE quotes */
strcat(cmd, "'");
strcat(cmd, zipname);
strcat(cmd, "'");
...
result = system(cmd);
包含单引号的名称会突破该引号包裹并执行攻击者命令。Debian 的修复(3.0-16)引入了 quote_arg()——用双引号包裹,并对 "、!、$、反引号和反斜杠逐字符转义。本实验基于上游 3.0 源码和 Debian 补丁系列构建双方,二者仅相差这一个修复补丁。
单引号并非一种能够抵御包含单引号的攻击者输入的引号机制。check_zipfile() 在 UNIX 上构建:
sh -c "unzip -tqq 'a.zip';id>pwned;#'"
a.zip 之后的第一个 ' 会闭合引号范围;其余部分则作为 shell 命令执行。
修复方案使用双引号并转义五个危险字符,因此该名称会作为一个字面参数传递给 unzip。
| 服务 | 镜像 | 角色 |
|---|---|---|
zip-vuln | cve-2026-130335:vuln | Zip 3.0 + Debian 补丁,不含 fix-command-injection.patch(= 3.0-15) |
zip-fixed | cve-2026-130335:fixed | 同上 + 修复补丁(= 3.0-16)—— 真正的厂商/发行版修复 |
poc | cve-2026-130335-poc:local | 仅使用标准库的 Python 驱动 |
打包服务模拟了文档中描述的前提条件:调用方选择归档名称,在该名称下创建真实的 zip 文件,并由 zip -T 对其进行验证 —— 这正是上传/CI 流水线的做法。文件名作为单个 argv 元素传递给 zip(服务层没有 shell),因此任何突破都发生在 Zip 自身的 system() 调用内部。安装 unzip 是因为 zip -T 会通过 shell 调用 unzip -tqq。
./run-lab.sh build # builds zip 3.0 twice (with/without the fix patch)
./run-lab.sh up # cve130335lab network, zip-vuln, zip-fixed
./run-lab.sh sweep # check / exploit / probe / mitigation on both sides
./run-lab.sh down
一个独立的完整链路利用脚本位于 exploit/exploit.py
(python3 exploit/exploit.py --host=<target>;确认利用成功时退出码为 1,目标安全时退出码为 0)。
uid=0(root) ...)。| 运行 | zip-vuln (3.0-15) | zip-fixed (3.0-16) |
|---|---|---|
check 无害 | zip 退出码 0,无标记 | 退出码 0,无标记 |
check 突破 | 标记已创建 — 注入的 id 已执行 | 安全引用,无标记 |
exploit | uid=0(root) gid=0(root) groups=0(root) | (无注入) |
probe 美元符形式 | 执行(标记中包含 /root) | 安全 |
probe 反引号形式 | 退出码 8(被引用上下文拦截) | 安全 |
捕获的运行记录:evidence/check-*-run.txt、evidence/exploit-*-run.txt、
evidence/probe-*-run.txt、evidence/mitigation-*-run.txt、
evidence/versions.txt、evidence/0day-sweep.txt。
cve130335lab 网络上。名称形态矩阵即为攻击面扫描(evidence/0day-sweep.txt):
该修复消除了所有突破形式;在存在漏洞的构建上,单引号和美元符形式可执行任意命令。除 check_zipfile 的 system() 调用外,未发现第二个注入汇聚点。
README.md this write-up
run-lab.sh environment driver (build / up / sweep / down)
Makefile convenience targets
exploit/exploit.py standalone full-chain exploit
poc/poc.py the PoC (check / exploit / probe / mitigation)
poc/Dockerfile runner image (python:3.12-alpine)
lab/lab.Dockerfile multi-stage build (zip 3.0 with/without the fix)
lab/patches/ the Debian patch series (series file included)
lab/service.py the packaging service (the documented precondition)
evidence/ captured runs of every mode on both sides
TRACKING.md excluded (working record)