CVE-2024-24557: Moby classic builder cache poisoning
Moby could provide weaker than expected security, caused by improper cache validation in the classic builder cache system. By persuading a victim to open a specially crafted file, a remote attacker could exploit this vulnerability to conduct a cache poisoning attack.
Other sources
Moby is an open-source project created by Docker to enable software containerization. The classic builder cache system is prone to cache poisoning if the image is built FROM scratch. Also, changes to some instructions (most important being HEALTHCHECK and ONBUILD) would not cause a cache miss. An attacker with the knowledge of the Dockerfile someone is using could poison their cache by making them pull a specially crafted image that would be considered as a valid cache candidate for some build steps. 23.0+ users are only affected if they explicitly opted out of Buildkit (DOCKERBUILDKIT=0 environment variable) or are using the /build API endpoint. All users on versions older than 23.0 could be impacted. Image build API endpoint (/build) and ImageBuild function from github.com/docker/docker/client is also affected as it the uses classic builder by default. Patches are included in 24.0.9 and 25.0.2 releases.
— NVD
The classic builder cache system is prone to cache poisoning if the image is built FROM scratch. Also, changes to some instructions (most important being HEALTHCHECK and ONBUILD) would not cause a cache miss.
An attacker with the knowledge of the Dockerfile someone is using could poison their cache by making them pull a specially crafted image that would be considered as a valid cache candidate for some build steps.
For example, an attacker could create an image that is considered as a valid cache candidate for: FROM scratch MAINTAINER Pawel
when in fact the malicious image used as a cache would be an image built from a different Dockerfile.
In the second case, the attacker could for example substitute a different HEALTCHECK command.
Impact
23.0+ users are only affected if they explicitly opted out of Buildkit (DOCKERBUILDKIT=0 environment variable) or are using the /build API endpoint (which uses the classic builder by default).
All users on versions older than 23.0 could be impacted. An example could be a CI with a shared cache, or just a regular Docker user pulling a malicious image due to misspelling/typosquatting.
Image build API endpoint (/build) and ImageBuild function from github.com/docker/docker/client is also affected as it the uses classic builder by default.
Patches
Patches are included in Moby releases:
- v25.0.2 - v24.0.9 - v23.0.10
Workarounds
- Use --no-cache or use Buildkit if possible (DOCKERBUILDKIT=1, it's default on 23.0+ assuming that the buildx plugin is installed). - Use Version = types.BuilderBuildKit or NoCache = true in ImageBuildOptions for ImageBuild call.
— GitHub
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
go/github.com/moby/mobyto a version that resolves this vulnerability.Fixed in 25.0.2 - Upgrade
Upgrade
go/github.com/moby/mobyto a version that resolves this vulnerability.Fixed in 24.0.9 - Upgrade
Upgrade
go/github.com/docker/dockerto a version that resolves this vulnerability.Fixed in 24.0.9 - Upgrade
Upgrade
go/github.com/docker/dockerto a version that resolves this vulnerability.Fixed in 25.0.2 - Upgrade
Upgrade
redhat/mobyto a version that resolves this vulnerability.Fixed in 25.0.2 - Upgrade
Upgrade
redhat/mobyto a version that resolves this vulnerability.Fixed in 24.0.9 - Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 23.0.10 - Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 24.0.9 - Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 25.0.2 - Configuration
Ensure Buildkit is used for Docker builds (do not set DOCKER_BUILDKIT=0). This addresses classic builder cache poisoning exposed via the /build API endpoint (classic builder by default) and ImageBuild calls that use the classic builder.
Docker image build (classic builder via /build API or ImageBuild) BuildKit = DOCKER_BUILDKIT=1 (and ensure buildx plugin is installed) - Configuration
If Buildkit cannot be used, disable build caching by using '--no-cache' or setting 'NoCache = true' in ImageBuildOptions for the ImageBuild call.
Docker image build Cache usage = --no-cache or NoCache=true - Configuration
Use 'Version = types.BuilderBuildKit' in ImageBuildOptions for the ImageBuild call to avoid the classic builder and its cache poisoning risk.
Docker image build (github.com/docker/docker/client ImageBuild) ImageBuildOptions.BuilderBuildKit = types.BuilderBuildKit
Event History
Frequently Asked Questions
What is the severity of CVE-2024-24557?
CVE-2024-24557 is classified based on its potential impact on system integrity and security.
How do I fix CVE-2024-24557?
To mitigate CVE-2024-24557, upgrade to Moby version 25.0.2 or 24.0.9 as soon as possible.
What are the affected versions for CVE-2024-24557?
CVE-2024-24557 affects Moby versions prior to 25.0.2 and Docker versions prior to 24.0.9.
What types of vulnerabilities does CVE-2024-24557 involve?
CVE-2024-24557 involves cache poisoning and issues with certain Dockerfile instructions like HEALTHCHECK and ONBUILD.
Is CVE-2024-24557 specific to certain software?
Yes, CVE-2024-24557 specifically impacts the Moby and Docker software containerization projects.