skill-scanner
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSkill Security Scanner
Skill安全扫描器
Scan agent skills for security issues before adoption. Detects prompt injection, malicious code, excessive permissions, secret exposure, and supply chain risks.
Important: Run all scripts from the repository root using the full path via .
${CLAUDE_SKILL_ROOT}在采用Agent技能前扫描其安全问题。可检测提示注入、恶意代码、过度权限、密钥泄露以及供应链风险。
重要提示:请从仓库根目录出发,通过使用完整路径运行所有脚本。
${CLAUDE_SKILL_ROOT}Bundled Script
内置脚本
scripts/scan_skill.py
scripts/scan_skill.pyscripts/scan_skill.py
scripts/scan_skill.pyStatic analysis scanner that detects deterministic patterns. Outputs structured JSON.
bash
uv run ${CLAUDE_SKILL_ROOT}/scripts/scan_skill.py <skill-directory>Returns JSON with findings, URLs, structure info, and severity counts. The script catches patterns mechanically — your job is to evaluate intent and filter false positives.
一款静态分析扫描工具,可检测确定性模式,输出结构化JSON数据。
bash
uv run ${CLAUDE_SKILL_ROOT}/scripts/scan_skill.py <skill-directory>返回包含检测结果、URL信息、结构详情和严重程度统计的JSON数据。该脚本通过机械方式识别模式——您的工作是评估其意图并过滤误报。
Workflow
工作流程
Phase 1: Input & Discovery
阶段1:输入与发现
Determine the scan target:
- If the user provides a skill directory path, use it directly
- If the user names a skill, look for it under or
plugins/*/skills/<name>/.claude/skills/<name>/ - If the user says "scan all skills", discover all files and scan each
*/SKILL.md
Validate the target contains a file. List the skill structure:
SKILL.mdbash
ls -la <skill-directory>/
ls <skill-directory>/references/ 2>/dev/null
ls <skill-directory>/scripts/ 2>/dev/null确定扫描目标:
- 如果用户提供技能目录路径,直接使用该路径
- 如果用户指定技能名称,在或
plugins/*/skills/<name>/目录下查找.claude/skills/<name>/ - 如果用户要求「扫描所有技能」,找出所有文件并逐个扫描
*/SKILL.md
验证目标目录是否包含文件,列出技能结构:
SKILL.mdbash
ls -la <skill-directory>/
ls <skill-directory>/references/ 2>/dev/null
ls <skill-directory>/scripts/ 2>/dev/nullPhase 2: Automated Static Scan
阶段2:自动化静态扫描
Run the bundled scanner:
bash
uv run ${CLAUDE_SKILL_ROOT}/scripts/scan_skill.py <skill-directory>Parse the JSON output. The script produces findings with severity levels, URL analysis, and structure information. Use these as leads for deeper analysis.
Fallback: If the script fails, proceed with manual analysis using Grep patterns from the reference files.
运行内置扫描工具:
bash
uv run ${CLAUDE_SKILL_ROOT}/scripts/scan_skill.py <skill-directory>解析JSON输出结果。该脚本会生成包含严重程度等级、URL分析和结构信息的检测结果,可将这些作为深入分析的线索。
备选方案:如果脚本运行失败,可使用参考文件中的Grep规则进行手动分析。
Phase 3: Frontmatter Validation
阶段3:前置元数据验证
Read the SKILL.md and check:
- Required fields: and
namemust be presentdescription - Name consistency: field should match the directory name
name - Tool assessment: Review — is Bash justified? Are tools unrestricted (
allowed-tools)?* - Model override: Is a specific model forced? Why?
- Description quality: Does the description accurately represent what the skill does?
读取SKILL.md文件并检查:
- 必填字段:必须包含和
name字段description - 名称一致性:字段应与目录名称匹配
name - 工具评估:检查字段——是否确实需要Bash?是否设置了无限制工具(
allowed-tools)?* - 模型覆盖:是否强制使用特定模型?原因是什么?
- 描述准确性:描述内容是否准确反映了该技能的实际功能?
Phase 4: Prompt Injection Analysis
阶段4:提示注入分析
Load for context.
${CLAUDE_SKILL_ROOT}/references/prompt-injection-patterns.mdReview scanner findings in the "Prompt Injection" category. For each finding:
- Read the surrounding context in the file
- Determine if the pattern is performing injection (malicious) or discussing/detecting injection (legitimate)
- Skills about security, testing, or education commonly reference injection patterns — this is expected
Critical distinction: A security review skill that lists injection patterns in its references is documenting threats, not attacking. Only flag patterns that would execute against the agent running the skill.
加载文件作为参考。
${CLAUDE_SKILL_ROOT}/references/prompt-injection-patterns.md查看扫描结果中「提示注入」类别的检测项,针对每个检测项:
- 读取文件中的上下文内容
- 判断该模式是实施注入(恶意)还是讨论/检测注入(合法)
- 安全类、测试类或教育类技能通常会引用注入模式——这是正常现象
关键区分:一个列出注入模式的安全审查技能是在记录威胁,而非发起攻击。仅标记那些会对运行该技能的Agent执行注入的模式。
Phase 5: Behavioral Analysis
阶段5:行为分析
This phase is agent-only — no pattern matching. Read the full SKILL.md instructions and evaluate:
Description vs. instructions alignment:
- Does the description match what the instructions actually tell the agent to do?
- A skill described as "code formatter" that instructs the agent to read ~/.ssh is misaligned
Config/memory poisoning:
- Instructions to modify ,
CLAUDE.md,MEMORY.md,settings.json, or hook configurations.mcp.json - Instructions to add itself to allowlists or auto-approve permissions
- Writing to or any agent configuration directory
~/.claude/
Scope creep:
- Instructions that exceed the skill's stated purpose
- Unnecessary data gathering (reading files unrelated to the skill's function)
- Instructions to install other skills, plugins, or dependencies not mentioned in the description
Information gathering:
- Reading environment variables beyond what's needed
- Listing directory contents outside the skill's scope
- Accessing git history, credentials, or user data unnecessarily
此阶段仅需Agent执行——无需模式匹配。完整读取SKILL.md中的指令并评估:
描述与指令一致性:
- 描述内容是否与指令实际要求Agent执行的操作匹配?
- 例如,一个描述为「代码格式化工具」的技能若指令Agent读取~/.ssh目录,则属于不一致情况
配置/内存篡改:
- 是否有修改、
CLAUDE.md、MEMORY.md、settings.json或钩子配置的指令.mcp.json - 是否有将自身添加至允许列表或自动批准权限的指令
- 是否有写入或任何Agent配置目录的指令
~/.claude/
范围越界:
- 指令是否超出了技能声明的用途
- 是否存在不必要的数据收集(读取与技能功能无关的文件)
- 是否有安装描述中未提及的其他技能、插件或依赖的指令
信息收集:
- 是否读取超出需求的环境变量
- 是否列出技能范围外的目录内容
- 是否不必要地访问Git历史、凭证或用户数据
Phase 6: Script Analysis
阶段6:脚本分析
If the skill has a directory:
scripts/- Load for context
${CLAUDE_SKILL_ROOT}/references/dangerous-code-patterns.md - Read each script file fully (do not skip any)
- Check scanner findings in the "Malicious Code" category
- For each finding, evaluate:
- Data exfiltration: Does the script send data to external URLs? What data?
- Reverse shells: Socket connections with redirected I/O
- Credential theft: Reading SSH keys, .env files, tokens from environment
- Dangerous execution: eval/exec with dynamic input, shell=True with interpolation
- Config modification: Writing to agent settings, shell configs, git hooks
- Check PEP 723 — are they legitimate, well-known packages?
dependencies - Verify the script's behavior matches the SKILL.md description of what it does
Legitimate patterns: CLI calls, commands, reading project files, JSON output to stdout are normal for skill scripts.
ghgit如果技能包含目录:
scripts/- 加载文件作为参考
${CLAUDE_SKILL_ROOT}/references/dangerous-code-patterns.md - 完整读取每个脚本文件(请勿跳过任何内容)
- 查看扫描结果中「恶意代码」类别的检测项
- 针对每个检测项评估:
- 数据泄露:脚本是否会将数据发送至外部URL?发送的是什么数据?
- 反向Shell:是否存在重定向I/O的Socket连接
- 凭证窃取:是否读取SSH密钥、.env文件或环境变量中的令牌
- 危险执行:是否使用eval/exec处理动态输入,或在插值时使用shell=True
- 配置修改:是否修改Agent设置、Shell配置或Git钩子
- 检查PEP 723 ——依赖是否为合法、知名的包?
dependencies - 验证脚本行为是否与SKILL.md中的描述一致
合法模式: CLI调用、命令、读取项目文件、向标准输出打印JSON等均为技能脚本的正常操作。
ghgitPhase 7: Supply Chain Assessment
阶段7:供应链评估
Review URLs from the scanner output and any additional URLs found in scripts:
- Trusted domains: GitHub, PyPI, official docs — normal
- Untrusted domains: Unknown domains, personal sites, URL shorteners — flag for review
- Remote instruction loading: Any URL that fetches content to be executed or interpreted as instructions is high risk
- Dependency downloads: Scripts that download and execute binaries or code at runtime
- Unverifiable sources: References to packages or tools not on standard registries
查看扫描输出中的URL以及脚本中发现的其他URL:
- 可信域名:GitHub、PyPI、官方文档——正常
- 不可信域名:未知域名、个人网站、短链接——标记待审查
- 远程指令加载:任何获取内容并执行或解释为指令的URL均属于高风险
- 依赖下载:在运行时下载并执行二进制文件或代码的脚本
- 不可验证来源:引用未在标准注册表中的包或工具
Phase 8: Permission Analysis
阶段8:权限分析
Load for the tool risk matrix.
${CLAUDE_SKILL_ROOT}/references/permission-analysis.mdEvaluate:
- Least privilege: Are all granted tools actually used in the skill instructions?
- Tool justification: Does the skill body reference operations that require each tool?
- Risk level: Rate the overall permission profile using the tier system from the reference
Example assessments:
- — Low risk, read-only analysis skill
Read Grep Glob - — Medium risk, needs Bash justification (e.g., running bundled scripts)
Read Grep Glob Bash - — High risk, near-full access
Read Grep Glob Bash Write Edit WebFetch Task
加载文件中的工具风险矩阵。
${CLAUDE_SKILL_ROOT}/references/permission-analysis.md评估:
- 最小权限原则:所有授予的工具是否均在技能指令中实际使用?
- 工具合理性:技能主体是否提及需要使用每个工具的操作?
- 风险等级:使用参考文件中的层级系统对整体权限配置进行评级
评估示例:
- —— 低风险,仅读取分析类技能
Read Grep Glob - —— 中风险,需说明使用Bash的理由(例如运行内置脚本)
Read Grep Glob Bash - —— 高风险,接近完全访问权限
Read Grep Glob Bash Write Edit WebFetch Task
Confidence Levels
置信度等级
| Level | Criteria | Action |
|---|---|---|
| HIGH | Pattern confirmed + malicious intent evident | Report with severity |
| MEDIUM | Suspicious pattern, intent unclear | Note as "Needs verification" |
| LOW | Theoretical, best practice only | Do not report |
False positive awareness is critical. The biggest risk is flagging legitimate security skills as malicious because they reference attack patterns. Always evaluate intent before reporting.
| 等级 | 判定标准 | 操作 |
|---|---|---|
| 高 | 模式已确认且存在明显恶意意图 | 按严重程度上报 |
| 中 | 模式可疑,但意图不明确 | 标记为「需验证」 |
| 低 | 仅理论上存在风险,仅涉及最佳实践 | 无需上报 |
误报意识至关重要。最大的风险是将合法的安全技能标记为恶意,因为它们引用了攻击模式。上报前务必评估其意图。
Output Format
输出格式
markdown
undefinedmarkdown
undefinedSkill Security Scan: [Skill Name]
Skill安全扫描:[技能名称]
Summary
摘要
- Findings: X (Y Critical, Z High, ...)
- Risk Level: Critical / High / Medium / Low / Clean
- Skill Structure: SKILL.md only / +references / +scripts / full
- 检测结果:X项(Y项关键,Z项高风险,...)
- 风险等级:关键 / 高 / 中 / 低 / 无风险
- 技能结构:仅含SKILL.md / +参考文档 / +脚本 / 完整结构
Findings
检测结果
[SKILL-SEC-001] [Finding Type] (Severity)
[SKILL-SEC-001] [检测类型] (严重程度)
- Location: or
SKILL.md:42scripts/tool.py:15 - Confidence: High
- Category: Prompt Injection / Malicious Code / Excessive Permissions / Secret Exposure / Supply Chain / Validation
- Issue: [What was found]
- Evidence: [code snippet]
- Risk: [What could happen]
- Remediation: [How to fix]
- 位置:或
SKILL.md:42scripts/tool.py:15 - 置信度:高
- 类别:提示注入 / 恶意代码 / 过度权限 / 密钥泄露 / 供应链 / 验证
- 问题:[检测到的内容]
- 证据:[代码片段]
- 风险:[可能造成的影响]
- 修复建议:[修复方法]
Needs Verification
需验证项
[Medium-confidence items needing human review]
[置信度为中等、需人工审查的内容]
Assessment
评估结论
[Safe to install / Install with caution / Do not install]
[Brief justification for the assessment]
**Risk level determination**:
- **Critical**: Any high-confidence critical finding (prompt injection, credential theft, data exfiltration)
- **High**: High-confidence high-severity findings or multiple medium findings
- **Medium**: Medium-confidence findings or minor permission concerns
- **Low**: Only best-practice suggestions
- **Clean**: No findings after thorough analysis[可安全安装 / 谨慎安装 / 禁止安装]
[评估结论的简短理由]
**风险等级判定**:
- **关键**:存在任何高置信度的关键检测结果(提示注入、凭证窃取、数据泄露)
- **高**:存在高置信度的高严重程度检测结果,或多个中等严重程度结果
- **中**:存在中等置信度的检测结果,或轻微权限问题
- **低**:仅存在最佳实践建议
- **无风险**:经过全面分析未发现任何问题Reference Files
参考文件
| File | Purpose |
|---|---|
| Injection patterns, jailbreaks, obfuscation techniques, false positive guide |
| Script security patterns: exfiltration, shells, credential theft, eval/exec |
| Tool risk tiers, least privilege methodology, common skill permission profiles |
| 文件 | 用途 |
|---|---|
| 注入模式、越狱技术、混淆手段、误报指南 |
| 脚本安全模式:数据泄露、Shell、凭证窃取、eval/exec |
| 工具风险层级、最小权限方法论、常见技能权限配置 |