Skip to main content
Vulnerability Database/CVE-2026-28406

CVE-2026-28406: kaniko Path Traversal Vulnerability

CVE-2026-28406 is a path traversal vulnerability in kaniko that allows attackers to write files outside the intended directory, potentially achieving code execution. This article covers technical details, affected versions, and mitigation.

Published:

CVE-2026-28406 Overview

CVE-2026-28406 is a path traversal vulnerability affecting kaniko, a widely-used tool for building container images from Dockerfiles inside containers or Kubernetes clusters. The vulnerability exists in versions 1.25.4 through 1.25.9 and allows attackers to write files outside the intended destination directory during build context archive extraction.

The flaw stems from improper path validation when unpacking build context archives. Kaniko uses filepath.Join(dest, cleanedName) without enforcing that the final resolved path remains within the designated destination directory. This allows malicious tar entries containing path components like ../outside.txt to escape the extraction root and write arbitrary files to locations outside the intended directory.

Critical Impact

When combined with registry authentication configurations, this path traversal vulnerability can be chained with Docker credential helpers to achieve code execution within the kaniko executor process, potentially compromising the entire CI/CD pipeline.

Affected Products

  • kaniko versions 1.25.4 through 1.25.9
  • Kubernetes environments using vulnerable kaniko executor images
  • CI/CD pipelines leveraging kaniko for container image builds

Discovery Timeline

  • 2026-02-27 - CVE-2026-28406 published to NVD
  • 2026-03-02 - Last updated in NVD database

Technical Details for CVE-2026-28406

Vulnerability Analysis

This path traversal vulnerability (CWE-22) occurs during the extraction of build context archives in kaniko. The vulnerability is exploitable over the network without authentication, making it particularly dangerous in automated CI/CD environments where kaniko processes untrusted build contexts.

The exploitation chain becomes especially severe in environments with configured registry authentication. Attackers can leverage the arbitrary file write capability to overwrite Docker credential helper configurations or binaries, which are subsequently executed by the kaniko process during registry authentication. This transforms a file write primitive into full code execution within the executor context.

The vulnerability requires no user interaction and has low attack complexity, making it an attractive target for supply chain attacks against container build infrastructure.

Root Cause

The root cause lies in insufficient path validation during tar archive extraction. The kaniko code uses Go's filepath.Join() function to construct destination paths for extracted files. However, filepath.Join() does not prevent path traversal when the joined path component contains directory traversal sequences like ../.

When processing a tar entry with a malicious name such as ../../../etc/malicious.conf, the filepath.Join(dest, cleanedName) call produces a path that escapes the intended extraction directory. Without subsequent validation to ensure the resolved path remains within the destination boundary, the file is written to the attacker-controlled location.

Attack Vector

The attack is initiated over the network by supplying a maliciously crafted build context archive to a kaniko build process. An attacker can construct a tar archive containing entries with path traversal sequences in their filenames.

When kaniko extracts this archive during the build context setup phase, the malicious tar entries cause files to be written outside the designated extraction directory. In environments where kaniko is configured with registry authentication, an attacker can:

  1. Craft a tar archive with a file entry targeting Docker credential helper locations
  2. Supply this archive as a build context to kaniko
  3. Overwrite credential helper binaries or configuration files
  4. Trigger registry authentication, causing execution of attacker-controlled code

The vulnerability can be exploited to compromise build infrastructure, inject malicious content into container images, or steal registry credentials.

Detection Methods for CVE-2026-28406

Indicators of Compromise

  • Unexpected files appearing outside kaniko build context directories
  • Modified Docker credential helper binaries or configurations
  • Anomalous file system activity during kaniko build processes
  • Tar archives containing entries with ../ path sequences in build contexts

Detection Strategies

  • Monitor file system operations during kaniko builds for writes outside expected directories
  • Implement integrity checking on Docker credential helper binaries and configuration files
  • Scan incoming build context archives for path traversal sequences before processing
  • Enable audit logging for kaniko executor processes to capture file operations

Monitoring Recommendations

  • Deploy file integrity monitoring (FIM) on critical credential helper paths
  • Implement network monitoring for unusual egress traffic from build infrastructure
  • Configure alerting for kaniko processes attempting to write files outside designated directories
  • Review build logs for errors or warnings related to path resolution during extraction

How to Mitigate CVE-2026-28406

Immediate Actions Required

  • Upgrade kaniko to version 1.25.10 or later immediately
  • Audit existing build infrastructure for signs of exploitation
  • Review and rotate registry credentials if compromise is suspected
  • Implement network segmentation to limit build infrastructure access

Patch Information

The vulnerability has been fixed in kaniko version 1.25.10. The fix implements secure path resolution using the securejoin library for tar extraction, which properly prevents path traversal attacks by ensuring extracted file paths cannot escape the destination directory.

For detailed technical information about the fix, see the GitHub Security Advisory, the pull request implementing the fix, and the specific commit with the securejoin implementation.

Workarounds

  • Restrict network access to kaniko build infrastructure to trusted sources only
  • Implement input validation on build context archives to reject entries containing path traversal sequences
  • Run kaniko executors in isolated environments with minimal file system permissions
  • Disable or remove Docker credential helpers if registry authentication is not required
bash
# Configuration example
# Validate tar archives for path traversal before use with kaniko
# This script checks for malicious path sequences in tar entries
tar -tzf build-context.tar.gz | grep -E '(^|/)\.\.(/|$)' && echo "WARNING: Path traversal detected" || echo "Archive appears safe"

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.