CVE-2024-24557: Moby vulnerable to classic builder cache poisoning
Summary
CVE-2024-24557: Classic builder cache poisoning. Affects github.com/docker/docker across 2 version ranges.
< 24.0.9
>= 25.0.0, < 25.0.2
Fixed in 24.0.9 or 25.0.2, depending on the release line you run. How to fix ↓
Also tracked for
- docker.io · Debian:11
The same CVE-2024-24557 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
Moby is an open-source project that provides a platform for building, packaging, and distributing containerized applications. It is written in Go and is widely used in the Docker ecosystem. Moby allows users to create and manage containers using Dockerfiles, which are text files that contain a set of instructions for building an image. These instructions are executed by the Moby builder, which is responsible for pulling base images, running commands, and creating the final image. However, the classic builder cache system in Moby is susceptible to cache poisoning if the image is built 'FROM scratch'. This vulnerability can be exploited by an attacker to poison the cache and potentially execute malicious code during the build process.
Vulnerability Detail
The classic builder cache system in Moby is vulnerable to cache poisoning if the image is built 'FROM scratch'. This means that an attacker with knowledge of the Dockerfile being used could create a specially crafted image that would be considered a valid cache candidate for certain build steps. For example, an attacker could create an image that appears to be built 'FROM scratch' and has a valid cache candidate for the 'MAINTAINER' instruction. However, the malicious image used as a cache would actually be built from a different Dockerfile. Additionally, certain instructions like 'HEALTHCHECK' and 'ONBUILD' would not cause a cache miss, allowing an attacker to substitute a different 'HEALTHCHECK' command. This vulnerability affects Moby versions 23.0 and above if the user has opted out of Buildkit or is using the '/build' API endpoint. Users on versions older than 23.0 could also be impacted, such as those using a shared cache or pulling a malicious image due to misspelling or typosquatting.
How To Fix
Latest published version: v28.5.2+incompatible as of 22 Oct 2026
go get github.com/docker/docker@v28.5.2+incompatible
Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.
If you can't move to the latest
The minimum fixed version depends on the release line you run.
-
< 24.0.924.0.9go get github.com/docker/docker@v24.0.9 -
>= 25.0.0, < 25.0.225.0.2go get github.com/docker/docker@v25.0.2
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
If updating to the latest Moby releases or using Buildkit is not feasible, users can use the '--no-cache' flag when building images to bypass the cache and ensure that all instructions are executed. This can be done by running the following command:
docker build --no-cache .
Conclusion
The classic builder cache system in Moby is vulnerable to cache poisoning, which can be exploited by an attacker to execute malicious code during the build process. Users should update to the latest Moby releases or use the '--no-cache' flag when building images to mitigate this vulnerability. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for github.com/docker/docker →
FAQ
Moby is an open-source project that provides a platform for building, packaging, and distributing containerized applications. It is widely used in the Docker ecosystem and is written in Go.
Cache poisoning is a technique used by attackers to manipulate the contents of a cache in order to execute malicious code or perform unauthorized actions.
Users of Moby versions 23.0 and above are affected if they have opted out of Buildkit or are using the '/build' API endpoint. Users on older versions could also be impacted. This vulnerability allows an attacker to poison the cache and potentially execute malicious code during the build process.
To fix this vulnerability, users should update to the latest Moby releases (v25.0.2 or v24.0.9) or use the '--no-cache' flag when building images. Alternatively, users can switch to using Buildkit by setting the 'DOCKER_BUILDKIT=1' environment variable.
Yes, if updating to the latest Moby releases or using Buildkit is not feasible, users can use the '--no-cache' flag when building images to bypass the cache and ensure that all instructions are executed.
References
Related vulnerabilities
Recent vulnerabilities recorded for github.com/docker/docker.