Security Check
Run a focused security analysis on a PR diff. Checks for OWASP Top 10 vulnerabilities, hardcoded secrets, auth gaps, and dependency risks.
Usage
/check-security — Check the current PR branch
/check-security 42 — Check PR #42
Also works as @claude check security in GitHub PR comments.
Process
1. Get the changes
gh pr view --json number,title,body,files
gh pr diff
2. Security checklist
Analyze every changed file against these categories:
Input Validation
- Are all user inputs validated before use?
- Are inputs sanitized for the context (HTML, SQL, shell, regex)?
- Are file uploads validated (type, size, content)?
- Are URL parameters and query strings validated?
- Are request bodies validated against a schema?
Injection
- SQL: Are all queries parameterized? No string concatenation for SQL?
- XSS: Is output escaped in templates? Any
dangerouslySetInnerHTML?
- Command injection: Are shell commands built from user input?
- Path traversal: Are file paths validated? No
../ in user input?
- SSRF: Are URLs fetched from user input validated against allowlists?
Authentication & Authorization
- Do protected routes check authentication?
- Is authorization checked (not just authentication)?
- Are JWT tokens validated properly (signature, expiration, issuer)?
- Are session tokens regenerated after login?
- Is password handling done with proper hashing (bcrypt, argon2)?
Secrets & Configuration
- Are there hardcoded API keys, tokens, or passwords?
- Are secrets read from environment variables, not code?
- Is
.env in .gitignore?
- Are default credentials or admin passwords present?
- Are error messages leaking internal details (stack traces, DB schemas)?
Dependencies
- Were new dependencies added? Run
npm audit / pnpm audit if so
- Are dependencies pinned to specific versions?
- Are there known vulnerabilities in new/updated packages?
Data Protection
- Is sensitive data encrypted at rest and in transit?
- Are PII fields properly handled (logging, serialization)?
- Is CSRF protection in place for state-changing operations?
- Are rate limits configured on public-facing endpoints?
- Are CORS headers properly configured?
3. Output format
## Security Review
### Summary
<1-2 sentence overview. Include count of findings by severity.>
### 🔴 Critical
Must fix before merge — exploitable vulnerabilities.
- **`file:line`** — <vulnerability type>
**Risk**: <what an attacker could do>
**Fix**: <concrete remediation>
### 🟡 Warning
Should fix — creates risk but not immediately exploitable.
- **`file:line`** — <issue description>
**Risk**: <potential impact>
**Fix**: <concrete remediation>
### ℹ️ Info
Best practice suggestions for defense in depth.
- **`file:line`** — <suggestion>
**Fix**: <concrete improvement>
### Dependency Audit
<Results of npm/pnpm audit if new dependencies were added, or "No new dependencies">
### Verdict
<PASS | FAIL | NEEDS_ATTENTION>
<justification>
Rules
- ALWAYS fetch the actual PR diff — never review from memory
- ALWAYS explain the risk (what an attacker could do), not just the issue
- ALWAYS provide a concrete fix, not just "validate input"
- Flag hardcoded secrets as 🔴 Critical — always
- If new dependencies were added, run the package audit
- Don't flag test files for security issues (test fixtures are fine)
- Don't flag development-only code (devDependencies, scripts) unless it ships to production
1---2name: check-security3description: Security-focused review of a PR — injection, XSS, auth, secrets, dependencies4---56# Security Check78Run a focused security analysis on a PR diff. Checks for OWASP Top 10 vulnerabilities, hardcoded secrets, auth gaps, and dependency risks.910## Usage1112```13/check-security — Check the current PR branch14/check-security 42 — Check PR #4215```1617Also works as `@claude check security` in GitHub PR comments.1819## Process2021### 1. Get the changes2223```bash24gh pr view --json number,title,body,files25gh pr diff26```2728### 2. Security checklist2930Analyze every changed file against these categories:3132#### Input Validation33- Are all user inputs validated before use?34- Are inputs sanitized for the context (HTML, SQL, shell, regex)?35- Are file uploads validated (type, size, content)?36- Are URL parameters and query strings validated?37- Are request bodies validated against a schema?3839#### Injection40- **SQL**: Are all queries parameterized? No string concatenation for SQL?41- **XSS**: Is output escaped in templates? Any `dangerouslySetInnerHTML`?42- **Command injection**: Are shell commands built from user input?43- **Path traversal**: Are file paths validated? No `../` in user input?44- **SSRF**: Are URLs fetched from user input validated against allowlists?4546#### Authentication & Authorization47- Do protected routes check authentication?48- Is authorization checked (not just authentication)?49- Are JWT tokens validated properly (signature, expiration, issuer)?50- Are session tokens regenerated after login?51- Is password handling done with proper hashing (bcrypt, argon2)?5253#### Secrets & Configuration54- Are there hardcoded API keys, tokens, or passwords?55- Are secrets read from environment variables, not code?56- Is `.env` in `.gitignore`?57- Are default credentials or admin passwords present?58- Are error messages leaking internal details (stack traces, DB schemas)?5960#### Dependencies61- Were new dependencies added? Run `npm audit` / `pnpm audit` if so62- Are dependencies pinned to specific versions?63- Are there known vulnerabilities in new/updated packages?6465#### Data Protection66- Is sensitive data encrypted at rest and in transit?67- Are PII fields properly handled (logging, serialization)?68- Is CSRF protection in place for state-changing operations?69- Are rate limits configured on public-facing endpoints?70- Are CORS headers properly configured?7172### 3. Output format7374```markdown75## Security Review7677### Summary78<1-2 sentence overview. Include count of findings by severity.>7980### 🔴 Critical81Must fix before merge — exploitable vulnerabilities.8283- **`file:line`** — <vulnerability type>84 **Risk**: <what an attacker could do>85 **Fix**: <concrete remediation>8687### 🟡 Warning88Should fix — creates risk but not immediately exploitable.8990- **`file:line`** — <issue description>91 **Risk**: <potential impact>92 **Fix**: <concrete remediation>9394### ℹ️ Info95Best practice suggestions for defense in depth.9697- **`file:line`** — <suggestion>98 **Fix**: <concrete improvement>99100### Dependency Audit101<Results of npm/pnpm audit if new dependencies were added, or "No new dependencies">102103### Verdict104<PASS | FAIL | NEEDS_ATTENTION>105<justification>106```107108## Rules109110- ALWAYS fetch the actual PR diff — never review from memory111- ALWAYS explain the **risk** (what an attacker could do), not just the issue112- ALWAYS provide a concrete fix, not just "validate input"113- Flag hardcoded secrets as 🔴 Critical — always114- If new dependencies were added, run the package audit115- Don't flag test files for security issues (test fixtures are fine)116- Don't flag development-only code (devDependencies, scripts) unless it ships to production