GitHub security posture analysis for AI agents.
GitHub Enterprise security features cost $21/user/month.
This gives your AI agent the same visibility for free — org, repos, Actions, secrets, supply chain.
The Problem • How It's Different • Quick Start • What The AI Can Do • Tools • Checks • Architecture
______________________________________________________________________
问题
GitHub的安全性是分散的。您需要单独的工具来进行组织设置、仓库配置、操作工作流分析、秘密扫描、供应链和访问控制。没有一个工具能涵盖这一切,也没有一个能与人工智能代理配合使用。
Traditional workflow:
manually check org settings → click through 15 pages
run github-advisory-db for each repo → one at a time
grep workflows for script injection → miss half the patterns
review collaborator access → spreadsheet hell
check secret scanning alerts → another dashboard
──────────────────────────────────────────
Total: hours of manual work per orggithub安全mcp 为您的AI代理提供39个工具和45个安全检查 模型上下文协议.代理直接调用GitHub API,了解它发现了什么,并告诉您要修复什么。
With github-security-mcp:
You: "Audit my GitHub org for security issues and prioritize the fixes"
Agent: → checks org settings (2FA, SSO, member privileges)
→ scans repos (branch protection, secret scanning, Dependabot)
→ analyzes workflows (script injection, unpinned actions, OIDC)
→ reviews access (teams, collaborators, PATs, GitHub Apps)
→ "12 critical, 8 high — here are the top 5 to fix now"______________________________________________________________________
这有什么不同
现有的工具专注于GitHub安全的一个方面。github security-mcp覆盖了整个堆栈,可以与任何AI代理配合使用。
Existing Tools github-security-mcp
Interface CLI / GitHub UI / dashboards MCP — AI agent calls tools in real-time
Scope Single domain (Actions, or secrets, or repos) Full stack: org + repos + Actions + secrets + supply chain + access
Correlation None — isolated findings Agent chains: "This unpinned action + write permissions + no environment protection = supply chain risk"
Remediation Generic docs links Agent generates specific fix instructions for your exact configuration
Actions analysis Most tools skip workflows 8 checks: script injection, PR target, OIDC, pinning, secrets, runners, environments, permissions
Enterprise features Require GitHub Enterprise ($21/user/mo) Free — uses public API with graceful degradation for Enterprise-only features
Specific comparisons with popular tools
| 工具 | 它能做什么 | 它不能做什么 |
|---|---|---|
| 全明星 | 通过GitHub App强制执行仓库设置 | 无操作分析、无秘密扫描、无访问审核 |
| 记分卡 | OpenSSF仓库安全评分 | 单一仓库焦点,无组织级检查,无实时交互 |
| 合法化 | 组织+回购策略执行 | CLI输出,无AI集成,操作分析有限 |
| 踏步安全/加固转轮 | 运行时操作安全 | 仅操作,无组织/仓库/访问检查 |
| GitGuardian 的 | 提交中的秘密检测 | 仅SaaS,无自托管,仅限于秘密域 |
| 套接字 | 供应链风险分析 | 以包为重点,无组织/行动/访问分析 |
所有这些都是优秀的工具。github安全mcp并没有取代它们——它填补了提供人工智能代理的空白 统一、交互式访问 跨所有GitHub安全域。
______________________________________________________________________
快速开始
安装
git clone https://github.com/badchars/github-security-mcp.git
cd github-security-mcp
bun install设置身份验证
# Classic PAT (requires: repo, admin:org, admin:org_hook, admin:repo_hook)
export GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# Fine-grained PAT (preferred — least privilege)
# Organization: Members (read), Administration (read)
# Repository: Administration, Code scanning, Dependabot, Secret scanning,
# Actions, Environments, Webhooks (all read-only)连接到您的AI代理
Claude Code
claude mcp add github-security -- bun run /path/to/github-security-mcp/src/index.tsClaude Desktop
增添 ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"github-security": {
"command": "bun",
"args": ["run", "/path/to/github-security-mcp/src/index.ts"],
"env": {
"GITHUB_TOKEN": "ghp_your_token_here"
}
}
}
}Cursor / Windsurf / other MCP clients
相同的JSON配置格式。将命令指向您的安装路径。
开始审核
You: "Audit my GitHub org for security misconfigurations"就这样,剩下的就交给特工了。
______________________________________________________________________
AI能做什么
全面组织审计
You: "Run a complete security audit on our GitHub org"
Agent: → github_run_all {org: "myorg", repo: "main-app"}
→ 45 checks across 6 categories
→ github_audit_report
→ "34 findings: 4 critical, 7 high, 12 medium.
Critical #1: No branch protection on main (REPO-001)
Critical #2: Script injection in deploy.yml (ACT-001)
Critical #3: 3 critical Dependabot alerts unfixed 90+ days (REPO-007)
Critical #4: Unresolved secret scanning alerts (SEC-002)
Here are the exact fixes for each..."操作工作流安全
You: "Check our CI/CD workflows for supply chain risks"
Agent: → github_check_workflow_injection
Found ${{ github.event.issue.title }} in run: block (deploy.yml:47)
→ github_check_workflow_pinning
12 actions use tags instead of SHA pins
→ github_check_workflow_pr_target
build.yml uses pull_request_target with checkout — critical risk
→ github_check_workflow_permissions
Default GITHUB_TOKEN has write-all permissions
→ "4 supply chain risks found. The PR target + checkout pattern
allows any fork to execute arbitrary code with write access
to your repo. Fix this first."访问控制审查
You: "Who has too much access to our repositories?"
Agent: → github_check_team_permissions
"platform" team has admin on 47 repos, only 3 members
→ github_check_collaborators
8 outside collaborators with write access
→ github_check_app_permissions
"old-ci-bot" GitHub App has admin + all repos
→ github_check_pat_usage
14 classic PATs with repo scope (should be fine-grained)
→ "Reduce blast radius: restrict platform team to maintain,
remove 3 stale outside collaborators, limit old-ci-bot
to specific repos, migrate classic PATs to fine-grained."秘密曝光检测
You: "Are we properly protecting secrets across our repos?"
Agent: → github_check_secret_scanning
Secret scanning disabled on 5 private repos
→ github_check_push_protection
3 push protection bypasses in the last month
→ github_check_secret_patterns
No custom secret patterns defined
→ github_check_secret_scoping
2 org secrets available to all repos (should be scoped)
→ "Enable secret scanning on all repos, review the 3 bypasses,
add custom patterns for internal API keys, and scope
org secrets to only the repos that need them."______________________________________________________________________
工具参考(39个工具)
Organization (7)
| 工具 | 说明 |
|---|---|
github_check_org_security | 2FA执行、默认仓库可见性、成员创建权限 |
github_check_org_sso | 通过GraphQL配置SSO/SAML |
github_check_org_members | 外部合作者、过时成员检测 |
github_check_org_apps | OAuth凭据授权、GitHub应用程序安装权限 |
github_check_org_webhooks | 不安全的webhook URL(HTTP,无秘密) |
github_check_org_audit_log | 可疑的审计日志活动(企业) |
github_list_org_repos | 列出组织中具有安全元数据的所有存储库 |
Repository (8)
| 工具 | 说明 |
|---|---|
github_check_repo_branch_protection | 违约分行的分行保护规则 |
github_check_repo_secrets | 启用秘密扫描和推送保护 |
github_check_repo_code_scanning | CodeQL/代码扫描已启用,打开警报 |
github_check_repo_dependabot | 启用Dependabot的关键警报分诊 |
github_check_repo_settings | SECURITY.md、私有漏洞报告、分叉限制 |
github_check_repo_webhooks | 不安全的仓库级webhook URL |
github_check_repo_deploy_keys | 部署密钥权限(只读与读写) |
github_check_repo_codeowners | CODEOWNERS文件的存在和执行 |
Actions (8)
| 工具 | 说明 |
|---|---|
github_check_workflow_injection | 通过脚本注入 ${{ github.event.* }} 在 run: 砌块 |
github_check_workflow_pr_target | pull_request_target +结账模式(关键) |
github_check_workflow_permissions | GITHUB_TOKEN默认权限范围 |
github_check_workflow_pinning | 未绑定的第三方操作(标签vs SHA) |
github_check_workflow_runners | 自我主持跑步者曝光 |
github_check_workflow_environments | 缺少环境保护规则 |
github_check_workflow_secrets | 工作流中的秘密渗透模式 |
github_check_workflow_oidc | OIDC主题索赔定制 |
Secrets (4)
| 工具 | 说明 |
|---|---|
github_check_secret_scanning | 覆盖范围差距和未解决的警报 |
github_check_push_protection | 推送保护旁路跟踪 |
github_check_secret_patterns | 自定义秘密图案配置 |
github_check_secret_scoping | 环境、仓库和组织级秘密范围 |
Supply Chain (4)
| 工具 | 说明 |
|---|---|
github_check_dependency_graph | 依赖图启用 |
github_check_dependabot_updates | Dependabot安全更新配置 |
github_check_sbom | SBOM生成能力 |
github_check_vulnerabilities | 已知漏洞,严重未修复>90天 |
Access Control (4)
| 工具 | 说明 |
|---|---|
github_check_team_permissions | 跨存储库的团队权限级别 |
github_check_collaborators | 外部合作者访问审核 |
github_check_app_permissions | GitHub应用程序权限范围审查 |
github_check_pat_usage | 经典与细粒度PAT使用 |
Meta (4)
| 工具 | 说明 |
|---|---|
github_list_checks | 浏览所有45项检查,按类别/严重程度筛选 |
github_audit_summary | 按类别、严重程度、状态汇总调查结果 |
github_audit_report | 完整的markdown或JSON审计报告 |
github_run_all | 执行对组织/仓库的所有检查 |
______________________________________________________________________
检查注册表(45次检查)
Organization (ORG-001 to ORG-010)
| ID | 检查 | 严重性 |
|---|---|---|
| ORG-001 | 2FA未执行 | 关键 |
| ORG-002 | 默认回购可见性为公开 | 高 |
| ORG-003 | 成员可以创建公共仓库 | 中等 |
| ORG-004 | 未配置SSO/SAML | 高 |
| ORG-005 | 有访问权限的外部合作者 | 中等 |
| ORG-006 | 组织成员陈旧 | 低 |
| ORG-007 | OAuth应用授权风险高 | 高 |
| ORG-008 | 过度允许GitHub应用程序安装 | 高 |
| ORG-009 | 不安全的webhook URL | 中等 |
| ORG-010 | 可疑审计日志活动 | 信息 |
Repository (REPO-001 to REPO-013)
| ID | 检查 | 严重性 |
|---|---|---|
| REPO-001 | 缺少或弱分支保护 | 关键 |
| REPO-002 | 未启用秘密扫描 | 高 |
| REPO-003 | 推送保护未启用 | 高 |
| REPO-004 | 未启用代码扫描 | 中等 |
| REPO-005 | 打开代码扫描警报 | 高 |
| REPO-006 | 未启用Dependabot | 中等 |
| REPO-007 | 关键依赖机器人警报 | 关键 |
| REPO-008 | 无SECURITY.md策略文件 | 低 |
| REPO-009 | 关闭私有漏洞报告 | 低 |
| REPO-010 | 无限制拨叉设置 | 低 |
| REPO-011 | 不安全的回购webhooks | 中等 |
| REPO-012 | 读写部署密钥 | 高 |
| REPO-013 | 缺少代码所有者文件 | 低 |
Actions (ACT-001 to ACT-008)
| ID | 检查 | 严重性 |
|---|---|---|
| ACT-001 | 通过不受信任的输入进行脚本注入 | 关键 |
| ACT-002 | 带校验的pull_request_target | 关键 |
| ACT-003 | 过度允许赠品_糖果 | 高 |
| ACT-004 | 未加密的第三方行为 | 中等 |
| ACT-005 | 自托管跑步者曝光 | 高 |
| ACT-006 | 缺少环境保护规则 | 中等 |
| ACT-007 | 秘密渗透模式 | 高 |
| ACT-008 | OIDC配置错误 | 中等 |
Secrets (SEC-001 to SEC-005)
| ID | 检查 | 严重性 |
|---|---|---|
| SEC-001 | 秘密扫描覆盖范围差距 | 高 |
| SEC-002 | 未解决的秘密扫描警报 | 严重 |
| SEC-003 | 推送保护旁路 | 高 |
| SEC-004 | 无自定义秘密图案 | 低 |
| SEC-005 | 秘密范围过于宽泛 | 中等 |
Supply Chain (SUP-001 to SUP-005)
| ID | 检查 | 严重性 |
|---|---|---|
| SUP-001 | 依赖关系图未启用 | 中等 |
| SUP-002 | Dependabot安全更新关闭 | 高 |
| SUP-003 | 无SBOM生成 | 低 |
| SUP-004 | 关键已知漏洞 | 关键 |
| SUP-005 | 长期未修复的漏洞(>90天) | 高 |
Access Control (ACC-001 to ACC-004)
| ID | 检查 | 严重性 |
|---|---|---|
| ACC-001 | 团队访问权限过大 | 高 |
| ACC-002 | 外部合作者写+ | 中等 |
| ACC-003 | GitHub应用程序范围过大 | 高 |
| ACC-004 | 具有宽范围的经典PAT | 高 |
______________________________________________________________________
建筑
src/
├── index.ts Entry point + MCP stdio
├── types/
│ └── index.ts CheckResult, ToolDef, ToolContext, ToolResult
├── github/
│ └── client.ts GitHubClientFactory (lazy Octokit + GraphQL)
├── protocol/
│ ├── tools.ts 39 tool definitions (Zod schemas)
│ └── mcp-server.ts MCP server + stdio transport
├── org/ Organization checks (ORG-001..010)
│ ├── security.ts 2FA, visibility, member privileges
│ ├── sso.ts SSO/SAML via GraphQL
│ ├── members.ts Outside collaborators, stale members
│ ├── apps.ts OAuth apps, GitHub App installations
│ ├── webhooks.ts Insecure webhook URLs
│ └── audit-log.ts Suspicious audit log patterns
├── repo/ Repository checks (REPO-001..013)
│ ├── branch-protection.ts Branch protection rules
│ ├── secret-scanning.ts Secret scanning + push protection
│ ├── code-scanning.ts CodeQL enabled, open alerts
│ ├── dependabot.ts Dependabot enabled, critical alerts
│ ├── settings.ts SECURITY.md, vuln reporting, forks
│ ├── webhooks.ts Insecure repo webhooks
│ ├── deploy-keys.ts Deploy key permissions
│ └── codeowners.ts CODEOWNERS file
├── actions/ GitHub Actions checks (ACT-001..008)
│ ├── injection.ts Script injection via untrusted inputs
│ ├── pr-target.ts pull_request_target + checkout
│ ├── permissions.ts GITHUB_TOKEN default permissions
│ ├── pinning.ts Unpinned third-party actions
│ ├── runners.ts Self-hosted runner exposure
│ ├── environments.ts Environment protection rules
│ ├── secrets.ts Secret exfiltration patterns
│ └── oidc.ts OIDC configuration
├── secrets/ Secret management checks (SEC-001..005)
│ ├── scanning.ts Coverage + alert triage
│ ├── push-protection.ts Push protection bypasses
│ ├── patterns.ts Custom secret patterns
│ └── scoping.ts Env/repo/org secret scoping
├── supply-chain/ Supply chain checks (SUP-001..005)
│ ├── dependency-graph.ts Dependency graph enabled
│ ├── dependabot-updates.ts Security updates config
│ ├── sbom.ts SBOM generation
│ └── vulnerabilities.ts Known vulns, stale unfixed
├── access/ Access control checks (ACC-001..004)
│ ├── teams.ts Team permission audit
│ ├── collaborators.ts External collaborators
│ ├── github-apps.ts GitHub App permissions
│ └── tokens.ts Classic vs fine-grained PATs
└── meta/ Aggregation + reporting
├── list-checks.ts CHECK_REGISTRY (45 checks)
├── summary.ts Findings aggregation
├── report.ts Markdown/JSON report
└── run-all.ts Execute all checks设计决策:
- 单个Octokit实例 -GitHub API是全球性的(无地区)。在第一个API调用上的延迟初始化。
- 统一检查结果 --每次检查都返回相同的结构:checkId、严重性、状态、详细信息、补救措施。图案与 云审计mcp.
- 静态工作流分析 -操作检查通过Contents API获取YAML并使用regex分析。GitHub没有解析的工作流API。
- 企业优雅降级 --仅限企业的功能(审核日志、凭据授权、SSO)返回
NOT_APPLICABLE而不是错误。 - 记忆中的发现 --会话范围的发现数组。没有数据库,就没有持久性。跑
github_audit_summary或github_audit_report聚合。 - 4依赖关系 —
@modelcontextprotocol/sdk,@octokit/rest,@octokit/graphql,zod没有别的了。
______________________________________________________________________
认证
| 令牌类型 | 必填范围 |
|---|---|
| 经典PAT | repo, admin:org, admin:org_hook, admin:repo_hook |
| 细粒PAT (推荐) | 组织:成员+管理(阅读)。回购:管理、代码扫描、Dependabot、秘密扫描、操作、环境、Webhooks(阅读) |
| GitHub应用程序 | 与细粒度PAT具有相同的存储库/组织权限 |
从读取令牌 GITHUB_TOKEN 环境变量。
______________________________________________________________________
MCP安全套件的一部分
| 项目 | 域 | 工具 |
|---|---|---|
| Hackbrowserv mcp | 基于浏览器的安全测试 | 39个工具,Firefox,注入测试 |
| 云审计mcp | 云安全(AWS/Azure/GCP) | 38个工具,60多项检查 |
| github安全mcp | GitHub安全态势 | 39个工具,45个检查 |
______________________________________________________________________
局限性
- 需要具有适当范围的GitHub PAT或GitHub App令牌
- 一些检查需要GitHub Enterprise Cloud(审计日志、凭据授权、SSO)——这些检查在免费/团队计划中会优雅地返回NOT_APPLICABLE
- 动作工作流分析是基于正则表达式的(没有AST解析)——可能会错过复杂的注入模式
- 速率限制:GitHub API允许通过身份验证的用户每小时请求5000次。一个包含多个仓库的完整组织审计可能会接近这个极限
- macOS/Linux(未测试Windows)
______________________________________________________________________
For authorized security testing and assessment only.
Always ensure you have proper authorization before auditing any organization.
MIT License • Built with Bun + TypeScript
