VYPR
Medium severity6.1GHSA Advisory· Published May 18, 2026· Updated May 18, 2026

Docker: Race condition in docker cp allows creation of arbitrary empty files on the host via symlink swap

CVE-2026-41568

Description

Summary

A race condition during docker cp mount setup allows a malicious container to create empty files or directories at arbitrary absolute paths on the host filesystem.

This advisory covers the race during mountpoint creation. The related race during the subsequent mount syscall is tracked in GHSA-rg2x-37c3-w2rh

Details

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 path is first resolved within the container's root filesystem using GetResourcePath, and then used to create the mountpoint (file or directory) if it does not already exist via createIfNotExists.

Between path resolution and mountpoint creation, a process running inside the container can swap a path component for a symlink pointing to an arbitrary location on the host. Because createIfNotExists operates on the already-resolved absolute path using standard os.MkdirAll and os.OpenFile — which follow symlinks in intermediate path components — the symlink is followed and the file or directory is created outside the container root filesystem, as root.

Impact

A malicious container can create empty files or directories at arbitrary absolute paths on the host filesystem, running as root. This enables persistent denial of service — for example:

  • Converting /etc/docker/daemon.json into a directory prevents the daemon from restarting
  • Creating /etc/nologin prevents user logins
  • Overwriting critical system paths with empty files can break host services

The container does not gain read or write access to existing host files — only the ability to create new empty files or directories at chosen paths.

Conditions for exploitation

  • A container must be running with a process that can rapidly create and swap symlinks at a volume mount destination path.
  • An operator must initiate a docker cp into that container, or call the PUT /containers/{id}/archive or HEAD /containers/{id}/archive API endpoints.

Not affected

  • Containers that do not have volume mounts are not affected, as the race occurs during volume bind-mount setup.

Patches

Mountpoint creation is now scoped to the container root using os.Root (Go 1.24+), which refuses to follow symlinks that escape the opened root directory. All filesystem operations in createIfNotExists (MkdirAll, OpenFile) are performed through the os.Root handle, so even if a symlink swap occurs after path resolution, the creation stays confined to the container root.

Workarounds

  • Only run containers from trusted images.
  • Avoid using docker cp with untrusted running containers.
  • Use authorization plugins to restrict access to the archive API endpoints (PUT /containers/{id}/archive, HEAD /containers/{id}/archive).

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

A race condition in `docker cp` allows a malicious container to create empty files/directories at arbitrary host paths as root, enabling denial of service.

Vulnerability

CVE-2026-41568 is a race condition that occurs during the docker cp mount setup. When copying files into a container, the Docker daemon resolves the destination path within the container's root filesystem using GetResourcePath and then creates the mountpoint if it does not exist via createIfNotExists. A race window exists between path resolution and mountpoint creation, where a malicious process inside the container can replace a path component with a symlink pointing to an arbitrary host location [1][2].

Exploitation

An attacker must have a running container with a process capable of rapidly creating and swapping symlinks at a volume mount destination path. The exploitation is triggered when an operator initiates a docker cp into that container or calls the PUT /containers/{id}/archive or HEAD /containers/{id}/archive API endpoints [1][2].

Impact

If exploited, the container can create empty files or directories anywhere on the host filesystem as root. This does not allow reading or writing existing files, but can cause persistent denial of service by, for example, converting /etc/docker/daemon.json into a directory to prevent the daemon from restarting, creating /etc/nologin to block user logins, or overwriting critical system paths with empty files [1][2].

Mitigation

Users should apply security patches from Docker as soon as they become available. The advisory notes that containers running without the ability to create symlinks rapidly at the mount destination path are not affected [1][2].

AI Insight generated on May 18, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.

Affected products

1

Patches

0

No patches discovered yet.

Vulnerability mechanics

AI mechanics synthesis has not run for this CVE yet.

References

2

News mentions

0

No linked articles in our index yet.