目标达成 感谢每一位支持者 — 我们达成了 100% 目标!

目标: 1000 元 · 已筹: 1359 元

100%

CVE-2021-41091 PoC — Moby 安全漏洞

来源
关联漏洞
标题: Moby 安全漏洞 (CVE-2021-41091)
Description:Moby是一个开源项目,旨在推动软件的容器化,并帮助生态系统使容器技术主流化。 Moby 存在安全漏洞,该漏洞源于在Moby (Docker Engine)中发现了一个bug,数据目录(通常是var lib Docker )包含的子目录权限没有受到足够的限制,允许没有特权的Linux用户遍历目录内容和执行程序。攻击者可利用该漏洞当容器包含具有扩展权限位(如setuid )的可执行程序时,没有特权的Linux用户可以发现并执行这些程序。
Description
POC for CVE-2021-41091
介绍
# CVE-2021-41091

This exploit offers an in-depth look at the CVE-2021-41091 security vulnerability and provides a step-by-step guide on how to utilize the exploit script to achieve privilege escalation on a host.

## Vulnerability Summary

CVE-2021-41091 is a flaw in Moby (Docker Engine) that allows unprivileged Linux users to traverse and execute programs within the data directory (usually located at /var/lib/docker) due to improperly restricted permissions. This vulnerability is present when containers contain executable programs with extended permissions, such as setuid. Unprivileged Linux users can then discover and execute those programs, as well as modify files if the UID of the user on the host matches the file owner or group inside the container.

## Overlay 

The overlay filesystem is a critical component in exploiting this vulnerability. Docker's overlay filesystem enables the container's file system to be layered on top of the host's file system, thus allowing the host system to access and manipulate the files within the container. In the case of CVE-2021-41091, the overly permissive directory permissions in /var/lib/docker/overlay2 enable unprivileged users to access and execute programs within the containers, leading to a potential privilege escalation attack.
Exploitation Steps

1. Connect to the Docker container hosted on your machine and obtain root access.

2. Inside the container, set the setuid bit on /bin/bash with the following command: `chmod u+s /bin/bash`

3. On the host system, run the provided exploit script (poc.sh) by cloning the repository and executing the script as follows:

```
git clone https://github.com/UncleJ4ck/CVE-2021-41091
cd CVE-2021-41091
chmod +x ./poc.sh
./poc.sh
```

4. The script will prompt you to confirm if you correctly set the setuid bit on /bin/bash in the Docker container. If the answer is "yes," the script will check if the host is vulnerable and iterate over the available overlay2 filesystems. If the system is indeed vulnerable, the script will attempt to gain root access by spawning a shell in the vulnerable path (the filesystem of the Docker container where you executed the setuid command on /bin/bash).


<img src="https://i.imgur.com/gWUcKUX.png">

> Tested on docker engine version 20.10.5+dfsg1

# Mitigation

It is crucial to update Docker to version 20.10.9 or higher to address this vulnerability.


## TO-DO

- [ ] Add Many Cases for other privilige escalation scenarios
- [x] Fix Bugs


## Credit

> https://www.cyberark.com/resources/threat-research-blog/how-docker-made-me-more-capable-and-the-host-less-secure
文件快照

登录后查看神龙缓存的 POC 文件快照

登录查看
备注
    1. 建议优先通过来源进行访问。
    2. 本地 POC 快照面向订阅用户开放;当原始来源失效或无法访问时,本地镜像作为订阅权益的一部分提供。
    3. 持续抓取、验证、维护这份 POC 档案需要不少投入,因此本地快照已纳入付费订阅。您的订阅是让这份资料能继续走下去的关键,由衷感谢。 查看订阅方案 →