| CVE | CVE-2026-131842 |
| 组件 | Poppler utils/pdfdetach.cc — -saveall / -savefile 提取 |
| 受影响版本 | pdfdetach 24.03.0 至 26.11.0 |
| 修复版本 | 尚无上游修复(工作项 1826 处于 OPEN 状态);本实验的修复侧包含一个有文档记录的合成组件感知包含性补丁 |
| CWE | CWE-22(对路径名的限制不恰当,导致受限目录被绕过) |
| 影响 | 以运行 pdfdetach 者的权限任意创建/覆盖文件——任何将不可信 PDF 中的嵌入文件提取到隔离目录(pdfdetach -saveall -o <dir>)的文档处理流水线,都可能被诱导写入该目录之外的位置(配置文件、cron、源码树、SSH 密钥——任何可写内容) |
| 向量 | 文件格式——一个精心构造的 PDF,其嵌入文件名逃逸出输出目录 |
| 触发条件 | 一次上传,其嵌入文件名为 ../<base-suffix>/…(同级前缀绕过),或经由输出目录内的符号链接穿越 |
自 24.03.0 起,输出目录通过字符串前缀包含性检查来“保护”:
// utils/pdfdetach.cc @ poppler-26.11.0 (~L220)
std::filesystem::path filePath = basePath;
filePath = filePath.append(currentFileName).lexically_normal();
if (!filePath.generic_string().starts_with(basePath.generic_string())) {
error(errIO, -1, "Preventing directory traversal");
return 3;
}
embFile->save(filePath.generic_string());
对规范化后的字符串使用 starts_with 并不等同于包含关系。以基目录 /work/quarantine 为例,内嵌名称 ../quarantine-staging/pwned.txt 会被规范化为 /work/quarantine-staging/pwned.txt——它位于基目录之外,却是基目录字符串的前缀——因此该防护检查通过,save() 便写入了该文件。输出目录内的符号链接同样能绕过该检查:词法路径仍处于“内部”,而 fopen() 却会跟随该链接。本实验以确定性的方式演示了这两种形式。
lexically_normal() + generic_string().starts_with(base) 检查的是字符,而非路径组件。由此产生两个后果:
../quarantine-staging/…),或者当基目录不带末尾斜杠时,每一层级的同级条目。2023 年时期的旧修复(提交 d8e7a8a9,“Fix directory traversal in pdfdetach”)以这种被削弱的形式一直保留到 24.03+;上游工作项 1826 跟踪该绕过问题,且仍处于开放状态——目前尚无厂商修复可供差分对比。
| 服务 | 镜像 | 角色 |
|---|---|---|
pdf-vuln | cve-2026-131842:vuln | 按原样从上游标签 poppler-26.11.0 构建的 pdfdetach |
pdf-fixed | cve-2026-131842:fixed | 同一代码树 + 合成的组件感知包含性补丁(sha256 见 evidence/versions.txt) |
poc | cve-2026-131842-poc:local | 仅使用标准库的 Python 驱动程序,用于构造 PDF |
该流水线服务模拟真实的产品流程:POST /detach 接收一个 PDF,以子进程方式运行 pdfdetach -saveall -o /work/quarantine <pdf>,并报告在隔离目录之外创建的每个文件。两个实验前置条件(两侧完全相同)使这些向量具有确定性,并已如此记录:一个同级目录 /work/quarantine-staging(写入需要已存在的父目录)以及一个符号链接 /work/quarantine/link-escape → /work/escape-zone——在任何会累积暂存目录和符号链接的流水线中,这两者都是合理的。
./run-lab.sh build # builds poppler 26.11.0 twice (with/without the patch)
./run-lab.sh up # cve131842lab network: pdf-vuln, pdf-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)。
poc/poc.py(仅使用标准库——它自行写入最小 PDF 字节):
.. 对照。| 用例 | pdf-vuln (26.11.0) | pdf-fixed(合成补丁) |
|---|---|---|
良性 doc.txt | 保存在隔离区内,退出码 0 | 退出码 0 |
../quarantine-staging/pwned-prefix.txt | 写入外部,退出码 0 | 拒绝 "Preventing directory traversal",退出码 3 |
link-escape/pwned-sym.txt | 通过符号链接写入,退出码 0 | 仍被写入(残留) |
../pwned-direct.txt(对照) | 被阻止,退出码 3 | 被阻止,退出码 3 |
捕获的运行记录:evidence/check-*-run.txt、evidence/exploit-*-run.txt、
evidence/probe-*-run.txt、evidence/mitigation-*-run.txt、
evidence/versions.txt、evidence/0day-sweep.txt。
cve131842lab 网络上。在已打补丁的构建上运行探测矩阵(evidence/0day-sweep.txt)显示,
合成的组件感知检查关闭了同级前缀绕过,但
无法关闭符号链接形式——词法包含检查从不解析
链接。符号链接变体在直至 26.11.0 的每个版本上以及本实验的修复侧
仍然可利用;它需要基于
std::filesystem::weakly_canonical 的检查(或提取到
进程无法遍历出去的目录,例如按作业的挂载
命名空间)。该残留问题已在上游工作项 1826 中记录。
在供应商修复之前的部署缓解措施:在调用 pdfdetach 之前拒绝包含 .. 组件的嵌入名称,
并在隔离区外无写权限的容器中运行
分离操作。
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 (poppler 26.11.0 with/without patch)
lab/patches/fix-prefix-containment.patch the synthetic fixed-side patch
lab/service.py the document-pipeline service (POST /detach)
evidence/ captured runs of every mode on both sides
TRACKING.md excluded (working record)