security-review
The security-review slash command performs comprehensive vulnerability analysis on source code using CWE Top 25 patterns and STRIDE threat modeling. It supports multiple scan modes including auto-detection of sensitive files, quick scanning of recent changes, dependency checking, and report generation in markdown or JSON formats. The command enforces maximum analysis depth for accuracy and includes auto-triggering expanded scans when critical patterns like authentication, payment, or cryptographic code are detected.
mkdir -p ~/.claude/commands && curl -fsSL https://raw.githubusercontent.com/sangrokjung/claude-forge/HEAD/commands/security-review.md -o ~/.claude/commands/security-review.mdsecurity-review.md
## Task
### 0단계: effort:max 강제
```
⚠️ Security Review는 항상 effort:max로 실행됩니다.
이는 보안 품질을 위해 타협할 수 없는 설정입니다.
모든 분석은 최대 깊이로 수행되며, 축약하지 않습니다.
```
effort:max를 내부적으로 강제 적용한다. 보안 검토는 속도보다 정확성이 우선이며,
shallow scan은 허용하지 않는다.
---
### 1단계: 스캔 대상 식별
**파라미터 파싱:**
- `[경로]`: 특정 파일 또는 디렉토리 지정
- `--auto`: git diff 기반 변경 파일만 스캔 (민감 패턴 감지 시 자동 트리거)
- `--quick`: 변경 파일 대상 빠른 스캔 (CWE 상위 10개만)
- `--cwe`: CWE Top 25 전체 매핑 상세 분석
- `--stride`: STRIDE 위협 모델링 추가 실행
- `--deps`: 의존성 취약점 검사
- `--report [형식]`: markdown 또는 json 리포트 파일 생성
**스캔 범위 결정:**
```bash
# --auto: git diff 변경 파일만
git diff --cached --name-only | grep -E '\.(ts|tsx|js|jsx|py|go|rs|java)$'
git diff --name-only | grep -E '\.(ts|tsx|js|jsx|py|go|rs|java)$'
# --quick: 변경 파일 빠른 스캔
git diff --name-only HEAD~1 | grep -E '\.(ts|tsx|js|jsx|py|go|rs|java)$'
# 기본 (플래그 없음): 전체 소스 파일
find src/ lib/ app/ -type f -name '*.ts' -o -name '*.tsx' -o -name '*.js' -o -name '*.jsx'
```
**Auto-trigger 패턴 (--auto 모드에서 파일 경로/내용에 포함 시 자동 확대 스캔):**
| 패턴 | 위험 수준 | 설명 |
|------|-----------|------|
| `auth` | Critical | 인증 관련 코드 |
| `payment` | Critical | 결제 처리 코드 |
| `session` | High | 세션 관리 |
| `token` | High | 토큰 발급/검증 |
| `password` | Critical | 비밀번호 처리 |
| `secret` | Critical | 시크릿/키 관리 |
| `crypto` | High | 암호화 로직 |
| `jwt` | High | JWT 토큰 처리 |
| `admin` | High | 관리자 기능 |
| `upload` | Medium | 파일 업로드 |
| `download` | Medium | 파일 다운로드 |
| `redirect` | Medium | URL 리다이렉트 |
---
### 2단계: CWE Top 25 매핑
모든 소스 파일에 대해 CWE Top 25 기반 패턴 매칭을 수행한다.
각 발견 항목에는 반드시 CWE ID를 태깅한다.
```
┌─────────┬──────────────────────────────┬───────────────────────────────┬──────┐
│ CWE ID │ Name │ Detection Pattern │ Sev │
├─────────┼──────────────────────────────┼───────────────────────────────┼──────┤
│ CWE-79 │ Cross-site Scripting (XSS) │ innerHTML, dangerouslySet*, │ Crit │
│ │ │ v-html, [innerHTML]= │ │
├─────────┼──────────────────────────────┼───────────────────────────────┼──────┤
│ CWE-89 │ SQL Injection │ query( + string concat/ │ Crit │
│ │ │ template literal with ${}, │ │
│ │ │ .raw( + user input │ │
├─────────┼──────────────────────────────┼───────────────────────────────┼──────┤
│ CWE-78 │ OS Command Injection │ exec(, spawn(, execSync( │ Crit │
│ │ │ + user-controlled input │ │
├─────────┼──────────────────────────────┼───────────────────────────────┼──────┤
│ CWE-22 │ Path Traversal │ ../ in user-supplied paths, │ High │
│ │ │ path.join( + req.params │ │
├─────────┼──────────────────────────────┼───────────────────────────────┼──────┤
│ CWE-352 │ Cross-Site Request Forgery │ POST/PUT/DELETE without │ High │
│ │ │ CSRF token validation │ │
├─────────┼──────────────────────────────┼───────────────────────────────┼──────┤
│ CWE-287 │ Improper Authentication │ Missing auth middleware, │ High │
│ │ │ auth check bypass │ │
├─────────┼──────────────────────────────┼───────────────────────────────┼──────┤
│ CWE-862 │ Missing Authorization │ Route handler without authz, │ High │
│ │ │ direct object reference │ │
├─────────┼──────────────────────────────┼───────────────────────────────┼──────┤
│ CWE-798 │ Hardcoded Credentials │ apiKey=", secret=", pass=", │ Crit │
│ │ │ token=", key=" (literals) │ │
├─────────┼──────────────────────────────┼───────────────────────────────┼──────┤
│ CWE-200 │ Exposure of Sensitive Info │ console.log + secret/token/ │ Med │
│ │ │ password, error stack trace │ │
│ │ │ in response │ │
├─────────┼──────────────────────────────┼───────────────────────────────┼──────┤
│ CWE-502 │ Deserialization of Untrusted │ JSON.parse(untrusted), │ High │
│ │ Data │ eval(, new Function( │ │
├─────────┼──────────────────────────────┼───────────────────────────────┼──────┤
│ CWE-306 │ Missing Authentication for │ Critical endpoint without │ High │
│ │ Critical Function │ auth guard │ │
├─────────┼──────────────────────────────┼───────────────────────────────┼──────┤
│ CWE-20 │ Improper Input Validation │ No schema validation (zod/ │ Med │
│ │ │ joi), missing sanitization │ │
├─────────┼──────────────────────────────┼───────────────────────────────┼──────┤
│ CWE-269 │ Improper Privilege Mgmt │ Role escalation, missing │ High │
│ │ │ role check │ │
├─────────┼──────────────────────────────┼───────────────────────────────┼──────┤
│ CWE-434 │ Unrestricted Upload │ File upload without type/ │ High │
│ │ │ size validation │ │
├─────────┼──────────────────────────────┼───────────────────────────────┼──────┤
│ CWE-918 │ Server-Side Request Forgery │ fetch/axios with user URL, │ High │
│ │ │ no URL allowlist │ │
├─────────┼──────────────────────────────┼───────────────────────────────┼──────┤
│ CWE-611 │ XML External Entity (XXE) │ XML parser without disabled │ High │
│ │ │ external entities │ │
├─────────┼──────────────────────────────┼───────────────────────────────┼──────┤
│ CWE-77 │ Command Injection │ Template strings in shell │ Crit │
│ │ │ commands │ │
├──|
|
|
Use when writing SQL queries, creating migrations, or troubleshooting database performance in Supabase/PostgreSQL projects. Reviews indexes, RLS policies, schema types, N+1 patterns. Read-only reviewer with EXPLAIN ANALYZE capability.
|
|
|
|