
Code sample for using exploit CVE-2019-5736 to mine bitcoin with no association to original container or user.
This uses two open source libraries:
This was tested on Kali Linux, with Docker version 18.03.0 and RunC version 1.0.0-rc5.
The docker container escape starts multiple mining daemons which belong to process #1 (the kernel). This means the computers resources are used for mining without the script/compute resources being associated with your container.
This takes advantage of CVE-2019-5736. When the container is run, docker uses docker-runc to run it, and we access the pid of runc which is running our container. We then pass the execution to another program (overwrite_runc) with the symlink to the runc binary. This symlink points us directly to the file descriptor of the runc binary. This allows us to open the runc file descriptor for writing and overwrite it. By overwriting it with a malicious script, when the container shuts down, it executes the script with root priveleges, allowing us to start a cryptominer.
This overwrites the runc binary on the testbed, so copying the real one is smart before running this.
Don't use this on real, vulnerable systems.