TupleType/awesome-cicd-attacks
GitHub: TupleType/awesome-cicd-attacks
一份精选的 CI/CD 攻击性安全研究资源汇总,汇集了攻击技术、实战工具与案例分析,帮助安全从业者深入理解并应对软件供应链与持续集成环境中的安全威胁。
Stars: 582 | Forks: 53
# Awesome CI/CD 攻击 [](https://awesome.re)
针对与代码开发和部署相关的系统及流程的攻击性安全研究。
## 目录
- [技术](#techniques)
- [公开暴露的敏感数据](#publicly-exposed-sensitive-data)
- [初始代码执行](#initial-code-execution)
- [后渗透](#post-exploitation)
- [防御规避](#defense-evasion)
- [工具](#tools)
- [案例分析](#case-studies)
- [类似项目](#similar-projects)
## 技术
精心整理的独特且实用的 CI/CD 攻击技术列表。
### 公开暴露的敏感数据
- [(The) Postman Carries Lots of Secrets](https://trufflesecurity.com/blog/postman-carries-lots-of-secrets) - Postman 的公共 API 网络因令人困惑的 UI、 forks 以及不充分的 secret 扫描而泄露了数以千计的 secret。
- [All the Small Things: Azure CLI Leakage and Problematic Usage Patterns](https://www.paloaltonetworks.com/blog/prisma-cloud/secrets-leakage-user-error-azure-cli/) - Azure CLI 因使用模式问题将 secret 泄露到了 CI/CD 日志中。
- [Anyone can Access Deleted and Private Repository Data on GitHub](https://trufflesecurity.com/blog/anyone-can-access-deleted-and-private-repo-data-github) - 只要它是 fork 网络的一部分。
- [Beyond S3: Exposed Resources on AWS](https://duo.com/blog/beyond-s3-exposed-resources-on-aws) - 公共 EBS、RDS、AMI 和 Elasticsearch 集群暴露在互联网上。
- [CloudQuarry: Digging for secrets in public AMIs](https://securitycafe.ro/2024/05/08/aws-cloudquarry-digging-for-secrets-in-public-amis/) - 研究人员在公共 AWS AMI 中发现了 500GB 的凭据、私有仓库和密钥,影响了多个行业。
- [Employee Personal GitHub Repos Expose Internal Azure and Red Hat Secrets](https://www.aquasec.com/blog/github-repos-expose-azure-and-red-hat-secrets/) - 员工的个人 GitHub 仓库暴露了内部的 Azure 和 Red Hat secret。
- [Fortune 500 at Risk: 250M Artifacts Exposed via Misconfigured Registries](https://www.aquasec.com/blog/250m-artifacts-exposed-via-misconfigured-registries/) - 配置不当的公共 Registry 及其包含敏感专有代码和 secret 的软件 artifact 被暴露。
- [GitLab Secrets](https://github.com/RichardoC/gitlab-secrets) - 一款能够揭示已删除的 GitLab commit 的工具,这些 commit 可能包含敏感信息,且无法通过公共 Git 历史记录访问。
- [Hidden GitHub Commits and How to Reveal Them](https://neodyme.io/en/blog/github_secrets/) - 一款能够揭示已删除的 GitHub commit 的工具,这些 commit 可能包含敏感信息,且无法通过公共 Git 历史记录访问。
- [Holes in Your Bitbucket: Why Your CI/CD Pipeline Is Leaking Secrets](https://cloud.google.com/blog/topics/threat-intelligence/bitbucket-pipeline-leaking-secrets) - Bitbucket 受保护变量通过 artifact 对象泄露 secret;建议包括使用专用的 secret 管理器和代码扫描。
- [Millions of Secrets Exposed via Web Application Frontends](https://web.archive.org/web/20230531032433/https://redhuntlabs.com/blog/millions-of-secrets-exposed-via-web-application-frontend/) - 数以百万计的 secret 通过 JavaScript 和调试页面暴露在 Web 应用前端。
- [Publicly Exposed AWS Document DB Snapshots](https://ramimac.me/exposed-docdb) - Cinemark Brazil 公开暴露的 AWS DocumentDB 快照泄露了数百万条客户记录。
- [Thousands of images on Docker Hub leak auth secrets, private keys](https://www.bleepingcomputer.com/news/security/thousands-of-images-on-docker-hub-leak-auth-secrets-private-keys/) - 研究人员发现数千个 Docker Hub 镜像泄露了私钥和 API secret。
### 初始代码执行
- [ActionsTOCTOU (Time Of Check to Time Of Use)](https://github.com/AdnaneKhan/ActionsTOCTOU/) - 一款用于监听审批事件,然后迅速将 PR 头部的文件替换为指定为参数的本地文件的工具。
- [AWS Targeted by a Package Backfill Attack](https://www.mend.io/blog/aws-targeted-by-a-package-backfill-attack/) - 扫描 commit 历史记录以获取内部 package,从而执行依赖混淆攻击。
- [Can you trust ChatGPT's package recommendations?](https://vulcan.io/blog/ai-hallucinations-package-risk) - 利用生成式 AI 平台倾向于生成不存在的编码库的特点,来执行依赖混淆攻击。
- [Can You Trust Your VSCode Extensions?](https://www.aquasec.com/blog/can-you-trust-your-vscode-extensions/) - 冒充流行的 VSCode 扩展,诱骗不知情的开发者下载它们。
- [Deep dive into Visual Studio Code extension security vulnerabilities](https://snyk.io/blog/visual-studio-code-extension-security-vulnerabilities-deep-dive/) - VS Code 扩展存在漏洞(命令注入、路径遍历、zip slip),可能危及开发者机器的安全。
- [Dependency Confusion: How I Hacked Into Apple, Microsoft and Dozens of Other Companies](https://medium.com/@alex.birsan/dependency-confusion-4a5d60fec610) - 研究人员上传了带有公司内部名称的恶意 package,由于依赖混淆获得了对 Apple、Microsoft 等公司的访问权限。
- [Dependency Confusions in Docker and remote pwning of your infra](https://www.errno.fr/DockerDependencyConfusion.html) - 当配置错误的 Docker 镜像源拉取恶意的公共镜像而不是私有镜像时,就会发生 Docker 依赖混淆。
- [Erosion of Trust: Unmasking Supply Chain Vulnerabilities in the Terraform Registry](https://boostsecurity.io/blog/erosion-of-trust-unmasking-supply-chain-vulnerabilities-in-the-terraform-registry) - Terraform 模块不受 Dependency Lock File 的保护,因此,一个看似无害的模块可能会引入恶意代码。
- [Fixing typos and breaching microsoft's perimeter](https://johnstawinski.com/2024/04/15/fixing-typos-and-breaching-microsofts-perimeter/) - 通过成为贡献者来绕过 GitHub workflow 的批准要求。
- [GitHub Dataset Research Reveals Millions Potentially Vulnerable to RepoJacking](https://www.aquasec.com/blog/github-dataset-research-reveals-millions-potentially-vulnerable-to-repojacking/) - 由于组织重命名,数以百万计的 GitHub 仓库容易受到 RepoJacking 攻击,从而导致潜在的代码执行。
- [Gitloker attacks abuse GitHub notifications to push malicious OAuth apps](https://www.bleepingcomputer.com/news/security/gitloker-attacks-abuse-github-notifications-to-push-malicious-oauth-apps/) - 攻击者利用伪造的 GitHub 通知诱骗用户授权窃取仓库访问权限的恶意 OAuth 应用。
- [Hacking GitHub AWS integrations again](https://dagrz.com/writing/aws-security/hacking-github-aws-oidc/) - 攻击配置错误且使用 OIDC 的 pipeline。
- [How I hacked into Google's internal corporate assets](https://observationsinsecurity.com/2024/04/25/how-i-hacked-into-googles-internal-corporate-assets/) - 在代码中寻找依赖关系以进行依赖混淆攻击的更多方法。
- [How to completely own an airline in 3 easy steps](https://maia.crimew.gay/posts/how-to-hack-an-airline/) - 可以从互联网访问的配置错误的 CI 系统。
- [How We Hacked a Software Supply Chain for $50K](https://www.landh.tech/blog/20250211-hack-supply-chain-for-50k/) - 抓取目标的 JavaScript 前端文件,并利用 AST 识别 import/require 语句,从而发现包含 NPM 凭据的公共容器。
- [Introducing MavenGate: a supply chain attack method for Java and Android applications](https://blog.oversecured.com/Introducing-MavenGate-a-supply-chain-attack-method-for-Java-and-Android-applications/) - 许多早已被废弃的公共流行库仍被大型项目使用。可以通过购买域名来劫持对这些项目的访问。
- [Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/) - 将 pull_request_target workflow 触发器与显式检出不受信任的 PR 相结合,可能会导致仓库被入侵。
- [Keeping your GitHub Actions and workflows secure Part 2: Untrusted input](https://securitylab.github.com/research/github-actions-untrusted-input/) - GitHub Actions 命令注入。
- [Malicious code analysis: Abusing SAST (mis)configurations to hack CI systems](https://medium.com/cider-sec/malicious-code-analysis-abusing-sast-mis-configurations-to-hack-ci-systems-13d5c1b37ffe) - 配置错误的 SAST 工具可被利用在 CI 系统上执行恶意代码,允许攻击者窃取凭据或部署恶意 artifact。
- [PPE — Poisoned Pipeline Execution](https://medium.com/cider-sec/ppe-poisoned-pipeline-execution-34f4e8d0d4e9) - 投毒流水线执行 允许攻击者在没有直接访问权限的情况下在 CI/CD 系统中运行恶意代码。
- [Security alert: social engineering campaign targets technology industry employees](https://github.blog/2023-07-18-security-alert-social-engineering-campaign-targets-technology-industry-employees/) - 钓鱼攻击 GitHub 用户,诱使其下载并执行仓库。
- [The Monsters in Your Build Cache – GitHub Actions Cache Poisoning](https://adnanthekhan.com/2024/05/06/the-monsters-in-your-build-cache-github-actions-cache-poisoning/) - 通过利用漏洞或依赖缺陷,允许攻击者以有限的权限破坏 workflow。攻击者窃取缓存 token,填满缓存以强制驱逐,并用恶意代码替换合法条目。
- [Thousands of npm accounts use email addresses with expired domains](https://therecord.media/thousands-of-npm-accounts-use-email-addresses-with-expired-domains) - 维护者电子邮件劫持。
- [Understanding typosquatting methods - for a secure supply chain](https://bytesafe.dev/posts/understanding-typosquatting-methods/) - Typosquatting (误植域名/包名) 涉及发布名称与合法包相似的恶意 package,利用拼写错误注入恶意代码。
- [Vulnerable GitHub Actions Workflows Part 1: Privilege Escalation Inside Your CI/CD Pipeline](https://www.legitsecurity.com/blog/github-privilege-escalation-vulnerability) - GitHub Actions workflow_run 提权。
- [What the fork? Imposter commits in GitHub Actions and CI/CD](https://www.chainguard.dev/unchained/what-the-fork-imposter-commits-in-github-actions-and-ci-cd) - GitHub Actions 漏洞允许 fork 的 commit 绕过 workflow 安全设置。
- [whoAMI: A cloud image name confusion attack](https://securitylabs.datadoghq.com/articles/whoami-a-cloud-image-name-confusion-attack/) - 利用 AWS AMI 进行的依赖混淆攻击。
- [WordPress Plugin Confusion: How an update can get you pwned](https://vavkamil.cz/2021/11/25/wordpress-plugin-confusion-update-can-get-you-pwned/) - 未被认领的 WordPress 插件容易通过插件目录被接管。
### 后渗透
- [From Self-Hosted GitHub Runner to Self-Hosted Backdoor](https://www.praetorian.com/blog/self-hosted-github-runners-are-backdoors/) - 攻击者利用配置错误的 runner 和薄弱的 PAT 安全性来获取持久性、提升权限并进行横向移动。
- [Hacking Terraform State for Privilege Escalation](https://blog.plerion.com/hacking-terraform-state-privilege-escalation/) - 修改 Terraform state 文件允许攻击者删除基础设施或通过自定义 provider 执行代码。
- [Hijacking GitHub runners to compromise the organization](https://www.synacktiv.com/publications/hijacking-github-runners-to-compromise-the-organization) - 注册带有 ubuntu-latest 标签的 GitHub runner,可访问最初指定给 GitHub 提供的 runner 的作业。
- [How We Discovered Vulnerabilities in CI/CD Pipelines of Popular Open-Source Projects](https://cycode.com/blog/github-actions-vulnerabilities) - 提取 GitHub Actions 中的所有仓库和组织 secret。
- [Invisible Ghost: Alarming Vulnerability in GitHub Copilot](https://www.apexhq.ai/blog/blog/invisible-ghost-alarming-vulnerability-in-github-copilot/) - 使用隐藏的 Unicode 字符来操纵 GitHub Copilot 的建议。
- [Leaking Secrets From GitHub Actions: Reading Files And Environment Variables, Intercepting Network/Process Communication, Dumping Memory](https://karimrahal.com/2023/01/05/github-actions-leaking-secrets/) - 可以通过多种方法从存在漏洞的 GitHub Actions workflow 中泄露 secret:读取文件/环境变量、拦截通信以及转储 runner 内存。
- [Living off the pipeline](https://github.com/boostsecurityio/lotp) - 盘点开发工具(通常是 CLI)如何具有鲜为人知的 RCE-By-Design(设计即远程代码执行)特性。
- [Registering self-hosted CircleCI runner](broken_links.md/#httpstwittercomalxk7istatus1524353383976558593t5esgwtom2218sgygy5vdoas19) - 可用于窃取在恶意 runner 上执行的作业的 secret。
- [The GitHub Actions Worm: Compromising GitHub Repositories Through the Actions Dependency Tree](https://www.paloaltonetworks.com/blog/prisma-cloud/github-actions-worm-dependencies/) - 一种新型的 GitHub Actions 蠕虫利用了 action 依赖树。攻击者入侵一个 action 后,通过 branch 推送或 tag 覆盖感染依赖的 action,从而递归传播恶意软件。
### 防御规避
- [#redteam tip: want to discretely extract credentials from a CI/CD pipeline?](https://twitter.com/_alxk/status/1442519103885959172?s=21) - 草稿 PR 不会提醒仓库贡献者,但仍然会触发 pipeline。
- [Abusing Repository Webhooks to Access Internal CI/CD Systems at Scale](https://www.paloaltonetworks.com/blog/prisma-cloud/repository-webhook-abuse-access-ci-cd-systems-at-scale/) - 用于触发 CI/CD pipeline 的仓库 webhook 可被滥用于访问内部系统。
- [Bypassing required reviews using GitHub Actions](https://medium.com/cider-sec/bypassing-required-reviews-using-github-actions-6e1b29135cc7) - GitHub Actions 可以绕过必须的审查,允许将恶意代码推送到受保护的分支。
- [Forging signed commits on GitHub](https://iter.ca/post/gh-sig-pwn/) - GitHub API 中的一个错误允许伪造已签名的 commit。通过利用内部 Codespaces API endpoint 中的正则表达式缺陷,攻击者可以创建由任何用户签名的 commit,尽管存在 GitHub 的 Web 流程签名。
- [GitHub comments abused to push malware via Microsoft repo URLs](https://www.bleepingcomputer.com/news/security/github-comments-abused-to-push-malware-via-microsoft-repo-urls/) - 隐藏的 GitHub 评论链接。
- [How a Single Vulnerability Can Bring Down the JavaScript Ecosystem](https://www.landh.tech/blog/20240603-npm-cache-poisoning/) - 针对 NPM registry 的缓存投毒攻击导致 package 不可用。
- [One Supply Chain Attack to Rule Them All – Poisoning GitHub's Runner Images](https://adnanthekhan.com/2023/12/20/one-supply-chain-attack-to-rule-them-all/) - GitHub Actions 中的一个关键漏洞,涉及 actions/runner-images 仓库中配置错误的自托管 runner,可能允许攻击者入侵所有的 GitHub 和 Azure 托管 runner 镜像。
- [PR sneaking](https://github.com/mortenson/pr-sneaking) - 将恶意代码混入 GitHub Pull Request 的方法。
- [Remove evidence of malicious pull requests on GitHub](https://x.com/adnanthekhan/status/1829116171045474374) - 将账户的电子邮件更改为被列入黑名单的域名,会自动封禁该账户。
- [StarJacking – Making Your New Open Source Package Popular in a Snap](https://checkmarx.com/blog/starjacking-making-your-new-open-source-package-popular-in-a-snap/) - StarJacking 是一种攻击者利用其使恶意开源 package 显得受欢迎的技术。
- [The massive bug at the heart of the npm ecosystem](https://blog.vlt.sh/blog/the-massive-hole-in-the-npm-ecosystem) - NPM Manifest 混淆。
- [Trojan Source](https://trojansource.codes/) - 对手无需插入逻辑错误,而是可以攻击源代码文件的编码来注入漏洞。
- [Unpinnable Actions: How Malicious Code Can Sneak into Your GitHub Actions Workflows](https://www.paloaltonetworks.com/blog/prisma-cloud/unpinnable-actions-github-security/) - GitHub Actions 即使被固定到 commit SHA,仍然可以通过可变的依赖项(如 Docker镜像、未锁定的 package 或外部脚本)拉取恶意代码。
- [Why npm lockfiles can be a security blindspot for injecting malicious modules](https://snyk.io/blog/why-npm-lockfiles-can-be-a-security-blindspot-for-injecting-malicious-modules/) - 恶意代码可以通过 lockfile(package-lock.json 或 yarn.lock)注入到 npm 项目中,因为这些庞大的机器生成文件很少被彻底审查。
- [Working as unexpected](https://www.chainguard.dev/unchained/working-as-unexpected) - 创建一个与分支保护规则模式匹配并包含在 push 时触发的 workflow 文件的 GitHub 分支,以获取环境 secret 的访问权限。
- [Zuckerpunch - Abusing Self Hosted GitHub Runners at Facebook](https://marcyoung.us/post/zuckerpunch/) - 在 GitHub PR 中隐藏 commit。
## 工具
- [ADOKit](https://github.com/xforcered/ADOKit) - Azure DevOps 服务攻击工具包。
- [Gato](https://github.com/praetorian-inc/gato) - GitHub 攻击工具包。
- [Gato-X](https://github.com/AdnaneKhan/Gato-X) - GitHub 攻击工具包 - 极限版。
- [GH Archive](https://www.gharchive.org/) - 一个记录公共 GitHub 时间线、将其归档并使其易于访问以供进一步分析的项目。
- [GHTorrent Project](http://ghtorrent-downloads.ewi.tudelft.nl/mysql/) - GitHub API 数据的可查询离线镜像。[教程](https://ghtorrent.github.io/tutorial/)。
- [git-dumper](https://github.com/arthaud/git-dumper) - 从网站转储 Git 仓库。
- [GitFive](https://github.com/mxrch/gitfive) - 用于调查 GitHub 配置文件的 OSINT 工具。
- [Grep.app](https://grep.app/) - 使用 regex 搜索 GitHub。
- [Jenkins Attack Framework](https://github.com/Accenture/jenkins-attack-framework) - 该工具可以管理 Jenkins 任务,例如列出作业、转储凭据、运行命令/脚本以及管理 API token。
- [Nord Stream](https://github.com/synacktiv/nord-stream) - 一款用于提取存储在 CI/CD 环境中的 secret 的工具。
- [pwn_jenkins](https://github.com/gquere/pwn_jenkins) - 关于攻击 Jenkins 服务器的笔记。
- [Secrets Patterns Database](https://github.com/mazen160/secrets-patterns-db) - 用于检测 secret、API 密钥、密码、token 等的最大开源数据库。
- [Sourcegraph](https://sourcegraph.com/search) - 用于公共仓库的基于 Web 的代码搜索和导航工具。
- [Token-Spray](https://blog.projectdiscovery.io/nuclei-v2-5-3-release/) - 使用 Nuclei 自动化验证 token。
- [zizmor](https://github.com/zizmorcore/zizmor) - 针对 GitHub Actions 的静态分析。
## 案例分析
- [10 real-world stories of how we've compromised CI/CD pipelines](https://www.nccgroup.com/research-blog/10-real-world-stories-of-how-we-ve-compromised-cicd-pipelines/) - 示例包括利用 S3 配置错误、Jenkins 插件缺陷、GitLab runner 权限提升、Kubernetes pod 注释漏洞以及受损的开发者笔记本电脑。
- [GitHub Actions Attack Diagram](https://github.com/jstawinski/GitHub-Actions-Attack-Diagram) - 包含在 Black Hat USA 2024 和 DEF CON 32 上展示的公共漏洞研究。
- [Playing with Fire – How We Executed a Critical Supply Chain Attack on PyTorch](https://johnstawinski.com/2024/01/11/playing-with-fire-how-we-executed-a-critical-supply-chain-attack-on-pytorch/) - 研究人员通过恶意的 pull request 利用了一个关键的 PyTorch 漏洞,在自托管 runner 上执行代码。
## 类似项目
- [Common Threat Matrix for CI/CD Pipeline](https://github.com/rung/threat-matrix-cicd)
- [Open Software Supply Chain Attack Reference (OSC&R)](https://pbom.dev/)
- [Risk Explorer for Software Supply Chains](https://riskexplorer.endorlabs.com/#/attack-tree)
- [SDLC Infrastructure Threat Framework (SITF)](https://github.com/wiz-sec-public/SITF) - 一个用于分析和防御针对软件开发生命周期基础设施攻击的综合框架。
标签:AWS安全, Azure安全, CI/CD安全, CISA项目, DevOps安全, DevSecOps, GitHub安全, Llama, StruQ, 上游代理, 代码执行, 供应链攻击, 凭据扫描, 安全测试, 攻击性安全, 敏感数据泄露, 数据展示, 文档安全, 漏洞利用检测, 白帽黑客, 私有化部署, 管道安全, 红队, 网络安全审计, 请求拦截, 资源合集, 软件供应链安全, 远程方法调用, 防御规避