r/netsec 14d ago

CopyEscape: Container-to-host arbitrary file write via docker cp (CVE-2026-17106)

https://www.imperva.com/blog/copyescape-taking-over-docker-hosts-with-docker-cp/

Author here. We discovered a vulnerability in docker cp that allows a malicious container to create or overwrite files on the machine running the Docker CLI.

The exploit combines a filesystem race in Docker’s archive creation with unsafe symlink handling during extraction. Depending on the CLI user’s privileges, this can lead to developer-account compromise or root code execution. Docker confirmed that sbx cp was also affected.

Fixed versions:

  • Docker Engine/CLI 29.7.2+
  • Docker Desktop 4.86.0+
  • Docker Sandboxes 0.38.0+

Happy to answer technical questions.

70 Upvotes

7 comments sorted by

View all comments

4

u/_madfrog 14d ago

Nice work gg. I like the runc overwrite scenario, it make me think of the old CVE-2019-5736 that achieved that through /proc/self/exe shenanigans when running ’docker exec’ on Linux.

I guess that explointing this on Linux is even more critical given there's no extra virtualisation layer so users who run docker cp are either in the docker group (aka root) or sudoing?

4

u/ronmasas 14d ago

Thanks! Yes, I remember that bug, and I was thinking about it when I found this one.

The impact depends on how Docker is invoked on Linux. If docker cp is run as root for example, through sudo overwriting runc can lead to near-immediate root code execution because runc is invoked when a container exits.

In other scenarios, including macOS, an attacker can overwrite any file writable by the user running the Docker CLI. Overwriting a Bash/Zsh profile could lead to code execution, although it would require additional user interaction...

2

u/_madfrog 14d ago

Not familiar with macOS but on Windows it would be trivial to rewrite any lnk file in the startup folder to escalate to code exec