security-scan
AgentShield を使用して、Claude Code の設定(.claude/ ディレクトリ)のセキュリティ脆弱性、設定ミス、インジェクションリスクをスキャンします。CLAUDE.md、settings.json、MCP サーバー、フック、エージェント定義をチェックします。
About this skill
This skill leverages the AgentShield tool to conduct a thorough security audit of your Claude AI agent's project configuration, specifically targeting the `.claude/` directory. It systematically checks critical files and components like `CLAUDE.md`, `settings.json`, MCP server configurations (`mcp.json`), custom hooks (`hooks/`), and agent definitions (`agents/*.md`) for potential security weaknesses. The scan identifies issues such as hardcoded secrets, overly permissive settings, prompt injection vulnerabilities, command injection risks, dangerous bypass flags, supply chain risks, and data exfiltration patterns, ensuring your Claude Code setup adheres to robust security practices. This proactive approach helps maintain a secure development lifecycle for AI agents.
Best use case
Proactively identify and remediate security flaws in Claude AI agent configurations, integrate security checks into the AI agent development lifecycle, and ensure compliance with security best practices for Claude Code deployments.
AgentShield を使用して、Claude Code の設定(.claude/ ディレクトリ)のセキュリティ脆弱性、設定ミス、インジェクションリスクをスキャンします。CLAUDE.md、settings.json、MCP サーバー、フック、エージェント定義をチェックします。
A detailed report outlining identified security vulnerabilities, misconfigurations, and injection risks within the Claude Code project's `.claude/` directory, along with potential recommendations for remediation.
Practical example
Example input
The agent would be instructed to perform a security scan on a specified Claude Code project path, for example: `security-scan --project-path ./my-claude-project` or simply `security-scan` when within the project's context.
Example output
```json
{
"scan_results": {
"status": "completed",
"findings": [
{
"file": "CLAUDE.md",
"type": "Hardcoded Secret",
"severity": "High",
"description": "Found potential hardcoded API key 'sk-...' in CLAUDE.md. Consider using environment variables.",
"line": 15
},
{
"file": "settings.json",
"type": "Misconfiguration",
"severity": "Medium",
"description": "Whitelist for tool access is overly permissive, allowing access to all local files. Recommend restricting to specific directories.",
"path": "tools.allow_list"
},
{
"file": "agents/my_agent.md",
"type": "Prompt Injection Risk",
"severity": "Medium",
"description": "Agent definition includes user-controlled input directly into a tool call without sanitization, creating a potential prompt injection vector.",
"line": 30
},
{
"file": "mcp.json",
"type": "Supply Chain Risk",
"severity": "Low",
"description": "MCP server definition uses 'npx' directly without version pinning. Risk of executing outdated or malicious packages.",
"path": "servers[0].command"
}
],
"summary": {
"High": 1,
"Medium": 2,
"Low": 1,
"Total": 4
},
"recommendations": [
"Review all identified high-severity issues immediately.",
"Implement proper secret management practices.",
"Refine access control lists for tools and resources.",
"Sanitize all user-controlled inputs before feeding them to agent prompts or tool calls."
]
}
}
```When to use this skill
- Upon setting up a new Claude Code project.
- After making changes to `.claude/settings.json`, `CLAUDE.md`, or MCP server configurations.
- Before committing configuration changes to a version control system.
- When onboarding to a new repository that contains existing Claude Code configurations.
When not to use this skill
- If you are not working with a Claude AI agent project or its `.claude/` directory.
- When a full, in-depth penetration test or comprehensive security audit of an entire application or system is required (this skill focuses specifically on Claude Code configurations).
- If you already have another dedicated security scanning tool that covers these specific Claude configuration files.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/security-scan/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How security-scan Compares
| Feature / Agent | security-scan | Standard Approach |
|---|---|---|
| Platform Support | Claude | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | easy | N/A |
Frequently Asked Questions
What does this skill do?
AgentShield を使用して、Claude Code の設定(.claude/ ディレクトリ)のセキュリティ脆弱性、設定ミス、インジェクションリスクをスキャンします。CLAUDE.md、settings.json、MCP サーバー、フック、エージェント定義をチェックします。
Which AI agents support this skill?
This skill is designed for Claude.
How difficult is it to install?
The installation complexity is rated as easy. You can find the installation instructions above.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
SKILL.md Source
# Security Scan Skill
[AgentShield](https://github.com/affaan-m/agentshield) を使用して、Claude Code の設定のセキュリティ問題を監査します。
## 起動タイミング
- 新しい Claude Code プロジェクトのセットアップ時
- `.claude/settings.json`、`CLAUDE.md`、または MCP 設定の変更後
- 設定変更をコミットする前
- 既存の Claude Code 設定を持つ新しいリポジトリにオンボーディングする際
- 定期的なセキュリティ衛生チェック
## スキャン対象
| ファイル | チェック内容 |
|------|--------|
| `CLAUDE.md` | ハードコードされたシークレット、自動実行命令、プロンプトインジェクションパターン |
| `settings.json` | 過度に寛容な許可リスト、欠落した拒否リスト、危険なバイパスフラグ |
| `mcp.json` | リスクのある MCP サーバー、ハードコードされた環境シークレット、npx サプライチェーンリスク |
| `hooks/` | 補間によるコマンドインジェクション、データ流出、サイレントエラー抑制 |
| `agents/*.md` | 無制限のツールアクセス、プロンプトインジェクション表面、欠落したモデル仕様 |
## 前提条件
AgentShield がインストールされている必要があります。確認し、必要に応じてインストールします:
```bash
# インストール済みか確認
npx ecc-agentshield --version
# グローバルにインストール(推奨)
npm install -g ecc-agentshield
# または npx 経由で直接実行(インストール不要)
npx ecc-agentshield scan .
```
## 使用方法
### 基本スキャン
現在のプロジェクトの `.claude/` ディレクトリに対して実行します:
```bash
# 現在のプロジェクトをスキャン
npx ecc-agentshield scan
# 特定のパスをスキャン
npx ecc-agentshield scan --path /path/to/.claude
# 最小深刻度フィルタでスキャン
npx ecc-agentshield scan --min-severity medium
```
### 出力フォーマット
```bash
# ターミナル出力(デフォルト) — グレード付きのカラーレポート
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
```
### 自動修正
安全な修正を自動的に適用します(自動修正可能とマークされた修正のみ):
```bash
npx ecc-agentshield scan --fix
```
これにより以下が実行されます:
- ハードコードされたシークレットを環境変数参照に置き換え
- ワイルドカード権限をスコープ付き代替に厳格化
- 手動のみの提案は変更しない
### Opus 4.6 ディープ分析
より深い分析のために敵対的な3エージェントパイプラインを実行します:
```bash
# ANTHROPIC_API_KEY が必要
export ANTHROPIC_API_KEY=your-key
npx ecc-agentshield scan --opus --stream
```
これにより以下が実行されます:
1. **攻撃者(レッドチーム)** — 攻撃ベクトルを発見
2. **防御者(ブルーチーム)** — 強化を推奨
3. **監査人(最終判定)** — 両方の観点を統合
### 安全な設定の初期化
新しい安全な `.claude/` 設定をゼロから構築します:
```bash
npx ecc-agentshield init
```
作成されるもの:
- スコープ付き権限と拒否リストを持つ `settings.json`
- セキュリティベストプラクティスを含む `CLAUDE.md`
- `mcp.json` プレースホルダー
### GitHub Action
CI パイプラインに追加します:
```yaml
- uses: affaan-m/agentshield@v1
with:
path: '.'
min-severity: 'medium'
fail-on-findings: true
```
## 深刻度レベル
| グレード | スコア | 意味 |
|-------|-------|---------|
| A | 90-100 | 安全な設定 |
| B | 75-89 | 軽微な問題 |
| C | 60-74 | 注意が必要 |
| D | 40-59 | 重大なリスク |
| F | 0-39 | クリティカルな脆弱性 |
## 結果の解釈
### クリティカルな発見(即座に修正)
- 設定ファイル内のハードコードされた API キーまたはトークン
- 許可リスト内の `Bash(*)`(無制限のシェルアクセス)
- `${file}` 補間によるフック内のコマンドインジェクション
- シェルを実行する MCP サーバー
### 高い発見(本番前に修正)
- CLAUDE.md 内の自動実行命令(プロンプトインジェクションベクトル)
- 権限内の欠落した拒否リスト
- 不要な Bash アクセスを持つエージェント
### 中程度の発見(推奨)
- フック内のサイレントエラー抑制(`2>/dev/null`、`|| true`)
- 欠落した PreToolUse セキュリティフック
- MCP サーバー設定内の `npx -y` 自動インストール
### 情報の発見(認識)
- MCP サーバーの欠落した説明
- 正しくフラグ付けされた禁止命令(グッドプラクティス)
## リンク
- **GitHub**: [github.com/affaan-m/agentshield](https://github.com/affaan-m/agentshield)
- **npm**: [npmjs.com/package/ecc-agentshield](https://www.npmjs.com/package/ecc-agentshield)Related Skills
perl-security
全面的Perl安全指南,涵盖污染模式、输入验证、安全进程执行、DBI参数化查询、Web安全(XSS/SQLi/CSRF)以及perlcritic安全策略。
security-review
Use this skill when adding authentication, handling user input, working with secrets, creating API endpoints, or implementing payment/sensitive features. Provides comprehensive security checklist and patterns.
mobile-security-coder
Expert in secure mobile coding practices specializing in input validation, WebView security, and mobile-specific security patterns.
laravel-security-audit
Security auditor for Laravel applications. Analyzes code for vulnerabilities, misconfigurations, and insecure practices using OWASP standards and Laravel security best practices.
frontend-security-coder
Expert in secure frontend coding practices specializing in XSS prevention, output sanitization, and client-side security patterns.
frontend-mobile-security-xss-scan
You are a frontend security specialist focusing on Cross-Site Scripting (XSS) vulnerability detection and prevention. Analyze React, Vue, Angular, and vanilla JavaScript code to identify injection poi
azure-security-keyvault-keys-java
Azure Key Vault Keys Java SDK for cryptographic key management. Use when creating, managing, or using RSA/EC keys, performing encrypt/decrypt/sign/verify operations, or working with HSM-backed keys.
azure-security-keyvault-keys-dotnet
Azure Key Vault Keys SDK for .NET. Client library for managing cryptographic keys in Azure Key Vault and Managed HSM. Use for key creation, rotation, encryption, decryption, signing, and verification.
mtls-configuration
Configure mutual TLS (mTLS) for zero-trust service-to-service communication. Use when implementing zero-trust networking, certificate management, or securing internal service communication.
malware-analyst
Expert malware analyst specializing in defensive malware research, threat intelligence, and incident response. Masters sandbox analysis, behavioral analysis, and malware family identification.
linux-privilege-escalation
Execute systematic privilege escalation assessments on Linux systems to identify and exploit misconfigurations, vulnerable services, and security weaknesses that allow elevation from low-privilege user access to root-level control.
differential-review
Security-focused code review for PRs, commits, and diffs.