Summary
A crafted message sent to BuildKit's low-level build API can cause file deletion operations intended for the container root filesystem to affect the host's /tmp directory.
When build actions are allowed to manipulate paths without adequate isolation, an attacker can potentially remove host temporary files and disrupt workloads relying on them.
A crafted message sent to BuildKit's low-level build API can cause file deletion operations intended for the container root filesystem to affect the host's /tmp directory.
When build actions are allowed to manipulate paths without adequate isolation, an attacker can potentially remove host temporary files and disrupt workloads relying on them.
Affected context
This vulnerability occurs in environments using BuildKit's low-level build API to orchestrate filesystem operations inside build containers.
It is relevant where builds are run on hosts that expose container file manipulation actions and where the build engine does not strictly constrain which filesystem paths can be affected.
Systems that rely heavily on /tmp for runtime data, temporary secrets, or inter-process communication are particularly exposed when those paths are not adequately isolated from build operations.
This vulnerability occurs in environments using BuildKit's low-level build API to orchestrate filesystem operations inside build containers.
It is relevant where builds are run on hosts that expose container file manipulation actions and where the build engine does not strictly constrain which filesystem paths can be affected.
Systems that rely heavily on /tmp for runtime data, temporary secrets, or inter-process communication are particularly exposed when those paths are not adequately isolated from build operations.
Exploit preconditions
- Attack surface: BuildKit low-level build API exposed to callers (e.g., CI systems, orchestrators, custom tooling).
- Required access: Ability to submit or influence low-level build messages or instructions consumed by BuildKit.
- Trigger point: Execution of a filesystem-deletion action intended for the container rootfs that is crafted to escape to the host /tmp directory.
- Why exploitation is possible: The build API allows operations that are insufficiently constrained to the container's filesystem, enabling path semantics or environment handling that reach the host /tmp directory instead of remaining within the container rootfs.
- Attack surface: BuildKit low-level build API exposed to callers (e.g., CI systems, orchestrators, custom tooling).
- Required access: Ability to submit or influence low-level build messages or instructions consumed by BuildKit.
- Trigger point: Execution of a filesystem-deletion action intended for the container rootfs that is crafted to escape to the host /tmp directory.
- Why exploitation is possible: The build API allows operations that are insufficiently constrained to the container's filesystem, enabling path semantics or environment handling that reach the host /tmp directory instead of remaining within the container rootfs.
Why this happens
The underlying bug class maps to CWE-22: Improper Limitation of a Path to a Restricted Directory (Path Traversal).
BuildKit's low-level API exposes filesystem operations that are expected to be confined to the container root filesystem, but the implementation fails to enforce strict directory boundaries and isolation for certain delete actions.
As a result, a crafted message can cause path resolution or environment handling to target the host /tmp directory, allowing deletion beyond the intended restricted path scope.
The underlying bug class maps to CWE-22: Improper Limitation of a Path to a Restricted Directory (Path Traversal).
BuildKit's low-level API exposes filesystem operations that are expected to be confined to the container root filesystem, but the implementation fails to enforce strict directory boundaries and isolation for certain delete actions.
As a result, a crafted message can cause path resolution or environment handling to target the host /tmp directory, allowing deletion beyond the intended restricted path scope.
Potential impact
- Deletion of files and directories in the host /tmp path.
- Disruption of applications and services relying on temporary files for normal operation.
- Interruption of running builds, CI jobs, or background services that use /tmp for state or IPC.
- Possible loss of diagnostic logs or temporary security artifacts stored in /tmp.
- Deletion of files and directories in the host /tmp path.
- Disruption of applications and services relying on temporary files for normal operation.
- Interruption of running builds, CI jobs, or background services that use /tmp for state or IPC.
- Possible loss of diagnostic logs or temporary security artifacts stored in /tmp.
General mitigation guidance
Effective mitigation focuses on tightening filesystem boundaries and reducing trust in build instructions.
Common defensive patterns include:
- Enforcing strict path confinement so that build actions can only affect directories explicitly scoped to the container rootfs.
- Implementing robust validation and normalization of paths used in file operations, rejecting any that resolve outside the intended sandbox.
- Running the build engine with minimized privileges and leveraging dedicated, isolated temporary directories rather than the host-wide /tmp.
- Treating build definitions and low-level instructions as untrusted input and restricting which filesystem actions are allowed from them.
Effective mitigation focuses on tightening filesystem boundaries and reducing trust in build instructions.
Common defensive patterns include:
- Enforcing strict path confinement so that build actions can only affect directories explicitly scoped to the container rootfs.
- Implementing robust validation and normalization of paths used in file operations, rejecting any that resolve outside the intended sandbox.
- Running the build engine with minimized privileges and leveraging dedicated, isolated temporary directories rather than the host-wide /tmp.
- Treating build definitions and low-level instructions as untrusted input and restricting which filesystem actions are allowed from them.
How teams detect issues like this
Detection typically involves a combination of runtime monitoring and code-level controls:
- Monitoring build hosts for unusual or bulk deletions in /tmp correlated with BuildKit activity.
- Enforcing policies that restrict which low-level build operations are allowed, with logging for any attempts to access host paths.
- Using static analysis or configuration review to identify unsafe filesystem APIs or path-handling logic in the build orchestration layer.
- Reviewing CI/CD and automation scripts for direct use of low-level BuildKit actions that manipulate paths without clear sandbox boundaries.
Detection typically involves a combination of runtime monitoring and code-level controls:
- Monitoring build hosts for unusual or bulk deletions in /tmp correlated with BuildKit activity.
- Enforcing policies that restrict which low-level build operations are allowed, with logging for any attempts to access host paths.
- Using static analysis or configuration review to identify unsafe filesystem APIs or path-handling logic in the build orchestration layer.
- Reviewing CI/CD and automation scripts for direct use of low-level BuildKit actions that manipulate paths without clear sandbox boundaries.
Sources
| Source | Link |
|---|---|
| github. | github.com/ |

