/

CVE-2026-15789

Severity:

HIGH RISK

(7.5)

Path Traversal (CWE-22) in BuildKit Upload Handling

CVE-2026-15789

Analyzed

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Filesystem Escape and Data Exposure

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A path traversal vulnerability in BuildKit's upload handling lets a custom client craft build requests that cause files to escape the BuildKit-controlled state directory.

When an attacker has valid or bypassed access to the BuildKit control API, they can abuse this flaw to interact with filesystem locations outside the intended sandbox, increasing the risk of data exposure or tampering.

A path traversal vulnerability in BuildKit's upload handling lets a custom client craft build requests that cause files to escape the BuildKit-controlled state directory.

When an attacker has valid or bypassed access to the BuildKit control API, they can abuse this flaw to interact with filesystem locations outside the intended sandbox, increasing the risk of data exposure or tampering.

Affected context

This vulnerability manifests in environments running BuildKit daemons that accept build instructions via the control API. It is relevant when clients can submit custom upload requests as part of build configurations and the daemon assumes these requests remain confined to a designated state directory. The issue arises in setups where authentication or authorization controls for the BuildKit API are weak, misconfigured, or shared broadly among automation tools and users, making it easier for a malicious or compromised client to exploit path handling logic.

This vulnerability manifests in environments running BuildKit daemons that accept build instructions via the control API. It is relevant when clients can submit custom upload requests as part of build configurations and the daemon assumes these requests remain confined to a designated state directory. The issue arises in setups where authentication or authorization controls for the BuildKit API are weak, misconfigured, or shared broadly among automation tools and users, making it easier for a malicious or compromised client to exploit path handling logic.

Exploit preconditions

  • Attack surface: BuildKit control API exposed to clients initiating builds
  • Required access: Ability to authenticate to, or otherwise successfully send build/upload requests to, the BuildKit daemon
  • Trigger point: Upload operations within a build request that reference file locations expected to be confined to the state directory
  • Why exploitation is possible: The daemon insufficiently validates or normalizes upload paths, allowing crafted requests to reference filesystem locations outside the controlled state directory via path traversal or similar mechanisms
  • Attack surface: BuildKit control API exposed to clients initiating builds
  • Required access: Ability to authenticate to, or otherwise successfully send build/upload requests to, the BuildKit daemon
  • Trigger point: Upload operations within a build request that reference file locations expected to be confined to the state directory
  • Why exploitation is possible: The daemon insufficiently validates or normalizes upload paths, allowing crafted requests to reference filesystem locations outside the controlled state directory via path traversal or similar mechanisms

Why this happens

The root cause aligns with CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'). BuildKit's upload logic trusts client-supplied paths or file references without enforcing strict confinement to the state directory. Directory traversal sequences or equivalent path manipulations can cause the effective file operations to escape the intended sandbox. Abstractly, this reflects a common bug pattern where server-side components fail to canonicalize and validate paths against a well-defined allowed base, permitting unintended reads or writes in broader filesystem scopes.

The root cause aligns with CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'). BuildKit's upload logic trusts client-supplied paths or file references without enforcing strict confinement to the state directory. Directory traversal sequences or equivalent path manipulations can cause the effective file operations to escape the intended sandbox. Abstractly, this reflects a common bug pattern where server-side components fail to canonicalize and validate paths against a well-defined allowed base, permitting unintended reads or writes in broader filesystem scopes.

Potential impact

  • Files outside the BuildKit state directory may be read or exposed
  • Build processes could modify or overwrite host files beyond the intended sandbox
  • Sensitive configuration or credentials stored near the daemon can be accessed or tampered with
  • Build outputs and artifacts may be poisoned by data pulled from uncontrolled filesystem locations
  • Local privilege boundaries on the host can be weakened if critical files are altered
  • Files outside the BuildKit state directory may be read or exposed
  • Build processes could modify or overwrite host files beyond the intended sandbox
  • Sensitive configuration or credentials stored near the daemon can be accessed or tampered with
  • Build outputs and artifacts may be poisoned by data pulled from uncontrolled filesystem locations
  • Local privilege boundaries on the host can be weakened if critical files are altered

General mitigation guidance

Effective mitigation centers on enforcing strict directory confinement and hardening BuildKit's control interface. Common defensive patterns include:

  • Implementing canonical path normalization and verifying that all upload-related paths are strictly within the designated state directory
  • Rejecting or sanitizing any client-supplied paths that contain traversal sequences or attempt to reference locations outside allowed directories
  • Applying robust authentication and fine-grained authorization controls on the BuildKit control API to restrict who can initiate custom builds and uploads
  • Running the BuildKit daemon with least-privilege filesystem access, limiting the set of directories the process can read or write
  • Segregating build infrastructure from sensitive host data, for example by using isolated volumes and avoiding co-location with critical configuration or secrets

Effective mitigation centers on enforcing strict directory confinement and hardening BuildKit's control interface. Common defensive patterns include:

  • Implementing canonical path normalization and verifying that all upload-related paths are strictly within the designated state directory
  • Rejecting or sanitizing any client-supplied paths that contain traversal sequences or attempt to reference locations outside allowed directories
  • Applying robust authentication and fine-grained authorization controls on the BuildKit control API to restrict who can initiate custom builds and uploads
  • Running the BuildKit daemon with least-privilege filesystem access, limiting the set of directories the process can read or write
  • Segregating build infrastructure from sensitive host data, for example by using isolated volumes and avoiding co-location with critical configuration or secrets

How teams detect issues like this

Organizations can detect and monitor for this class of issue through a combination of code-focused and operational techniques:

  • Use static analysis or manual code review to identify path handling logic that concatenates or trusts client-supplied paths without canonicalization and base-directory checks
  • Enforce development policies requiring path normalization and directory whitelisting for all filesystem operations initiated via remote APIs
  • Monitor BuildKit daemon logs for suspicious upload activity, such as unexpected path patterns or attempts to access directories outside the normal state directory
  • Integrate automated security review tools into CI workflows to flag potential path traversal patterns in build infrastructure components
  • Periodically perform configuration and exposure assessments on BuildKit endpoints to ensure that API access is restricted and authenticated

Organizations can detect and monitor for this class of issue through a combination of code-focused and operational techniques:

  • Use static analysis or manual code review to identify path handling logic that concatenates or trusts client-supplied paths without canonicalization and base-directory checks
  • Enforce development policies requiring path normalization and directory whitelisting for all filesystem operations initiated via remote APIs
  • Monitor BuildKit daemon logs for suspicious upload activity, such as unexpected path patterns or attempts to access directories outside the normal state directory
  • Integrate automated security review tools into CI workflows to flag potential path traversal patterns in build infrastructure components
  • Periodically perform configuration and exposure assessments on BuildKit endpoints to ensure that API access is restricted and authenticated

Sources

SourceLink
github.comgithub.com/moby/buildkit/security/advisories/GHSA-g2h8-426c-7976

Frequently asked

questions

Exploitation is limited to environments where an attacker can act as a BuildKit client. If the control API is exposed and they can authenticate or bypass protections, they can craft malicious upload requests to escape the state directory.

The attacker must be able to send build or upload requests to the BuildKit daemon, typically requiring valid credentials or a misconfigured/authentication-bypassed control API. Without such access, they cannot trigger the vulnerable path handling.

Enforce strict path validation and confinement for all upload operations: normalize paths, check them against a defined state directory, and reject any request that attempts to escape this boundary. Combine this with hardened API authentication and least-privilege filesystem permissions.

Adopt secure path handling practices as a standard: treat all remote or client-supplied paths as untrusted, normalize and validate them against explicit allowlists, design build infrastructure with strong sandbox isolation, and regularly review control APIs for proper authentication and authorization.

Exploitation is limited to environments where an attacker can act as a BuildKit client. If the control API is exposed and they can authenticate or bypass protections, they can craft malicious upload requests to escape the state directory.

The attacker must be able to send build or upload requests to the BuildKit daemon, typically requiring valid credentials or a misconfigured/authentication-bypassed control API. Without such access, they cannot trigger the vulnerable path handling.

Enforce strict path validation and confinement for all upload operations: normalize paths, check them against a defined state directory, and reject any request that attempts to escape this boundary. Combine this with hardened API authentication and least-privilege filesystem permissions.

Adopt secure path handling practices as a standard: treat all remote or client-supplied paths as untrusted, normalize and validate them against explicit allowlists, design build infrastructure with strong sandbox isolation, and regularly review control APIs for proper authentication and authorization.

Find out what's already
exploitable in your codebase.