Building an image runs commands, resolves a context, and caches intermediate results, all on a build host that frequently has more access than the eventual runtime: registry credentials, cloud roles for pushing, and the source repository. Two problems follow. Secrets supplied to the build leak into the image or cache where they can be recovered later. And the build tooling itself, BuildKit and the daemon, processes an attacker-influenced Dockerfile and context, so flaws there read host files or execute on the build host.
docker version | grep -i buildkit # BuildKit frontend in use
env | grep -iE 'BUILD|REGISTRY|AWS|GITHUB_TOKEN' # build-host credentials worth stealing
Subtopics#
- Build-arg secret leak: secrets passed as build arguments persisting in the image.
- BuildKit RCE: crafted builds reading outside the context or executing on the build host.