/

CVE-2026-33747

Severity:

HIGH RISK

(8.4)

Path Traversal in BuildKit Custom Frontends Allowing File

CVE-2026-33747

Analyzed

Vulnerability type

Category:

Path Traversal / Directory Traversal

CWE:

CWE-22

Impact:

Arbitrary File Write Outside Expected Directory Boundaries

Severity:

HIGH RISK

(8.4)

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 issue in BuildKit allows a malicious custom frontend to craft API requests that write files outside the BuildKit state directory associated with the build execution context.

If a build uses an untrusted frontend specified via #syntax or --build-arg BUILDKIT_SYNTAX, this behavior can be abused to overwrite or create files on the host or in adjacent directories, breaking build isolation and integrity guarantees.

Affected context

This vulnerability occurs in BuildKit environments that:

  • Allow use of custom or third-party BuildKit frontends, and
  • Accept frontend selection via #syntax directives in Dockerfiles or the --build-arg BUILDKIT_SYNTAX option, and
  • Do not fully trust the selected frontend image.

The issue manifests when the frontend crafts specific API messages that cause BuildKit to resolve and write files outside the intended state directory used for a given build context, potentially impacting host or neighboring directories depending on deployment.

Exploit preconditions

  • Attack surface: Build workloads running through BuildKit where frontend selection is user-controlled or influenced by untrusted sources.
  • Required access: Ability to choose or control the BuildKit frontend image via #syntax in the Dockerfile or --build-arg BUILDKIT_SYNTAX at build time (e.g., commit access, CI configuration control, or build command execution).
  • Trigger point: Execution of a crafted frontend that issues specially formed API calls directing BuildKit to place files at paths that escape the state directory.
  • Why exploitation is possible: BuildKit did not sufficiently constrain or normalize file paths derived from frontend API messages, allowing directory traversal outside the designated state directory for the build execution context.

Why this happens

The underlying issue is inadequate validation and normalization of file paths derived from frontend-controlled input within BuildKit's internal APIs.

A custom frontend can specify paths that include traversal sequences or otherwise manipulate how BuildKit resolves output locations, causing writes to escape the intended state directory.

This aligns with CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where insufficient enforcement of directory boundaries permits access to filesystem locations that should remain out of scope for the component.

Potential impact

  • A malicious frontend may write or overwrite files outside the BuildKit state directory used for the build.
  • Build isolation guarantees can be weakened, potentially affecting host files or shared volumes depending on the deployment configuration.
  • Build outputs or intermediate artifacts can be tampered with, impacting supply-chain integrity.
  • Sensitive configuration files or scripts used by the build environment may be modified, enabling follow-on compromise or persistence in CI/CD systems.

General mitigation guidance

Effective mitigation focuses on reducing trust in arbitrary frontends and tightening filesystem boundaries:

  • Prefer vetted, well-known frontend images (such as maintained official Docker or BuildKit frontends) and avoid unreviewed or community-provided images in sensitive environments.
  • Restrict who can modify Dockerfiles, #syntax directives, and CI/CD build configurations to limit exposure to untrusted frontends.
  • Enforce policy that disallows or centrally controls the use of --build-arg BUILDKIT_SYNTAX in automated pipelines.
  • Run BuildKit builds with least-privilege filesystem access, limiting the host paths and volumes the builder can influence, and separating build state from critical host directories.
  • Apply configuration hardening around build executors to treat frontend input as untrusted and avoid giving builds unnecessary access to host resources.

How teams detect issues like this

Organizations can detect and monitor for this class of issue through:

  • Static review of Dockerfiles and build scripts for unapproved #syntax directives or BUILDKIT_SYNTAX arguments, enforced via code review policies or pre-commit hooks.
  • CI/CD policy checks that allow only an approved list of frontend images and block builds that deviate from those lists.
  • Runtime logging and monitoring of BuildKit behavior to flag unusual file writes outside expected state directories or into sensitive filesystem paths.
  • Use of security scanning and analysis tools that understand BuildKit configurations and can highlight potentially dangerous frontend selection or filesystem exposure patterns.

Sources

SourceLink
github.comgithub.com/moby/buildkit/releases/tag/v0.28.1
github.comgithub.com/moby/buildkit/security/advisories/GHSA-4c29-8rgm-jvjj

Frequently asked

questions

It can be, if an attacker can influence Dockerfiles, build configuration, or build arguments remotely—for example through a compromised repository, pull request, or misconfigured CI pipeline that accepts untrusted code. The exploitation path is through build configuration rather than a direct network endpoint.

The attacker needs the ability to select or control a BuildKit frontend, typically by editing the #syntax directive in a Dockerfile or setting --build-arg BUILDKIT_SYNTAX in build commands or CI configuration. Without this control, the vulnerability cannot be directly triggered.

The safest pattern is to enforce strict whitelisting of trusted frontends and ensure BuildKit enforces directory boundaries when handling paths from frontend APIs. Additionally, treat build frontends as untrusted code by default and minimize the filesystem scope that BuildKit can affect.

Future prevention relies on a combination of secure design and process controls: rigorously validate and normalize all filesystem paths derived from external or pluggable components; sandbox build operations with clear directory boundaries; lock down who can configure frontends; and integrate policy checks and automated reviews so that unexpected frontend usage is caught before reaching production build pipelines.

Find out what's already
exploitable in your codebase.