CVE-2024-23651
moby/buildkit: possible race condition with accessing subpaths from cache mounts
Severity
ModerateRed Hat Product Security
CVSS 3.1
Review impact separately from score.
Published · January 31, 2024
Updated · November 1, 2026
Description
A race condition issue was found in the Moby Builder Toolkit, stemming from a time-of-check/time-of-use (TOCTOU) vulnerability during cache volume mounting at container build time. Concurrent execution of two malicious build steps, sharing the same cache mounts with subpaths, may result in files from the host system being accessible to the build container. Successful exploitation could lead to a container escape to the underlying host OS when building an image using a malicious Dockerfile or upstream image (for example, when using FROM).
Statement
This vulnerability can only be exploited when two containers are being built in parallel within the same cache directory. A concurrent running build that has the target cache directory mounted, needs to replace the target directory with a symbolic link between the time it is checked and actually used. As there is an unpredictable race condition, this issue is difficult to exploit. Therefore it is rated as having Moderate severity.
CVSS score applicability
The CVSS score(s) listed for this vulnerability do not reflect the associated product's status, and are included for informational purposes to better understand the severity of this vulnerability.
Mitigation
Do not use BuildKit frontends or Dockerfiles from untrusted sources.
CVSS / CWE
CVSS 3.1 · 7.5CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:N
CWE-362 · Concurrent Execution using Shared Resource with Improper Synchronization