GitHub advisory · Go
Docker: Race condition in docker cp allows bind mount redirection to host path
Go
What it fixes
A race condition during docker cp mount setup allows a malicious container to redirect a bind mount target to an arbitrary host path, potentially overwriting host files or causing denial of service.
When copying files into a container, the daemon sets up a temporary filesystem view by bind-mounting volumes into a private mount namespace. During this setup, the mount destination is created inside the container root and then a bind mount is attached using the container-relative path resolved to an absolute host path.
Between mountpoint creation and the mount() syscall, a process running inside the container can replace the destination (or a parent path component) with a symlink pointing to an arbitrary location on the host. The mount() syscall follows the symlink, causing the volume to be bind-mounted onto an arbitrary host path instead of the intended container path.
A malicious container can redirect a volume bind mount to an arbitrary host path. The impact depends on the volume content and mount options:
docker cp completes), but the effects of any writes persist.docker cp into that container, or call the PUT /containers/{id}/archive or HEAD /containers/{id}/archive API endpoints.Manual fix · Go
go get github.com/moby/moby/v2@v2.0.0-beta.14Sources