
CVE-2019-5736 implemented in a self-written container runtime to understand the exploit.
CVE-2019-5736 implemented using a shallow, self-written container runtime to understand the exploit.
Exploit is based on (and almost all copied from) the runc-poc by twistlock: https://github.com/twistlock/RunC-CVE-2019-5736/tree/master/malicious_image_POC
See code docs for further details.
Usage: quarantine [OPTIONS] [BINARY and its ARGS]
--rootfs: (mandatory) Specify a rootfs for the container.
--urange: Specify a urange start_host:end_host,start_guest.
--grange: Specify a grange start_host:end_host,start_guest.
--uid: Specify the desired UID in the container.
--ugd: Specify the desired GID in the container.
--supp: Append supplementary groups from the specified grange to the process running in the container.
Unshares all namespaces except for the user ns. User ns is unshared under special circumstances, i.e. when urange, grange, and / or are specified.
uidgidThis was tested and done on Ubuntu 18.04.
mkdir rootfssudo debootstrap bionic ./rootfsgit clone https://github.com/mhiramat/libcapcat exploit_code_for_shared_lib.c >> <any cap*.c, I used cap_alloc.c>makelibcap.so
sudo chroot rootfsapt install libcap-devlibcap.so.2.25 file into the appropriate rootfs dir
-sudo cp libcap.so.2.25 rootfs/lib/x86_64-linux-gnu
ldd quarantinesudo cp shebang_exploit rootfs/sudo gcc -o rootfs/root/payload payload.csudo gcc -o rootfs/overwrite_sndbx_runtime overwrite_sndbx_runtime.cFor example: sudo ./quarantine --rootfs rootfs /shebang_exploit or ./quarantine --rootfs rootfs --uid 1 /shebang_exploit.
It works as long as you either keep CAP_DAC_OVERRIDE or CAP_SYS_ADMIN on the host, i.e. don't unshare user ns when using sudo (since this drops caps in parent ns), or you own the file on the host.