Run a comprehensive security scan on the codebase.
Iron Law
No "probably safe." Verify or flag.
If you cannot confirm a pattern is secure, flag it. False positives are cheap. Missed vulnerabilities are not.
Scan Checklist
1. Hardcoded Secrets (CRITICAL)
grep -rn "password\s*=\|api_key\s*=\|secret\s*=\|token\s*=" src/
grep -rn "BEGIN.*PRIVATE KEY" .
grep -rn "sk-\|pk_\|ghp_\|gho_\|AKIA" src/
Also check for:
- Base64-encoded secrets (long random strings in config)
- Secrets in comments ("// old password was...")
- Secrets in test fixtures that match production patterns
2. SQL Injection
- String concatenation in SQL queries (
"SELECT * FROM " + table)
- Raw queries without parameterization
- ORM bypass with raw SQL
- Dynamic table/column names from user input
3. XSS (Cross-Site Scripting)
dangerouslySetInnerHTML, innerHTML, document.write
- Template rendering with unescaped user input (
{!! !!}, | safe, <%- %>)
- URL parameters reflected in page without encoding
- SVG/image uploads that could contain scripts
4. Command Injection
exec(), spawn(), system() with user-controlled input
- Template strings in shell commands
- Unsanitized filenames in file operations
5. Authentication & Authorization
- Routes/endpoints missing auth middleware
- Role checks that can be bypassed (client-side only)
- Password hashing (must be bcrypt/argon2/scrypt — NOT md5/sha1/sha256)
- JWT: check expiry validation, algorithm confusion, secret strength
- Session fixation or missing session regeneration on login
6. Input Validation
- API endpoints accepting unvalidated input
- Missing type checks, length limits, format validation
- File upload: missing type restrictions, size limits, path traversal
- Regex DoS (ReDoS) — catastrophic backtracking patterns
7. Sensitive Data Exposure
- Sensitive data in logs (passwords, tokens, PII)
- Stack traces or internal paths in error responses
.env files not in .gitignore
- Sensitive data in URL query parameters (logged by proxies)
- Missing HTTPS enforcement
8. Dependency Vulnerabilities
npm audit 2>/dev/null || pip audit 2>/dev/null || true
Check for known CVEs in dependencies.
9. Insecure Configuration
- CORS: overly permissive (
Access-Control-Allow-Origin: *)
- Missing security headers (CSP, HSTS, X-Frame-Options)
- Cookie settings: missing httpOnly, secure, sameSite flags
- Debug mode enabled in production config
- Default credentials in config files
Anti-Rationalization
| Excuse |
Rebuttal |
| "This is internal/admin-only code" |
Internal code gets exposed via SSRF, insider threats, and supply chain attacks. Secure it. |
| "We're behind a firewall" |
Firewalls fail. Defense in depth means every layer is secure. |
| "This secret is only in development" |
Dev secrets leak to production. Use env vars and secret managers. |
| "Nobody would find this endpoint" |
Security through obscurity is not security. Assume attackers find everything. |
| "The framework handles this automatically" |
Verify. Frameworks have defaults, and defaults get overridden. |
| "This is a low-priority app" |
Low-priority apps are pivot points. Attackers use them to reach high-priority systems. |
| "We'll fix it later" |
Later never comes. Flag it now with severity. |
Pre-Delivery Checklist
Before presenting the report, verify:
Output Format
## Security Scan Report
### Critical (exploit risk — fix immediately)
- [file:line] [vulnerability] — [impact] — [fix]
### High (significant risk)
- [file:line] [vulnerability] — [impact] — [fix]
### Medium (moderate risk)
- [file:line] [vulnerability] — [impact] — [fix]
### Low (minor risk / hardening)
- [file:line] [issue] — [recommendation]
### Passed Checks
- [what looks good — acknowledge secure patterns]
### Prioritized Recommendations
1. [most urgent fix]
2. [next priority]
3. [etc.]
1---2name: security-scan3description: Use when the user wants a security audit, vulnerability scan, or asks about potential security issues.4---56Run a comprehensive security scan on the codebase.78## Iron Law910> **No "probably safe." Verify or flag.**11> If you cannot confirm a pattern is secure, flag it. False positives are cheap. Missed vulnerabilities are not.1213## Scan Checklist1415### 1. Hardcoded Secrets (CRITICAL)16```17grep -rn "password\s*=\|api_key\s*=\|secret\s*=\|token\s*=" src/18grep -rn "BEGIN.*PRIVATE KEY" .19grep -rn "sk-\|pk_\|ghp_\|gho_\|AKIA" src/20```21Also check for:22- Base64-encoded secrets (long random strings in config)23- Secrets in comments ("// old password was...")24- Secrets in test fixtures that match production patterns2526### 2. SQL Injection27- String concatenation in SQL queries (`"SELECT * FROM " + table`)28- Raw queries without parameterization29- ORM bypass with raw SQL30- Dynamic table/column names from user input3132### 3. XSS (Cross-Site Scripting)33- `dangerouslySetInnerHTML`, `innerHTML`, `document.write`34- Template rendering with unescaped user input (`{!! !!}`, `| safe`, `<%- %>`)35- URL parameters reflected in page without encoding36- SVG/image uploads that could contain scripts3738### 4. Command Injection39- `exec()`, `spawn()`, `system()` with user-controlled input40- Template strings in shell commands41- Unsanitized filenames in file operations4243### 5. Authentication & Authorization44- Routes/endpoints missing auth middleware45- Role checks that can be bypassed (client-side only)46- Password hashing (must be bcrypt/argon2/scrypt — NOT md5/sha1/sha256)47- JWT: check expiry validation, algorithm confusion, secret strength48- Session fixation or missing session regeneration on login4950### 6. Input Validation51- API endpoints accepting unvalidated input52- Missing type checks, length limits, format validation53- File upload: missing type restrictions, size limits, path traversal54- Regex DoS (ReDoS) — catastrophic backtracking patterns5556### 7. Sensitive Data Exposure57- Sensitive data in logs (passwords, tokens, PII)58- Stack traces or internal paths in error responses59- `.env` files not in `.gitignore`60- Sensitive data in URL query parameters (logged by proxies)61- Missing HTTPS enforcement6263### 8. Dependency Vulnerabilities64```65npm audit 2>/dev/null || pip audit 2>/dev/null || true66```67Check for known CVEs in dependencies.6869### 9. Insecure Configuration70- CORS: overly permissive (`Access-Control-Allow-Origin: *`)71- Missing security headers (CSP, HSTS, X-Frame-Options)72- Cookie settings: missing httpOnly, secure, sameSite flags73- Debug mode enabled in production config74- Default credentials in config files7576## Anti-Rationalization7778| Excuse | Rebuttal |79|--------|----------|80| "This is internal/admin-only code" | Internal code gets exposed via SSRF, insider threats, and supply chain attacks. Secure it. |81| "We're behind a firewall" | Firewalls fail. Defense in depth means every layer is secure. |82| "This secret is only in development" | Dev secrets leak to production. Use env vars and secret managers. |83| "Nobody would find this endpoint" | Security through obscurity is not security. Assume attackers find everything. |84| "The framework handles this automatically" | Verify. Frameworks have defaults, and defaults get overridden. |85| "This is a low-priority app" | Low-priority apps are pivot points. Attackers use them to reach high-priority systems. |86| "We'll fix it later" | Later never comes. Flag it now with severity. |8788## Pre-Delivery Checklist8990Before presenting the report, verify:9192- [ ] All 9 scan categories were checked (not skipped)93- [ ] Every finding has a file:line reference94- [ ] Severity levels are justified (not guessed)95- [ ] No "probably safe" — each item is verified or flagged96- [ ] Dependency audit command was actually run97- [ ] .env and .gitignore were checked98- [ ] Auth middleware coverage was mapped to routes99- [ ] Passed checks section acknowledges secure patterns found100- [ ] Recommendations are prioritized by actual risk, not alphabetical101102## Output Format103104```105## Security Scan Report106107### Critical (exploit risk — fix immediately)108- [file:line] [vulnerability] — [impact] — [fix]109110### High (significant risk)111- [file:line] [vulnerability] — [impact] — [fix]112113### Medium (moderate risk)114- [file:line] [vulnerability] — [impact] — [fix]115116### Low (minor risk / hardening)117- [file:line] [issue] — [recommendation]118119### Passed Checks120- [what looks good — acknowledge secure patterns]121122### Prioritized Recommendations1231. [most urgent fix]1242. [next priority]1253. [etc.]126```127128<!-- Skill by Huzefa Nalkheda Wala | github.com/huzaifa525 | claude-code-optimizer -->