mcpField
D
detecting-supply-chain-attacks-in-ci-cd

detecting-supply-chain-attacks-in-ci-cd

github.com/mukul975安全35.2k134 次安装8 周前更新
代码仓库

关于 detecting-supply-chain-attacks-in-ci-cd

面向 SOC 分析师和安全工程师的 CI/CD 供应链风险分析技能,重点检查 GitHub Actions 工作流中的依赖、注入路径和权限配置。

主要功能

  1. 01解析 GitHub Actions YAML
  2. 02查找未固定版本的 Actions
  3. 03检测表达式脚本注入
  4. 04检查令牌权限与机密暴露

适用场景

  1. 01调查 CI/CD 供应链安全事件
  2. 02编写威胁搜寻规则
  3. 03检查工作流风险监控覆盖

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill detecting-supply-chain-attacks-in-ci-cd

安装后在 Claude Code 中输入/detecting-supply-chain-attacks-in-ci-cd确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

LICENSE
references/
api-reference.md
scripts/
agent.py

详细介绍

检测 CI/CD 中的供应链攻击

何时使用

  • 在调查需要检测 CI/CD 中供应链攻击的安全事件时
  • 在为该领域构建检测规则或威胁狩猎查询时
  • 当 SOC 分析师需要针对此类分析的结构化流程时
  • 在验证相关攻击技术的安全监控覆盖范围时

前置条件

  • 熟悉安全运营概念和工具
  • 可访问测试或实验环境以安全执行
  • 已安装 Python 3.8+ 及所需依赖
  • 为任何测试活动获得适当授权

说明

通过解析 GitHub Actions YAML,扫描 CI/CD 工作流文件中的供应链风险, 检查未固定版本的依赖、脚本注入向量和密钥泄露。

import yaml
from pathlib import Path

for wf in Path(".github/workflows").glob("*.yml"):
    with open(wf) as f:
        workflow = yaml.safe_load(f)
    for job_name, job in workflow.get("jobs", {}).items():
        for step in job.get("steps", []):
            uses = step.get("uses", "")
            if uses and "@" in uses and not uses.split("@")[1].startswith("sha"):
                print(f"Unpinned action: {uses} in {wf.name}")

主要供应链风险:

  1. 未固定版本的 GitHub Actions(使用 @main 而非 SHA)
  2. 通过 ${{ github.event }} 表达式进行脚本注入
  3. GITHUB_TOKEN 权限过于宽松
  4. 对仓库具有写权限的第三方 action
  5. 通过公共/私有包名冲突进行依赖混淆

示例

# Check for script injection in run steps
for step in job.get("steps", []):
    run_cmd = step.get("run", "")
    if "${{" in run_cmd and "github.event" in run_cmd:
        print(f"Script injection risk: {run_cmd[:80]}")

评论

支持 Markdown