mcpField
G
GHAGuard — GitHub Actions Supply-Chain Security Auditor

GHAGuard — GitHub Actions Supply-Chain Security Auditor

远程服务
github.com安全01 周前更新

关于 GHAGuard — GitHub Actions Supply-Chain Security Auditor

GHAGuard 是面向 CI 维护者和仓库安全团队的 GitHub Actions 工作流确定性审计工具。它检测工作流注入、权限过宽、未固定版本的 Actions 和密钥,并可生成 SARIF 与 Markdown 报告。

主要功能

  1. 01检测拉取请求工作流风险
  2. 02查找脚本注入与硬编码密钥
  3. 03检查 Action 版本固定及权限
  4. 04审计容器与运行器暴露风险
  5. 05导出 SARIF 和 Markdown 报告

适用场景

  1. 01在 CI 中拦截不安全的工作流变更
  2. 02检查仓库工作流的供应链风险
  3. 03生成供代码扫描使用的 SARIF 结果

MCP 相关

项目可通过 `mcp.apify.com` 作为远程 MCP 使用;README 未说明 MCP 工具及其输出。

配置

远程服务无需本地安装。选择你使用的客户端,复制配置或使用一键安装。

服务地址https://mcp.apify.com/?actors=zluowa~ghaguard-workflow-auditor
一键复制安装命令
Claude CodeTerminal
Cursor.cursor/mcp.json
VS Code.vscode/mcp.json
Claude Desktopclaude_desktop_config.json
Windsurf~/.codeium/windsurf/mcp_config.json

命令在终端中运行;JSON 粘贴到对应客户端的 MCP 配置后重启。需要授权的服务会在首次连接时提示登录。

工具

详细介绍

GHAGuard — GitHub Actions 安全与供应链审计器(v1.0.0)

Release CI Node.js SARIF 2.1.0 License: MIT

针对 .github/workflows/*.yml 的零依赖确定性 CI/CD 安全门禁——在亚秒级执行中,借助 SARIF 2.1.0 和 PR Markdown 评分卡,检测 Pwn Request(pull_request_target)、脚本注入、未固定版本的第三方 Actions、权限过宽的 GITHUB_TOKEN 以及硬编码机密。

可作为零安装 CLI、GitHub Action 和 **Apify Store PPE Actor(zluowa/ghaguard-workflow-auditor)**运行,基于纯粹的 node:24-alpine 构建(128–256 MB RAM,无无头浏览器,也不会产生 LLM 幻觉)。


30 秒快速入门(无需 npm install)

1. 一条命令审计任意本地仓库
# Scan .github/workflows/*.yml and print a Markdown security scorecard
npx --yes github:Zluowa/gha-guard-actor . --markdown

# Strict mode: also flag unpinned official actions/* & github/* as HIGH severity
npx --yes github:Zluowa/gha-guard-actor . --strict-official --markdown

# Emit SARIF 2.1.0 JSON for GitHub Code Scanning
npx --yes github:Zluowa/gha-guard-actor . --sarif > ghaguard.sarif
2. 直接使用 GitHub Action(已在本仓库的 CI 中实测)
name: GHAGuard Security Gate
on: [push, pull_request]

permissions:
  contents: read
  security-events: write

jobs:
  ghaguard:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
      - uses: Zluowa/[email protected]
        with:
          target: '.'
          strict-official: 'true'
          sarif-file: 'ghaguard.sarif'
          fail-on-findings: 'true'

实际扫描输出示例(加固前后对比)

检出存在漏洞的 PR 自动化工作流(exit 1)
## GHAGuard Security & Supply-Chain Report — FAIL

- **Target**: `.github/workflows/pr-bot.yml`
- **Security Score**: **0/100** (Grade **F**)
- **Findings**: 6 total (3 CRITICAL, 1 HIGH, 1 MEDIUM, 1 LOW)

| Severity | Rule | Location | Issue |
|---|---|---|---|
| **CRITICAL** | `GHA004` | `.github/workflows/pr-bot.yml:4` | Explicit "permissions: write-all" grants full read/write GITHUB_TOKEN privileges across all scopes. |
| **CRITICAL** | `GHA001` | `.github/workflows/pr-bot.yml:11` | Workflow triggers on pull_request_target and checks out untrusted PR head code, allowing arbitrary code execution with write GITHUB_TOKEN & repo secrets (Pwn Request). |
| **CRITICAL** | `GHA002` | `.github/workflows/pr-bot.yml:13` | Untrusted GitHub context "${{ github.event.pull_request.title }}" is interpolated directly inside a shell run: block, enabling command injection. |
| **HIGH** | `GHA003` | `.github/workflows/pr-bot.yml:12` | Third-party action "thirdparty/auto-label@main" is pinned to mutable ref "main" instead of a 40-char commit SHA. |
| **MEDIUM** | `GHA003` | `.github/workflows/pr-bot.yml:9` | Official action "actions/checkout@v4" is pinned to mutable ref "v4" instead of a 40-char commit SHA. |
| **LOW** | `GHA010` | `.github/workflows/pr-bot.yml:1` | No job declares "timeout-minutes:", inheriting GitHub Actions 360-minute (6h) default which risks runaway runner cost. |
对本仓库进行自检(--strict-official,exit 0)
## GHAGuard Security & Supply-Chain Report — PASS

- **Target**: `.github/workflows/ci.yml`
- **Security Score**: **100/100** (Grade **A**)
- **Findings**: 0 total (0 CRITICAL, 0 HIGH, 0 MEDIUM, 0 LOW)

No supply-chain, injection, or permission issues detected.

10 条确定性供应链与 CI/CD 规则

规则严重性检测内容
GHA001CRITICALpull_request_target 搭配不可信 PR head 检出(head.sha、head.ref、refs/pull/.../merge)——Pwn Request 远程代码执行
GHA002CRITICAL通过 ${{ github.event.issue.title / pr.body / comment.body / head_ref }} 直接在 run: 中注入 Shell 脚本
GHA003HIGH / MEDIUM未固定到 40 字符提交 SHA 的第三方 Actions(以及使用 --strict-official 时的官方 Actions)
GHA004CRITICAL / HIGH / MEDIUMpermissions: write-all、多个全局写入权限范围,或未显式设置顶层 permissions:
GHA005CRITICAL工作流 YAML 中硬编码的 API 密钥、GitHub PAT、AWS 密钥、Stripe/Slack 令牌或 URL 凭据
GHA006CRITICAL / HIGH未验证的 `curl
GHA007HIGHself-hosted runner 暴露于可由外部触发的 pull_request / issue_comment 事件
GHA008HIGH高权限 workflow_run 下载不可信制品,或检出 workflow_run.head_sha
GHA009HIGH不可信事件输入被直接写入 GITHUB_ENV / GITHUB_PATH
GHA010MEDIUM / LOW未固定版本的容器 / docker:// 镜像(:latest 或缺少摘要),以及未设置 timeout-minutes

Apify Cloud Actor 与远程 MCP(mcp.apify.com)

在 Apify 上公开发布为 zluowa/ghaguard-workflow-auditor(按事件付费,权限有限);本地 CLI 和 GitHub Action 仍然免费。

操作PPE 事件价格(USD)功能
(平台启动)apify-actor-start$0.001平台自动计费的启动事件,用于解锁 5 秒免费计算时长(Actor 代码绝不会手动收费)。
audit-workflow-bundle (主要)workflow-bundle-audit$0.05传入 githubRepo: "owner/repo",即可一键实时扫描公开的 .github/workflows/*.yml(最多 25 个文件,严格固定 SSRF 主机,遇到 404/429 时不收费);或者传入最多 100 个离线工作流文件 -> 生成 0–100 分的评分、SARIF 2.1.0 和 Markdown。
audit-workflowworkflow-security-audit$0.025审计单个工作流 YAML 文件 -> 生成 0–100 的安全评分、A–F 等级、SARIF 2.1.0 和 Markdown。
{
  "action": "audit-workflow-bundle",
  "githubRepo": "Zluowa/gha-guard-actor",
  "includeSarif": true,
  "includeMarkdown": true
}

本地开发与验证

git clone https://github.com/Zluowa/gha-guard-actor.git
cd gha-guard-actor
npm test
node cli/ghaguard.mjs . --strict-official --markdown

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。