Skip to content

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.

REPRO-2026-00152 apko · go Path Traversal May 22, 2026 CVE entry ↗ .txt
Severity
HIGH
CVSS
7.5
Reproduced in
20m 23s
Tool calls
236
Spend
$2.22
01 · Overview

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).

02 · Severity & CVSS

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 threat level
7.5 / 10 CVSS base
03 · Affected Versions

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
or curl -O https://pruva.dev/api/v1/reproductions/REPRO-2026-00152/artifacts/reproduction_steps.sh && chmod +x reproduction_steps.sh && ./reproduction_steps.sh
Run in a VM or disposable container. This exploits a real vulnerability.
06 · Proof of Reproduction

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 742 events · 236 tool calls · 20 min
20 minDuration
236Tool calls
167Reasoning steps
742Events
Agent activity over 20 min
Support
25
Repro
383
Variant
329
0:0020:23

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.8 through < 1.2.5
  • Fixed versions: 1.2.5
  • Risk level: High (CVSS 7.5)
  • Consequences: An attacker who controls the contents of an .apk package 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:

  1. Writes a self-contained Go program (repro/main.go) that imports chainguard.dev/apko/pkg/apk/fs.
  2. The program creates a temporary sandbox with a base directory and an outside directory.
  3. It initializes apkfs.DirFS on base, plants a symlink evil -> ../outside, and calls fsys.WriteFile("evil/pwned", []byte("malicious-content"), 0644).
  4. The program writes a JSON report capturing whether the file was created outside the base directory and what error (if any) was returned.
  5. The script compiles and runs the program against the vulnerable module version v1.2.4 and the fixed version v1.2.5.
  6. 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". The write_error field 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_error shows "openat evil/pwned: path escapes from parent" (blocked by os.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 commit f5a96e1299ac81c7ea9441705ec467688086f442. os.Root prevents both direct .. traversal and symlink-following escapes without requiring manual path resolution.
  • Upgrade guidance: Upgrade chainguard.dev/apko to v1.2.5 or later.
  • Testing recommendations: Add fuzz-style tests that plant symlinks with absolute, relative (../outside), and chained targets, then attempt WriteFile, MkdirAll, OpenFile(O_CREATE), Link, and Mknod through them. Ensure all attempts are rejected and no files appear outside the root.

Additional Notes

  • Idempotency: repro/reproduction_steps.sh was executed twice consecutively with identical results.
  • Edge cases: The reproduction exercises the WriteFile path, which is the simplest demonstration of the dirFS symlink-follow vulnerability. The same root cause affects MkdirAll, OpenFile, Chmod, Chown, and Mknod. The fix commit added explicit tests for all of these variants.
  • Limitations: The reproduction uses the public apkfs.DirFS API directly rather than the full apko build CLI workflow, because the CLI requires a signed APK repository, index, and YAML configuration. The dirFS layer is the shared component used by the package-install path, so a direct dirFS reproduction 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.

Event 1/40
0:001:17
0:00
session startedaccounts/fireworks/models/kimi-k2p6 · cve-2026-42574 · cve-2026
0:06
0:06
0:08
web search
0:10
0:11
web search
0:16
0:17
0:45
0:46
web search
1:07
1:07
extract_facts
no facts extracted
1:13
1:13
1:13
supportrepro
1:15
1:15
1:15
1:16
1:16
1:16
1:16
1:17

Artifacts and Evidence for CVE-2026-42574

Scripts, logs, diffs, and output captured during the reproduction.

No artifacts available

08 · How to Fix

How to Fix CVE-2026-42574

Upgrade apko · go to 1.2.5 or later.

Coming soon

Step-by-step mitigation and hardening guidance for CVE-2026-42574 — configuration checks, workarounds where no patch exists, and how to verify you're protected — is on the way.

10 · FAQ

FAQ: CVE-2026-42574

How does the apko symlink-following path traversal attack work?

A crafted .apk package first installs a TypeSymlink tar entry inside the build root whose target points outside it. A later tar entry (a directory-creation or file-write) whose path resolves through that planted symlink is then written via the OS call, which follows the symlink and lands the write outside the build root entirely.

Which versions of apko are affected by CVE-2026-42574, and where is it fixed?

Versions >= 0.14.8, < 1.2.5 are affected. It is fixed in 1.2.5.

How severe is CVE-2026-42574?

High severity (CVSS 7.5) -- an attacker who controls the contents of an .apk package processed by apko can write files or create directories anywhere on the filesystem reachable by the apko process, enabling arbitrary filesystem modification, code execution, or container image poisoning.

How can I reproduce CVE-2026-42574?

Download the verified script from this page and run it in an isolated environment against apko >= 0.14.8, < 1.2.5. It crafts an .apk package containing a symlink entry pointing outside the build root followed by a write entry that resolves through it, and shows the write landing outside the intended build root.
11 · References

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.