
Proof-of-concept lab for CVE-2026-131842: Poppler pdfdetach path traversal via crafted embedded file names, with vulnerable/fixed containers and exploit scripts.
| CVE | CVE-2026-131842 |
| Component | Poppler utils/pdfdetach.cc — -saveall / -savefile extraction |
| Affected | pdfdetach 24.03.0 through 26.11.0 |
| Fixed in | no upstream fix yet (work item 1826 OPEN); this lab's fixed side carries a documented synthetic component-aware containment patch |
| CWE | CWE-22 (Improper Limitation of a Pathname to a Restricted Directory) |
| Impact | Arbitrary file create/overwrite with the privileges of whoever runs pdfdetach — any document pipeline that detaches embedded files from untrusted PDFs into a quarantine directory (pdfdetach -saveall -o <dir>) can be made to write outside that directory (config, cron, source trees, SSH keys — anything writable) |
| Vector | File format — a crafted PDF whose embedded-file name escapes the output directory |
| Trigger | one upload whose embedded file name is ../<base-suffix>/… (sibling-prefix bypass) or passes through a symlink inside the output directory |
Since 24.03.0 the output directory is "protected" by a string-prefix containment check:
// 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 on the normalized string is not containment. With base
/work/quarantine, an embedded name ../quarantine-staging/pwned.txt
normalizes to /work/quarantine-staging/pwned.txt — outside the base,
yet a string prefix of it — so the guard passes and save() writes the
file. A symlink inside the output directory defeats the check the same
way: the lexical path stays "inside" while fopen() follows the link.
This laboratory demonstrates both forms deterministically.
lexically_normal() + generic_string().starts_with(base) checks
characters, not path components. Two consequences:
../quarantine-staging/…) or, with a trailing-slash-less base,
sibling entries at every level.The older 2023-era fix (commit d8e7a8a9, "Fix directory traversal in pdfdetach") survived into 24.03+ in this weakened form; upstream work item 1826 tracks the bypass and is still open — there is no vendor fix to differential against yet.
| service | image | role |
|---|---|---|
pdf-vuln | cve-2026-131842:vuln | pdfdetach built from upstream tag poppler-26.11.0 as-is |
pdf-fixed | cve-2026-131842:fixed | same tree + synthetic component-aware containment patch (sha256 in evidence/versions.txt) |
poc | cve-2026-131842-poc:local | stdlib-only Python driver that crafts the PDFs |
The pipeline service models a real product flow: POST /detach accepts a
PDF, runs pdfdetach -saveall -o /work/quarantine <pdf> as a child
process, and reports every file created outside the quarantine
directory. Two lab preconditions (identical on both sides) make the
vectors deterministic and are documented as such: a sibling directory
/work/quarantine-staging (writes need an existing parent) and a
symlink /work/quarantine/link-escape → /work/escape-zone — both
plausible in any pipeline that accumulates staging dirs and symlinks.
./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
A standalone full-chain exploit script ships at exploit/exploit.py
(python3 exploit/exploit.py --host=<target>; exit 1 on confirmed
exploitation, 0 on a safe target).
poc/poc.py (stdlib only — it writes the minimal PDF bytes itself):
.. control.| case | pdf-vuln (26.11.0) | pdf-fixed (synthetic patch) |
|---|---|---|
benign doc.txt | saved inside quarantine, exit 0 | exit 0 |
../quarantine-staging/pwned-prefix.txt | written outside, exit 0 | rejected "Preventing directory traversal", exit 3 |
link-escape/pwned-sym.txt | written through symlink, exit 0 | still written (residual) |
../pwned-direct.txt (control) | blocked, exit 3 | blocked, exit 3 |
Captured runs: evidence/check-*-run.txt, evidence/exploit-*-run.txt,
evidence/probe-*-run.txt, evidence/mitigation-*-run.txt,
evidence/versions.txt, evidence/0day-sweep.txt.
cve131842lab network.The probe matrix on the patched build (evidence/0day-sweep.txt) shows
the synthetic component-aware check closes the sibling-prefix bypass but
cannot close the symlink form — lexical containment never resolves
links. The symlink variant remains exploitable on every release through
26.11.0 and on this lab's fixed side; it needs a
std::filesystem::weakly_canonical-based check (or extraction into a
directory the process cannot traverse out of, e.g. a per-job mount
namespace). That residual is documented upstream in work item 1826.
Deployment mitigations until a vendor fix: reject embedded names
containing .. components before invoking pdfdetach, and run
detachment in a container without write access outside the quarantine.
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)