docker cp flaw lets a container write files onto the host
In short
- Imperva's Red Team found that docker cp, the Docker command that copies a file out of a container, can be tricked by a malicious container into writing files anywhere the person running the command can write. The flaw is tracked as CVE-2026-17106 and nicknamed CopyEscape.
- On a Mac the attacker's code can run as the logged-in user; on Linux it can run as root when docker cp is run with elevated rights (for example sudo docker cp), by overwriting the runc program that starts containers.
- Imperva says the fix is Docker Engine and CLI 29.7.2 or later and Docker Desktop 4.86.0 or later. Docker Sandboxes 0.38.0, released on 6 August 2026, fixes the sbx cp variant. Check Docker's own advisory for your version; we did not read it.
- Imperva published the write-up on 10 August 2026, after reporting the bug to Docker on 11 April and agreeing several delays so that disclosure matched a usable patch.
CVE-2026-17106 the flaw's identifier; 29.7.2 Docker Engine/CLI fixed version, per Imperva; 4.86.0 Docker Desktop fixed version, per Imperva; 0.38.0 Docker Sandboxes release with the sbx cp fix
What does docker cp do, and why can it be abused?
The command looks harmless: docker cp container:/path/to/file.txt ./file.txt. The expectation is that Docker writes to ./file.txt and nowhere else.
But it is not a direct file copy. Imperva explains that the Docker daemon (the background service) walks the container's live files and packs the chosen path into a tar archive, a single stream that bundles files, folders and links. The Docker command-line tool (CLI) on your machine then unpacks it. So the container controls what is in the archive, while the unpacking runs with your permissions.
For that to be safe, two things must hold: the archive must be consistent, and every unpacked item must stay inside the destination. Imperva says it broke both in one copy.
How the attack works
Step 2 is a race condition: the container changes the file between the daemon's two looks at it. Imperva says Docker locks its own bookkeeping while reading, but that does not stop programs inside the container. To win the race reliably, its proof of concept places a large file just before the target and watches for the daemon opening it, then does the two renames.
Step 4 is the second flaw. Imperva says the containment check validated a path built with filepath.Join, while the symlink was created from the archive's original link target. "The check approves one path. The filesystem creates another."
What can an attacker reach?
Imperva says the result is a file create-or-overwrite within the permissions of whoever ran docker cp. The container does not gain root from the Docker daemon, and someone or something must run docker cp on the attacker's container.
- macOS: Docker Desktop runs the daemon in a Linux virtual machine, but the CLI that unpacks the archive runs on the Mac. A container could therefore overwrite shell start-up files, SSH settings or launch agents; overwriting a start-up file could run code the next time a terminal opens.
- Linux: in its proof of concept, Imperva replaced /usr/bin/runc with a shell script; a later Docker operation ran it and created a marker file as root. This needs docker cp to run with elevated privileges, as in administrator or CI automation.
Imperva highlights where the copy is routine: CI systems pulling test results, developer machines, and incident responders collecting evidence from a container they already suspect is compromised. It also points to AI coding agents, since Docker Sandboxes uses sbx cp to move files out of an agent's isolated environment.
Imperva validated the exploit on Linux with Docker Engine 29.6.1 and on macOS with Docker Desktop 4.81.0. Its own proof of concept is the evidence; we have not seen independent confirmation, and a severity score (CVSS) was not given in the post.
How do you protect yourself from docker cp attacks?
Imperva's advice, if you cannot upgrade yet:
- Do not copy from running, untrusted or compromised containers onto a sensitive machine.
- Stop the container first; docker cp works on stopped containers, which removes the live process that performs the race. Imperva notes this does not fix unsafe unpacking itself.
- Avoid sudo docker cp and copy jobs that run as root; give the CLI the least privilege the job needs.
- Take data from suspicious containers using a disposable account or virtual machine.
Disclosure timeline
11 April 2026: Imperva reports the bug to Docker. 15 April: Docker confirms it as a valid finding. 10 July: the initial 90-day disclosure period ends without a public patch. 24 July: Docker provides CVE-2026-17106 and targets a 3 August release. 30 July: go-archive v0.3.0 and Docker Engine/CLI 29.7.0 ship the unpacking fix. 31 July: Docker reports functional regressions from the first fix and asks for more time; follow-up releases address them. 6 August: Docker Sandboxes 0.38.0 fixes the sbx cp variant. 10 August: Docker Desktop 4.86.0, bundling Engine 29.7.2, ships; Imperva publishes.
Imperva adds that Docker decided the daemon-side race would not get its own CVE and would be handled as extra hardening. It describes the unpacking fix as the primary one.
What is not stated or checked
- Docker's own advisory and release notes were not opened, so version details rest on Imperva's post alone. Rely on Docker's advisory for the authoritative versions.
- We did not run the exploit or read the code Imperva quotes.
- Imperva also said the Docker Desktop fix was pending until 10 August; the post does not say how many users were affected or whether it was exploited in the wild.
Terms in plain English
- Tar archive (ours): one file that bundles many files, folders and links, used to move a directory tree.
- Symlink: a file that points at another path; opening it opens the target.
- Race condition: a bug that depends on the exact timing of two actions.
- runc: the program that actually starts containers on a Linux host; replacing it means the next container start runs the attacker's code.
Where things stand
Imperva lists Docker Engine and CLI 29.7.2, Docker Desktop 4.86.0 and Docker Sandboxes 0.38.0 as the fixed releases and says its main lesson is that unpacking an archive is a security boundary. Check Docker's advisory GHSA-hfg8-hc9c-6c3h for the authoritative version list.
Sources
- CopyEscape: Taking Over Docker Hosts with docker cp, Imperva Threat Research, 10 August 2026
Sources
Related stories
- A symlink trick beats six AI coding assistants, Wiz says
- Cloudflare brings full post-quantum switch forward to 2027
- Anthropic says plain Claude Code review finds 11 of 21 logic bugs
- OpenSSL fixes Encrypted Client Hello bug allowing impersonation
- Anthropic posts quantum algorithms its authors call impractical
- Self-tuning GPS receiver resists slow spoofing longer in simulation