CVE-2026-42574: apko dirFS has a symlink-following path traversal that allows multiple entry points to escape the build root
A crafted .apk could install a TypeSymlink tar entry whose target pointed outside the build root, and a subsequent directory-creation or file-write entry in the same or later archive could traverse that symlink to reach host paths the build user could write to. The root cause was the sanitizePath helper in pkg/apk/fs/rwosfs.go, which rejected only lexical .. traversal and did not resolve or refuse symlinks. Every disk-backed DirFS method that handed its caller-supplied path to a symlink-following stdlib call — ReadFile, WriteFile, Chmod, Chown, Chtimes, MkdirAll, Mkdir, and Mknod — was affected. The reachable primitive from a malicious APK during tar extraction is the MkdirAll / Mkdir / WriteFile chain via apko build-cpio and disk-backed consumers such as melange; the remaining sinks are reachable by direct callers of the pkg/apk/fs package. The in-memory tarfs install path used by apko build, apko publish, and apko build-minirootfs is not affected.
References
- github.com/advisories/GHSA-qq3r-w4hj-gjp6
- github.com/chainguard-dev/apko
- github.com/chainguard-dev/apko/commit/f5a96e1299ac81c7ea9441705ec467688086f442
- github.com/chainguard-dev/apko/pull/2187
- github.com/chainguard-dev/apko/releases/tag/v1.2.5
- github.com/chainguard-dev/apko/security/advisories/GHSA-qq3r-w4hj-gjp6
- nvd.nist.gov/vuln/detail/CVE-2026-42574
Code Behaviors & Features
Detect and mitigate CVE-2026-42574 with GitLab Dependency Scanning
Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →