gitlab漏洞系列-仓库敏感信息通过yml文件泄露
声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由用户承担全部法律及连带责任,文章作者不承担任何法律及连带责任。
背景
nikitastupin于2022年2月份提交的这个漏洞: 下面是有问题的代码片段:
...
on:
# The pull_request_target event type fires for pull requests, but in the context of the target
# project.
pull_request_target:
# Acceptance tests are unnecessary to run on some types of PRs.
paths-ignore:
- 'docs/**'
- 'examples/**'
- 'README.md'
- 'CHANGELOG.md'
- 'CONTRIBUTING.md'
...
# Check out the pull request code (as opposed to the target project).
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
...
# CAUTION: EXECUTING UNTRUSTED CODE.
# This is made safe because we have not referenced any secrets or GitHub tokens.
- run: make testacc-up
...
github文档https://docs.github.com/en/actions/managing-workflow-runs/approving-workflow-runs-from-public-forks#about-workflow-runs-from-public-forks 中谈到:
由pull_request_target事件触发的工作流在基分支的上下文中运行。由于基本分支被认为是受信任的,因此无论审批设置如何,由这些事件触发的工作流都将始终运行。
复现步骤
我没有针对原始的gitlabhq/terraform-provider-gitlab 仓库测试此漏洞,这会将该漏洞暴露给公众。相反,nikitastupin创建了一个gitlabhq/terraform-provider-gitlab存储库的镜像来验证poc。
环境建立
1.登录GitHub并创建一个空的公共GitHub仓库。
2.参考文档https://docs.github.com/en/repositories/creating-and-managing-repositories/duplicating-a-repository#mirroring-a-repository来创建镜像gitlabhq / terraform-provider-gitlab。
3.确保镜像的默认分支是主分支。
4.确保镜像的“actions”已启用。
POC
1.以恶意用户身份登录 GitHub。
2.创建镜像的分支。
3.修改GNUmakefile文件:修改testacc-up脚本回显“不受信任的代码执行!”
4.创建一个从镜像fork的pull请求。
5.导航到工作流运行日志,以验证“不受信任的代码执行!”字符串确实打印在日志中。
原文始发于微信公众号(迪哥讲事):gitlab漏洞系列-仓库敏感信息通过yml文件泄露
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论