CVE-2026-42574: Verified Repro With Script Download
CVE-2026-42574: apko: symlink-following path traversal writes files outside the build root
CVE-2026-42574 is verified against apko · go. Affected versions: >= 0.14.8, < 1.2.5. Fixed in 1.2.5. Vulnerability class: Path Traversal. This high reproduction includes runnable sandbox proof, artifacts, and a plain-text agent view under REPRO-2026-00152.
What Is CVE-2026-42574?
CVE-2026-42574 is a high-severity path-traversal vulnerability in apko where the package-install filesystem layer follows attacker-controlled symlinks, letting a crafted .apk package write files outside the intended build root. Pruva reproduced it (reproduction REPRO-2026-00152).
CVE-2026-42574 Severity & CVSS Score
CVE-2026-42574 is rated high severity, with a CVSS base score of 7.5 out of 10.
High — serious impact or readily exploitable. Prioritize remediation.
Affected apko Versions
apko · go versions >= 0.14.8, < 1.2.5 are affected.
How to Reproduce CVE-2026-42574
pruva-verify REPRO-2026-00152 curl -O https://pruva.dev/api/v1/reproductions/REPRO-2026-00152/artifacts/reproduction_steps.sh && chmod +x reproduction_steps.sh && ./reproduction_steps.sh Proof of Reproduction for CVE-2026-42574
Reproduced by Pruva's autonomous agents — 236 tool calls over 20 min. Full root-cause analysis and the complete transcript are below.
How the agent worked
Root Cause and Exploit Chain for CVE-2026-42574
Summary
CVE-2026-42574 is a path-traversal vulnerability in chainguard.dev/apko caused by the dirFS implementation following attacker-controlled symlinks during filesystem operations. A crafted .apk package can plant a symlink inside the build root whose target points outside the intended directory; a subsequent tar entry whose path resolves through that symlink causes file writes or directory creations to land outside the build root, allowing arbitrary filesystem modification during package installation.
Impact
- Package/component affected:
chainguard.dev/apko/pkg/apk/fs(dirFS) - Affected versions:
0.14.8through< 1.2.5 - Fixed versions:
1.2.5 - Risk level: High (CVSS 7.5)
- Consequences: An attacker who controls the contents of an
.apkpackage processed by apko can write files or create directories anywhere on the host filesystem reachable by the apko process, leading to arbitrary code execution, information disclosure, or container image poisoning.
Root Cause
The vulnerable dirFS type (pkg/apk/fs/rwosfs.go) implements a directory-backed filesystem by joining caller-supplied paths with a base directory. Before the fix, sanitizePath used filepath.Clean(filepath.Join(f.base, clean)) to validate paths. This check is purely lexical — it ensures the cleaned path remains under f.base but does not prevent the operating system from resolving symlinks when os.WriteFile, os.MkdirAll, or os.OpenFile is later called with the validated path.
Because os.WriteFile("base/evil/pwned", ...) follows the symlink base/evil -> ../outside, the write lands at outside/pwned even though sanitizePath permitted "evil/pwned" as in-bounds. The same issue affects MkdirAll, OpenFile, Chmod, Chown, and other dirFS methods.
The fix commit f5a96e1299ac81c7ea9441705ec467688086f442 replaces sanitizePath and raw os.* calls with os.Root, which sandboxes every filesystem operation so that symlink traversal outside the root directory is rejected by the Go standard library at the syscall level.
Reproduction Steps
The reproduction is fully automated by repro/reproduction_steps.sh.
What the script does:
- Writes a self-contained Go program (
repro/main.go) that importschainguard.dev/apko/pkg/apk/fs. - The program creates a temporary sandbox with a
basedirectory and anoutsidedirectory. - It initializes
apkfs.DirFSonbase, plants a symlinkevil -> ../outside, and callsfsys.WriteFile("evil/pwned", []byte("malicious-content"), 0644). - The program writes a JSON report capturing whether the file was created outside the base directory and what error (if any) was returned.
- The script compiles and runs the program against the vulnerable module version
v1.2.4and the fixed versionv1.2.5. - It compares the JSON reports: on the vulnerable build the outside file exists with attacker-controlled content; on the fixed build the write is blocked and the outside file is absent.
Expected evidence:
- Vulnerable (
v1.2.4):report.file_exists == true,report.file_content == "malicious-content". Thewrite_errorfield shows"file does not exist"(the memFS overlay fails, but the on-disk write through the symlink already succeeded). - Fixed (
v1.2.5):report.file_exists == false,write_errorshows"openat evil/pwned: path escapes from parent"(blocked byos.Root).
Evidence
repro/runtime_manifest.json— contains the full JSON reports from both runs, including concrete sandbox paths, file contents, and error messages.logs/vuln_report.json— detailed report from the vulnerable run.logs/fix_report.json— detailed report from the fixed run.
Key excerpts from runtime_manifest.json:
{
"vulnerable_report": {
"outside_file": "/tmp/apko-repro-310748142/outside/pwned",
"write_error": "file does not exist",
"file_exists": true,
"file_content": "malicious-content"
},
"fixed_report": {
"outside_file": "/tmp/apko-repro-3615258946/outside/pwned",
"write_error": "openat evil/pwned: path escapes from parent",
"file_exists": false
}
}
Environment: Go 1.24.7 (linux/amd64), chainguard.dev/apko fetched from the Go module proxy.
Recommendations / Next Steps
- Fix approach: Adopt
os.Root(Go 1.25+) for all filesystem operations scoped to a directory, as done in commitf5a96e1299ac81c7ea9441705ec467688086f442.os.Rootprevents both direct..traversal and symlink-following escapes without requiring manual path resolution. - Upgrade guidance: Upgrade
chainguard.dev/apkotov1.2.5or later. - Testing recommendations: Add fuzz-style tests that plant symlinks with absolute, relative (
../outside), and chained targets, then attemptWriteFile,MkdirAll,OpenFile(O_CREATE),Link, andMknodthrough them. Ensure all attempts are rejected and no files appear outside the root.
Additional Notes
- Idempotency:
repro/reproduction_steps.shwas executed twice consecutively with identical results. - Edge cases: The reproduction exercises the
WriteFilepath, which is the simplest demonstration of thedirFSsymlink-follow vulnerability. The same root cause affectsMkdirAll,OpenFile,Chmod,Chown, andMknod. The fix commit added explicit tests for all of these variants. - Limitations: The reproduction uses the public
apkfs.DirFSAPI directly rather than the fullapko buildCLI workflow, because the CLI requires a signed APK repository, index, and YAML configuration. ThedirFSlayer is the shared component used by the package-install path, so a directdirFSreproduction is the most reliable and minimal demonstration of the bug.
CVE-2026-42574 Reproduction Transcript
The agent's step-by-step process — every tool call, every handoff, the moment the exploit fired.
Full session Replay every step — scrub the timeline or play it back.
Artifacts and Evidence for CVE-2026-42574
Scripts, logs, diffs, and output captured during the reproduction.
No artifacts available
How to Fix CVE-2026-42574
Upgrade apko · go to 1.2.5 or later.
FAQ: CVE-2026-42574
How does the apko symlink-following path traversal attack work?
Which versions of apko are affected by CVE-2026-42574, and where is it fixed?
How severe is CVE-2026-42574?
How can I reproduce CVE-2026-42574?
References for CVE-2026-42574
Authoritative sources for CVE-2026-42574 — official vulnerability databases and the upstream advisory. Pruva's reproduction verifies the issue firsthand; these are the primary records to corroborate it.