dheeraj-jayaswal/CICD-Goat-Vapt-Writeup

GitHub: dheeraj-jayaswal/CICD-Goat-Vapt-Writeup

一份针对 OWASP CICD-Goat 的完整 VAPT 报告,涵盖 9 个 CTFd flag、多个严重漏洞的 PoC 与修复方案,并映射 OWASP CI/CD 安全风险分类。

Stars: 1 | Forks: 0

# CICD-Goat VAPT 报告 [![专为 OWASP CICD-Goat 打造](https://img.shields.io/badge/target-OWASP%20CICD--Goat-blue)](https://github.com/cider-security-research/cicd-goat) [![发现](https://img.shields.io/badge/findings-16-critical)](./findings) [![已捕获 Flag](https://img.shields.io/badge/CTFd%20flags-9%2F11-success)](./ctfd/challenge-cross-reference.md) [![许可证](https://img.shields.io/badge/license-CC%20BY%204.0-blue)](./LICENSE.md) [![LinkedIn](https://img.shields.io/badge/LinkedIn-Dheeraj%20Kumar%20Jayaswal-0077B5?style=flat-square&logo=linkedin&logoColor=white)](https://linkedin.com/in/dheerajkumarjayaswal) [![位置](https://img.shields.io/badge/Location-Pune%2C%20India-FF6B6B?style=flat-square&logo=googlemaps&logoColor=white)](https://github.com/dheeraj-jayaswal) ## 为什么会有这个项目 大多数 CI/CD 安全报告要么停留在纯理论层面(用一张幻灯片解释“Poisoned Pipeline Execution”),要么纯粹是为了在 CTF 中拿 flag(一句“这是 flag,下一个”)。这个 repo 试图避免这两种情况:下面的每一个发现都是**经过全面验证、有 PoC 支撑的漏洞**,映射到特定的 [OWASP CI/CD-SEC](./docs/02-owasp-top10-cicd-mapping.md) 风险类别,并且是以你在面试或真实客户报告中实际希望采用的方式来编写的——包括死胡同、错误的假设,以及它们是如何被纠正的。 如果你正在为 AppSec/DevSecOps/CI-CD 安全面试做准备,或者正在筹备一次涉及 CI/CD 工具链的渗透测试,又或者只是想具体、 hands-on 地了解“Poisoned Pipeline Execution”或“Insufficient Credential Hygiene”在网络中到底长什么样——这篇就是为你写的。 ## 目标环境 | 字段 | 值 | |---|---| | 目标 | [OWASP CICD-Goat](https://github.com/cider-security-research/cicd-goat) — 本地 Docker Compose 部署 | | 测试类型 | 授权的自导向学习实验室 (grey-box) | | 技术栈 | Jenkins 2.332.1, Gitea 1.16.5, GitLab 15.11.13-ee, CTFd, Docker Compose | | 范围 | `localhost:3000` (Gitea), `:8080`/`:50000` (Jenkins), `:4000` (GitLab), `:8000` (CTFd), `:8008` (prod-sim) | | 方法论 | 阶段 0–3 (范围 → 指纹识别 → 漏洞识别 → 利用) | 完整的测试规则:[`docs/00-engagement-overview.md`](./docs/00-engagement-overview.md)。 ## 结果一览 | ID | 标题 | 严重程度 | OWASP CI/CD 映射 | CTFd Flag | |---|---|---|---|---| | [F-010](./findings/F-010-jenkins-secrets-exposure-console-logs.md) | Jenkins 构建控制台日志中的 Secrets 泄露 → 凭证窃取 → 未经授权的 repo 写入 | **CRITICAL** | CICD-SEC-6, -4, -2 | flag1, flag2 | | [F-013](./findings/F-013-insecure-automerge-bypass.md) | 不安全的自动合并逻辑绕过了代码审查 (PR-wide word-diff heuristic) | **CRITICAL** | CICD-SEC-1, -5 | flag10 | | [F-016](./findings/F-016-CVE-2024-23897-jenkins-cli-arbitrary-file-read.md) | CVE-2024-23897 — Jenkins CLI 在 controller 上的任意文件读取 | **CRITICAL** | CICD-SEC-7 | flag8 | | [F-017](./findings/F-017-gitlab-runner-token-secret-theft.md) | GitLab shared-runner 注册 token → 全实例 CI/CD 凭证窃取 | **CRITICAL** | CICD-SEC-2, -6 | flag11 | | [F-019](./findings/F-019-jenkins-controller-rce-agent-label-override.md) | 通过 agent 标签覆盖实现 Jenkins controller-node 代码执行 | **CRITICAL** | CICD-SEC-5, -4 | flag5 | | [F-018](./findings/F-018-decoupled-pipeline-branch-exclusion-bypass.md) | 解耦的 pipeline repo + 分支排除过滤绕过 | HIGH | CICD-SEC-4, -6 | flag3 | | [F-020](./findings/F-020-shared-agent-filesystem-credential-leak.md) | 共享 agent 文件系统暴露 FreeStyle 作业凭证 | HIGH | CICD-SEC-6, -5 | flag6 | | [F-021](./findings/F-021-checkov-sast-config-override-bypass.md) | Checkov SAST 配置覆盖导致未检测到的 IaC 错误配置 | HIGH | CICD-SEC-1, -8 | flag7 | | [F-014](./findings/F-014-flask-secret-key-cicd-variable.md) | Flask 会话密钥源自 CI/CD pipeline 变量 | HIGH | CICD-SEC-6 | flag11 (via F-017) | 另外在 [`findings/informational/`](./findings/informational) 中还有 **6 个信息性/支持性发现**(正向控制、RBAC 边界确认、轻微信息泄露)。 ### 发现是如何串联起来的 有几个发现并不是独立的——一个直接促成或完成了另一个。这部分往往比任何单一的发现更能打动面试官: ![CICD-Goat 跨发现 kill chain 图,展示了 F-010 导致未经授权的推送,F-013 的自动合并绕过,F-016 的 CVE-2024-23897 任意文件读取反馈到 flag 捕获和 F-018,以及 F-017 的恶意 GitLab runner 完成了 F-014](https://static.pigsec.cn/wp-content/uploads/repos/cas/ed/eddb004a852244867b296708a5974205adaca401d98df6c0d8cbf17b1c6683ef.svg) **已解决 11 个 CTFd 挑战中的 9 个并验证了 flag** — 请参阅完整的 [挑战交叉引用](./ctfd/challenge-cross-reference.md),其中包括一个如实记录的案例(Dormouse/flag9),在该案例中,访问控制边界在持续的攻击下依然坚挺。 ## 完整目录 下面的每个文件都有直接链接——目录树仅展示了它们的组织方式。 ### 📋 测试文档 | 文件 | 内容 | |---|---| | [`docs/00-engagement-overview.md`](./docs/00-engagement-overview.md) | 测试规则、范围、技术栈 | | [`docs/01-methodology.md`](./docs/01-methodology.md) | 贯穿始终的分阶段测试方法论 | | [`docs/02-owasp-top10-cicd-mapping.md`](./docs/02-owasp-top10-cicd-mapping.md) | 完整的 CICD-SEC-1 到 -10 参考分类法 | | [`docs/03-remediation-roadmap.md`](./docs/03-remediation-roadmap.md) | 优先级排序的、可操作的修复清单 | | [`docs/04-interview-prep.md`](./docs/04-interview-prep.md) | 每个发现的口语化总结 + 可能的后续问题 | | [`docs/05-lessons-learned.md`](./docs/05-lessons-learned.md) | 回顾——哪些奏效了,哪些没有,下次该怎么做 | ### 🔍 侦察 | 文件 | 内容 | |---|---| | [`recon/01-fingerprinting.md`](./recon/01-fingerprinting.md) | 阶段 1 — 对范围内的每个服务进行未经认证的指纹识别 | | [`recon/02-authenticated-enumeration.md`](./recon/02-authenticated-enumeration.md) | 阶段 2 — 获得初始访问权限后进行的认证枚举 | ### 🚨 严重 & 高危发现 | 文件 | |---| | [F-010 — Jenkins secrets 通过控制台日志泄露](./findings/F-010-jenkins-secrets-exposure-console-logs.md) | | [F-013 — 不安全的自动合并绕过](./findings/F-013-insecure-automerge-bypass.md) | | [F-014 — 源自 CI/CD 变量的 Flask 密钥](./findings/F-014-flask-secret-key-cicd-variable.md) | | [F-016 — CVE-2024-23897 Jenkins CLI 任意文件读取](./findings/F-016-CVE-2024-23897-jenkins-cli-arbitrary-file-read.md) | | [F-017 — GitLab runner token 凭证窃取](./findings/F-017-gitlab-runner-token-secret-theft.md) | | [F-018 — 解耦的 pipeline 分支排除绕过](./findings/F-018-decoupled-pipeline-branch-exclusion-bypass.md) | | [F-019 — 通过 agent 标签覆盖实现 Jenkins controller RCE](./findings/F-019-jenkins-controller-rce-agent-label-override.md) | | [F-020 — 共享 agent 文件系统凭证泄露](./findings/F-020-shared-agent-filesystem-credential-leak.md) | | [F-021 — Checkov SAST 配置覆盖绕过](./findings/F-021-checkov-sast-config-override-bypass.md) | ### ℹ️ 信息性 / 支持性发现 | 文件 | |---| | [F-006 — 私有 repo 枚举缺口](./findings/informational/F-006-private-repo-enumeration-gap.md) | | [F-007 — 额外的 Jenkins 用户](./findings/informational/F-007-additional-jenkins-user.md) | | [F-009 — Job Read 与 ExtendedRead 权限](./findings/informational/F-009-job-read-vs-extendedread.md) | | [F-011 — 正确的 withCredentials 用法(正向控制)](./findings/informational/F-011-correct-withcredentials-usage.md) | | [F-012 — Credentials API 连接断开](./findings/informational/F-012-credentials-api-connection-drop.md) | | [F-015 — 匿名 registry 枚举](./findings/informational/F-015-anonymous-registry-enumeration.md) | ### 🎯 CTFd | 文件 | 内容 | |---|---| | [`ctfd/challenge-cross-reference.md`](./ctfd/challenge-cross-reference.md) | 完整的逐 flag 交叉引用,包括受阻的 Dormouse/flag9 调查以及 Duchess/flag4 的纠正 | ## Repo 结构 ``` . ├── docs/ # Engagement context, methodology, mappings, remediation, interview prep │ ├── 00-engagement-overview.md │ ├── 01-methodology.md │ ├── 02-owasp-top10-cicd-mapping.md │ ├── 03-remediation-roadmap.md │ ├── 04-interview-prep.md │ └── 05-lessons-learned.md ├── recon/ # Phase 1 & 2 — fingerprinting and authenticated enumeration │ ├── 01-fingerprinting.md │ └── 02-authenticated-enumeration.md ├── findings/ # One file per confirmed finding, full PoC + remediation │ ├── F-010-...md ... F-021-...md │ └── informational/ # INFO/LOW severity supporting observations ├── ctfd/ │ └── challenge-cross-reference.md └── LICENSE.md ``` ## 阅读路径 - **只想看亮点?** 从[上面的结果表](#results-at-a-glance)开始,然后阅读 F-010、F-013、F-016 和 F-017——这是四个最完整的端到端 kill chain。 - **正在准备面试?** 直接看 [`docs/04-interview-prep.md`](./docs/04-interview-prep.md)——每一个主要发现都有一段口语化的总结,外加常见的后续问题。 - **正在构建/加固 CI/CD pipeline?** 直接看 [`docs/03-remediation-roadmap.md`](./docs/03-remediation-roadmap.md)——一份优先级排序的、可操作的清单。 - **刚接触 CI/CD 安全概念?** 从 [`docs/02-owasp-top10-cicd-mapping.md`](./docs/02-owasp-top10-cicd-mapping.md) 开始,了解整个 repo 组织所依赖的参考分类法。 ## 关于 OWASP Top 10 CI/CD 安全风险 这里的每一个发现都映射到了 [OWASP Top 10 CI/CD Security Risks (2023)](https://owasp.org/www-project-top-10-ci-cd-security-risks/)——完整的参考表(从 CICD-SEC-1 到 CICD-SEC-10)位于 [`docs/02-owasp-top10-cicd-mapping.md`](./docs/02-owasp-top10-cicd-mapping.md),因为各个单独的发现中都在不断引用它。 ## 免责声明 此 repo 记录的测试**完全是针对本地、自托管、故意设计有漏洞的培训实验室**([OWASP CICD-Goat](https://github.com/cider-security-research/cicd-goat))进行的,仅用于教育和作品集目的。这里的内容不针对、不引用、也未针对任何生产系统、第三方服务或真实凭证进行测试。请勿将此 repo 中的任何技术用于您不拥有或未获得明确书面授权进行测试的系统。 ## 许可证 此内容采用 **[CC BY 4.0](./LICENSE.md)** 许可。欢迎您重复使用或改编此报告中的任何内容——只需明确归属 **Dheeraj Kumar Jayaswal** 并附上指向此 repo 的链接。CICD-Goat 本身是 [Cider Security](https://github.com/cider-security-research/cicd-goat) 的一个独立项目——去给原项目点个 star 吧。 ## 更广泛的安全作品集的一部分 | Repository | 内容 | |---|---| | [From-Dev-To-Attacker](https://github.com/dheeraj-jayaswal/From-Dev-To-Attacker) | 我的旗舰实战日志——从开发者的视角出发的原创漏洞报告,包含企业领域影响分析 | | [API-From-The-Trenches](https://github.com/dheeraj-jayaswal/API-From-The-Trenches) | 深入的 API 安全系列——OWASP API Top 10、BOLA、JWT 攻击、GraphQL | | [AppSec-From-The-Trenches](https://github.com/dheeraj-jayaswal/AppSec-From-The-Trenches) | 渗透测试工具与方法论参考 | | [Bug-Bounty-Hunting-Companion](https://github.com/dheeraj-jayaswal/Bug-Bounty-Hunting-Companion) | 将真实的已披露 Bug Bounty 报告作为可复现的清单 | ## 🧠 测试理念 我通过三个阶段进行每次测试:**攻击前先了解**(阅读应用,像真实用户一样使用它,先了解业务逻辑)→ **手动优先,工具其次**(有趣的 bug 是靠思考发现的,而不是扫描出来的)→ **像开发人员一样报告**(开发团队无法复现的发现永远无法被修复)。 ## 作者 - **姓名** — Dheeraj Kumar Jayaswal - **角色** — Technology Lead – Offensive Security, Infosys Limited - **专注领域** — Web 应用与 API 渗透测试 - **涉及领域** — 所得税 · 银行 · 零售 · 电商 · 货运物流 · 教育 ### 认证 | 认证 | 颁发机构 | 状态 | |---|---|---| | OSCP Offensive Security Certified Professional | OffSec | 🔄 进行中 (2025–2026) | | Certified Ethical Hacker (CEH) | EC-Council | ✅ 2021 | | AWS Certified Solutions Architect – Associate | Amazon Web Services | ✅ 2022 | | AWS Certified Cloud Practitioner | Amazon Web Services | ✅ 2022 | | Executive Certificate in Cyber Security | IIT Kanpur | ✅ 2026 | ## 🌐 联系方式 [![LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-0077B5?style=flat-square&logo=linkedin&logoColor=white)](https://linkedin.com/in/dheerajkumarjayaswal) [![Email](https://img.shields.io/badge/Email-Reach%20Out-D14836?style=flat-square&logo=gmail&logoColor=white)](mailto:jaiswal.dheeraj123@gmail.com) 欢迎反馈、指正和 PR(例如关于 flag9/Dormouse,或 [CTFd 交叉引用](./ctfd/challenge-cross-reference.md) 中的 Duchess/flag4 后续) — 请参阅 [CONTRIBUTING.md](./CONTRIBUTING.md)。
标签:CI/CD安全, DevSecOps, Llama, StruQ, 上游代理, 安全演练, 渗透测试报告, 漏洞分析, 版权保护, 路径探测