Skip to content
cccskills
FreePublished on GitHub

security-scan

使用 AgentShield 扫描 Claude Code 配置(.claude/ 目录)中的安全漏洞、配置错误和注入风险。检查 CLAUDE.md、settings.json、MCP 服务端、钩子(Hooks)和智能体(Agents)定义。

The English summary is being prepared. Showing the original description.

Run score Not tested

See how to install

Files included (1)

  • SKILL.md4.5 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

安全扫描技能 (Security Scan Skill)

使用 AgentShield 审计 Claude Code 配置的安全问题。

启动时机

  • 设置新的 Claude Code 项目时
  • 修改 .claude/settings.json、CLAUDE.md 或 MCP 配置后
  • 提交配置变更前
  • 接入具有现有 Claude Code 配置的新仓库时
  • 定期进行安全健康检查

扫描对象

文件检查内容
CLAUDE.md硬编码的密钥(Secrets)、自动执行指令、提示词注入(Prompt Injection)模式
settings.json过度宽松的允许列表(Allowlist)、缺失的拒绝列表(Denylist)、危险的绕过标志位
mcp.json存在风险的 MCP 服务端、硬编码的环境密钥、npx 供应链风险
hooks/由插值引起的命令注入、数据泄露、静默错误抑制
agents/*.md无限制的工具访问、提示词注入攻击面、缺失的模型规范

前提条件

必须安装 AgentShield。请检查并根据需要进行安装:

# 确认是否已安装
npx ecc-agentshield --version

# 全局安装(推荐)
npm install -g ecc-agentshield

# 或通过 npx 直接运行(无需安装)
npx ecc-agentshield scan .

使用方法

基础扫描

针对当前项目的 .claude/ 目录运行:

# 扫描当前项目
npx ecc-agentshield scan

# 扫描特定路径
npx ecc-agentshield scan --path /path/to/.claude

# 按最小严重程度过滤扫描
npx ecc-agentshield scan --min-severity medium

输出格式

# 终端输出(默认) — 带有分级的彩色报告
npx ecc-agentshield scan

# JSON — 用于 CI/CD 集成
npx ecc-agentshield scan --format json

# Markdown — 用于文档
npx ecc-agentshield scan --format markdown

# HTML — 自包含的深色主题报告
npx ecc-agentshield scan --format html > security-report.html

自动修复

自动应用安全的修复(仅限标记为可自动修复的项目):

npx ecc-agentshield scan --fix

这将执行以下操作:

  • 将硬编码的密钥替换为环境变量引用
  • 将通配符权限收紧为带作用域的替代方案
  • 不会修改仅限手动建议的项目

Opus 4.6 深度分析

运行对抗性的三智能体(3-Agent)流水线以进行更深层次的分析:

# 需要 ANTHROPIC_API_KEY
export ANTHROPIC_API_KEY=your-key
npx ecc-agentshield scan --opus --stream

这将执行以下操作:

  1. 攻击者(红队/Red Team) — 发现攻击向量
  2. 防御者(蓝队/Blue Team) — 推荐加固方案
  3. 审计员(最终判定) — 整合双方观点

安全配置初始化

从零开始构建新的安全 .claude/ 配置:

npx ecc-agentshield init

将创建的内容:

  • 带有作用域权限和拒绝列表的 settings.json
  • 包含安全最佳实践的 CLAUDE.md
  • mcp.json 占位符

GitHub Action

添加到 CI 流水线中:

- uses: affaan-m/agentshield@v1
  with:
    path: '.'
    min-severity: 'medium'
    fail-on-findings: true

严重程度分级 (Severity Levels)

分级分数含义
A90-100安全的配置
B75-89轻微问题
C60-74需要注意
D40-59重大风险
F0-39关键漏洞

结果解读

关键发现(立即修复)

  • 配置文件中硬编码的 API 密钥或令牌
  • 允许列表中的 Bash(*)(无限制的 Shell 访问)
  • 由 ${file} 插值引起的钩子(Hooks)内命令注入
  • 执行 Shell 的 MCP 服务端

高危发现(上线前修复)

  • CLAUDE.md 中的自动执行指令(提示词注入向量)
  • 权限中缺失的拒绝列表
  • 拥有不必要的 Bash 访问权限的智能体(Agent)

中度发现(建议修复)

  • 钩子(Hooks)内的静默错误抑制(2>/dev/null、|| true)
  • 缺失的 PreToolUse 安全钩子
  • MCP 服务端配置中的 npx -y 自动安装

信息级发现(知悉)

  • MCP 服务端缺失说明
  • 正确标记的禁止指令(良好实践)

链接

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

生产级 API 的 REST API 设计模式,包括资源命名、状态码、分页、过滤、错误响应、版本控制和速率限制。

The English summary is being prepared. Showing the original description.

xu-xiang/everything-claude-code-zh2KUpdated Mar 5, 2026

REST API设计模式,包括资源命名、状态码、分页、过滤、错误响应、版本控制和生产API的速率限制。

The English summary is being prepared. Showing the original description.

xu-xiang/everything-claude-code-zh2KUpdated Mar 5, 2026

根据提供的示例或品牌指导,以独特的语气撰写文章、指南、博客帖子、教程、新闻简报等长篇内容。当用户需要超过一段的精致书面内容时使用,尤其是当语气一致性、结构和可信度至关重要时。

The English summary is being prepared. Showing the original description.

xu-xiang/everything-claude-code-zh2KUpdated Mar 5, 2026

撰写文章、指南、博客、教程、时事通讯等长篇内容,并根据提供的示例或品牌指南呈现独特的语言风格。当用户需要篇幅超过一段的精炼文字,且重视风格一致性、结构和可信度时,请使用此技能。

The English summary is being prepared. Showing the original description.

xu-xiang/everything-claude-code-zh2KUpdated Mar 5, 2026

编写文章、指南、博客帖子、教程、新闻通讯(newsletter)以及其他长篇内容。这些内容具有从提供的示例或品牌指南中提取出的独特语气。当用户需要比段落更长的精美文案,且对语气一致性、结构和可信度有要求时,请使用此技能(Skill)。

The English summary is being prepared. Showing the original description.

xu-xiang/everything-claude-code-zh2KUpdated Mar 5, 2026

编写文章、指南、博客、教程、时事通讯(Newsletter)等长内容,支持从示例或品牌指南中提取独特的语感语调。适用于需要撰写超过一个段落的精炼文本,尤其是对语气一致性、结构和可信度有较高要求时。

The English summary is being prepared. Showing the original description.

xu-xiang/everything-claude-code-zh2KUpdated Mar 5, 2026

See all skills by xu-xiang

Report a problem with this skill