AI代理安全审计工具

MCP Audit是一款用于扫描AI开发工具(如Claude Desktop、Cursor、VS Code等)的安全审计工具,能够检测暴露的API密钥、数据库密码等敏感信息,并提供风险等级评估和修复建议。

  • by SCraypo
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 SteveCrapo/APIsec-MCP-Audit

使用说明

MCP审计

在AI代理上线之前,看看它们可以访问什么。

网页应用

命令行界面

快速开始

# Install
pip install -e .

# Scan your machine
mcp-audit scan

# Or try the web app (no install)
# https://apisec-inc.github.io/mcp-audit/?demo=true

它的作用

MCP Audit扫描您的AI开发工具(Claude Desktop、Cursor、VS Code),并显示:

  • 秘密 -公开的API密钥、令牌、数据库密码
  • 应用程序编程接口 -您的AI代理连接到的每个端点
  • AI模型 -配置了哪些LLM(GPT-4、Claude、Llama)
  • 风险标志 -Shell访问、文件系统访问、未经验证的源代码
⚠️  2 SECRET(S) DETECTED - IMMEDIATE ACTION REQUIRED

[CRITICAL] GitHub Personal Access Token
  Location: github-tools → env.GITHUB_TOKEN
  Remediation: https://github.com/settings/tokens → Delete → Recreate

[HIGH] Database Connection String
  Location: postgres-mcp → env.DATABASE_URL
  Remediation: Rotate credentials, use secrets manager

它发现了什么(和没有发现什么)

它发现了什么

扫描类型 查找
GitHub扫描 MCP配置已提交到存储库(mcp.json, .mcp/, claude_desktop_config.json等等)
本地扫描 您机器上的MCP配置(Claude Desktop、Cursor、VS Code、Windsurf、Zed)

它找不到什么

盲点 为什么
运行时环境变量中的秘密 我们扫描配置文件,而不是运行进程
从秘密管理者手中缴获的罪犯 未扫描Vault、AWS Secrets Manager等
动态生成的配置 运行时创建的配置不在文件中
已安装但未配置MCP 无配置文件=无需扫描
您无权访问的私有仓库 GitHub扫描受您的PAT范围限制
加密或混淆的秘密 模式匹配无法捕获编码值
非标准配置位置 已知位置之外的自定义路径

重要

干净的扫描并不意味着零风险。

  • 开发人员可能在您尚未扫描的计算机上配置了MCP
  • 配置可能存在于GitHub组织之外的存储库中
  • 运行时行为可能与静态配置不同

MCP审计提供可见性,而不是保证。与运行时监控和安全审查一起使用。

CI/CD集成

失败建立在关键风险之上:

# .github/workflows/mcp-audit.yml
name: MCP Security Audit
on: [push, pull_request]

jobs:
  audit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install MCP Audit
        run: pip install mcp-audit

      - name: Run Security Scan
        run: mcp-audit scan --path . --format json -o mcp-report.json

      - name: Fail on Critical
        run: |
          CRITICAL=$(jq '[.mcps[] | select(.risk == "critical")] | length' mcp-report.json)
          if [ "$CRITICAL" -gt 0 ]; then
            echo "❌ Found $CRITICAL critical-risk MCPs"
            exit 1
          fi

      - name: Upload AI-BOM
        uses: actions/upload-artifact@v4
        with:
          name: ai-bom
          path: mcp-report.json

导出格式

# JSON (for CI/CD)
mcp-audit scan --format json -o report.json

# AI-BOM (CycloneDX 1.6)
mcp-audit scan --format cyclonedx -o ai-bom.json

# SARIF (GitHub Security integration)
mcp-audit scan --format sarif -o results.sarif

# CSV / Markdown
mcp-audit scan --format csv -o report.csv
mcp-audit scan --format markdown -o report.md

# PDF Report via Email
mcp-audit scan --email security@company.com

主要特点

特性 描述
MCP发现 在Claude Desktop、Cursor、VS Code、Windsurf、Zed中查找MCP
秘密检测 25种以上的秘密模式,具有特定于提供商的补救措施
API库存 数据库、REST、SSE、SaaS、云端点
AI模型检测 OpenAI、Anthropic、谷歌、Meta、Mistral、Ollama
OWASP LLM Top 10 将调查结果映射到OWASP LLM Top 10(2025)框架
AI-BOM出口 CycloneDX 1.6用于供应链合规
SARIF输出 GitHub Security与OWASP标签的集成
注册表 50多种已知的具有风险分类的MCP

两种使用方法

网页应用 CLI工具
扫描 GitHub仓库 本地计算机
安装 无(浏览器) Python 3.9+
最适合 全组织可见性 深入的局部分析
隐私 令牌留在浏览器中 100%本地

Web应用程序: https://apisec-inc.github.io/mcp-audit/


CLI参考

扫描命令

mcp-audit scan                    # Full scan
mcp-audit scan --secrets-only     # Only secrets
mcp-audit scan --apis-only        # Only API endpoints
mcp-audit scan --models-only      # Only AI models
mcp-audit scan --verbose          # Detailed output
mcp-audit scan --path ./project   # Specific directory

导出选项

mcp-audit scan --format json -o report.json       # JSON output
mcp-audit scan --format csv -o report.csv         # CSV output
mcp-audit scan --format markdown -o report.md     # Markdown output
mcp-audit scan --format cyclonedx -o ai-bom.json  # CycloneDX 1.6 AI-BOM
mcp-audit scan --format sarif -o results.sarif    # SARIF for GitHub Security
mcp-audit scan --email security@company.com       # PDF report via email

注册表命令

mcp-audit registry                    # List all known MCPs
mcp-audit registry --risk critical    # Filter by risk
mcp-audit registry lookup "stripe"    # Search registry

风险等级

级别 含义 示例
🔴 关键的 完全系统访问权限 数据库管理、shell访问、云IAM
🟠 高 写入访问 文件系统写入,API突变
🟡 中等 读取+有限写入 SaaS集成,只读数据库
🟢 低 只读 公共API、内存存储

检测到的秘密

严重性 类型
🔴 关键 AWS密钥、GitHub PAT、Stripe Live密钥、DB凭据
🟠 High Slack代币、OpenAI密钥、拟人密钥、SendGrid
🟡 中级 Webhook,通用API密钥

隐私

  • 网页应用:GitHub令牌永远不会离开您的浏览器
  • 命令行界面:100%本地运行,无遥测
  • PDF报告:仅发送摘要数据(无机密)

安装

选项1:Python(pip)

# Clone and install
git clone https://github.com/apisec-inc/mcp-audit.git
cd mcp-audit
pip install -e .

# Verify
mcp-audit --help

需要Python 3.9+

选项2:Docker

# Build image
docker build -t mcp-audit .

# Scan current directory
docker run -v $(pwd):/scan mcp-audit scan

# Scan with JSON output
docker run -v $(pwd):/scan mcp-audit scan --format json -o /scan/report.json

验证下载完整性

所有MCP Audit版本都包含SHA256校验和。

验证CLI下载

# Download the checksum file
curl -O https://github.com/apisec-inc/mcp-audit/releases/latest/download/CHECKSUMS.txt

# Verify the zip file
shasum -a 256 -c CHECKSUMS.txt --ignore-missing

预期产量:

mcp-audit-cli.zip: OK

当前版本校验和

文件 SHA256
mcp-audit-cli.zip 4917a451742038355265b0d9a74c0bb2b3a5ada28798ce3dd43238a8defcaa73

全额支票金额: CHECKSUMS.txt


文档

许可证

麻省理工学院-见 许可证


由...建造 API秒