# CVE-2024-23652: BuildKit possible host system access from mount stub cleaner

> A malicious Dockerfile or frontend can trick BuildKit into deleting files on the host system, potentially leading to privilege escalation or data loss.

- **Severity:** Critical 10.0 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:N/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 31 Jan 2024
- **Updated:** 17 Jun 2025
- **Also known as:** AZL-34086, AZL-35010, BELL-CVE-2024-23652, CLEANSTART-2025-VO24808, CLEANSTART-2026-LT94285, GHSA-4v98-7qmw-rqr8, GO-2024-2494, UBUNTU-CVE-2024-23652

## What is CVE-2024-23652?

CVE-2024-23652 is a critical path traversal vulnerability in moby buildkit, published on 31 Jan 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

BuildKit is a toolkit for converting source code to build artifacts in an efficient, expressive and repeatable manner. A malicious BuildKit frontend or Dockerfile using RUN --mount could trick the feature that removes empty files created for the mountpoints into removing a file outside the container, from the host system. The issue has been fixed in v0.12.5. Workarounds include avoiding using BuildKit frontends from an untrusted source or building an untrusted Dockerfile containing RUN --mount feature.

Weakness: CWE-22 (Improper Limitation of a Pathname to a Restricted Directory)

## Which versions are affected by CVE-2024-23652?

3 open source packages ship an affected version, including github.com/moby/buildkit. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/moby/buildkit` | Go | All versions | 0.12.5 |
| `github.com/moby/buildkit` | Go | All versions | 0.12.5 |
| `github.com/moby/buildkit` | Go | All versions | 0.12.5 |

Products: Mobyproject Buildkit.

## How do I fix CVE-2024-23652?

Upgrade github.com/moby/buildkit to 0.12.5 or later.

## Is CVE-2024-23652 being exploited?

There is no known exploitation of CVE-2024-23652 in the wild and no public exploit code.

Public exploit code:

- https://github.com/abian2/CVE-2024-23652 (github_poc): https://github.com/abian2/CVE-2024-23652
- Reproduction and verification of container-escape CVEs (CVE-2022-0492, CVE-2024-23652) in isolated Docker labs (github_poc): https://github.com/hgyc/CVE-stand

## Other vulnerabilities in moby buildkit

- [CVE-2024-23653](https://insights.sbomify.com/CVE-2024-23653/): BuildKit interactive containers API does not validate entitlements check (critical 9.8)
- [CVE-2024-23651](https://insights.sbomify.com/CVE-2024-23651/): BuildKit possible race condition with accessing subpaths from cache mounts (high 8.7)
- [CVE-2026-33747](https://insights.sbomify.com/CVE-2026-33747/): BuildKit vulnerable to malicious frontend causing file escape outside of storage root (high 8.4)
- [CVE-2026-33748](https://insights.sbomify.com/CVE-2026-33748/): BuildKit Git URL subdir component can cause access to restricted files (high 8.2)
- [CVE-2026-15789](https://insights.sbomify.com/CVE-2026-15789/): Malicious client can bypass destination directory validation on local sources upload (medium 6.9)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-23652 and fix it if it is affected.

What it is: CVE-2024-23652 is a critical path traversal vulnerability in moby buildkit, published on 31 Jan 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2024-23652 in the wild and no public exploit code.

Affected packages and fixed versions:
- github.com/moby/buildkit (Go): affected all versions; fixed in 0.12.5
- github.com/moby/buildkit (Go): affected all versions; fixed in 0.12.5
- github.com/moby/buildkit (Go): affected all versions; fixed in 0.12.5

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2024-23652/ (Markdown: https://insights.sbomify.com/CVE-2024-23652/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2024-23652
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2024-23652
- OSV: https://osv.dev/vulnerability/CVE-2024-23652

---
From sbomify Insights: https://insights.sbomify.com/CVE-2024-23652/
Summaries are generated and may contain mistakes; the official description above is the record.
