
PoC for Docker `docker cp` arbitrary file write, exploiting symlink and tar extraction flaws to overwrite host binaries or launch agents for container escape and root code execution.
docker cp container-to-host arbitrary file writeHackSpeak distribution mirror. This repository is a distribution mirror of the CopyEscape PoC (CVE-2026-17106) published by the Imperva Red Team (Ron Masas), with the code identical to upstream; upstream does not include a LICENSE, so this mirror follows distribution convention and adopts MIT License, Copyright (c) 2026 HackSpeak, with source code copyright belonging to the original author.
⚠️ For authorized security research and testing only; the Linux demo will overwrite
/usr/bin/runc, so run it in a disposable VM and make a verifiable backup first; do not run it in unauthorized or production environments.
CopyEscape (CVE-2026-17106) is a container-to-host arbitrary file write vulnerability in Docker docker cp (and sbx cp in Docker Sandboxes), discovered by the Imperva Red Team (Ron Masas).
docker cp is not a direct filesystem copy — the daemon runs filepath.WalkDir on the container filesystem to produce a tar archive, and the CLI receives the tar and extracts it on the client side;addTarFile Lstat's it again it sees a symlink → the tar stream contains inconsistent entries (a symlink header followed by "child file" entries);filepath.Join is boundary-checked, but the actual os.Symlink call uses the raw, unchecked hdr.Linkname (which can point to an absolute path); when subsequent child files are extracted, the kernel follows the symlink and writes outside the user-specified destination;docker cp. On macOS it can overwrite shell startup scripts and persist via ~/Library/LaunchAgents; on Linux, using sudo docker cp can overwrite /usr/bin/runc, and subsequent Docker lifecycle operations then achieve root code execution.sudo docker cp with untrusted containers.Two demos (test environment matches the official one: Engine 29.6.1 / Desktop 4.81.0):
macOS (non-destructive, creates ~/pwnd)
cd macos
./demo-macos.sh
Linux (high impact, overwrites /usr/bin/runc)
cd linux
# 按 linux/ 内说明构建镜像并运行;⚠️ 覆盖 runc 前务必备份
For detailed steps, see the instruction files in the
macos/andlinux/subdirectories of this repository.
/usr/bin/runc) and must be run in a disposable VM with a backup.docker cp — https://www.imperva.com/blog/copyescape-taking-over-docker-hosts-with-docker-cp/