| name | security-reviewer |
| description | Comprehensive application security reviewer for web apps, mobile apps, APIs, and infrastructure. Runs automated scans (Semgrep SAST, Gitleaks secrets, npm/pip audit, dependency checks) and manual code review against OWASP Top 10, CWE Top 25, STRIDE threat model, and SLSA compliance. Use when: reviewing code for vulnerabilities, scanning for exposed secrets/API keys, auditing dependencies, checking security headers, conducting threat modeling, performing pre-deployment security checks, or running end-of-session security sweeps. Triggers on: security review, vulnerability scan, secret detection, dependency audit, penetration test prep, compliance check, threat model, security assessment. |
Security Reviewer - Application Security Intelligence
Comprehensive security review system for web apps, mobile apps, APIs, and infrastructure. Combines automated scanning tools with expert manual review against industry frameworks.
When to Use
Must Use (automatic triggers):
- Before any deployment or push to production
- End of development session (security sweep)
- After adding new dependencies
- After implementing auth/payment/data-handling features
- When handling user input, file uploads, or external data
- When configuring CORS, CSP, or other security headers
- When reviewing PRs that touch security-sensitive code
Recommended:
- After significant refactoring
- When onboarding new APIs or third-party services
- Periodic codebase health checks
- Before security audits or compliance reviews
Automated Scanning Tools
1. Semgrep (SAST - Static Analysis)
Scans code for vulnerability patterns across 30+ languages.
semgrep scan --config auto .
semgrep scan --config "p/owasp-top-ten" .
semgrep scan --config "p/secrets" .
semgrep scan --config "p/javascript" .
semgrep scan --config "p/python" .
semgrep scan --config "p/typescript" .
semgrep scan --config "p/react" .
semgrep scan --config auto --json .
semgrep scan --config auto src/auth/ src/api/
Key rulesets:
p/owasp-top-ten — OWASP Top 10 vulnerabilities
p/secrets — Hardcoded secrets and credentials
p/security-audit — Broad security patterns
p/javascript / p/typescript / p/python / p/react — Language-specific
p/jwt — JWT implementation issues
p/sql-injection — SQL injection patterns
p/xss — Cross-site scripting patterns
2. Gitleaks (Secret Detection)
Scans git history and working directory for exposed secrets.
gitleaks detect -s . -v
gitleaks detect -v
gitleaks detect -s . -f json -r gitleaks-report.json
gitleaks detect -s ./src -v
3. npm audit (JavaScript Dependencies)
npm audit
npm audit --json
npm audit fix
npm audit --omit=dev
4. pip-audit (Python Dependencies)
pip-audit
pip-audit -r requirements.txt
pip-audit --format json
pip-audit --fix
5. GitHub Security Features (via gh CLI)
gh api repos/{owner}/{repo}/dependabot/alerts --jq '.[].security_advisory.summary'
gh api repos/{owner}/{repo}/secret-scanning/alerts --jq '.[].secret_type_display_name'
gh api repos/{owner}/{repo}/code-scanning/alerts --jq '.[].rule.description'
6. Manual Pattern Scanning (via Grep)
When automated tools aren't available, use Grep for critical patterns:
grep -rn "api[_-]?key\s*[:=]" --include="*.{js,ts,py,env}" .
grep -rn "password\s*[:=]\s*['\"]" --include="*.{js,ts,py}" .
grep -rn "secret\s*[:=]\s*['\"]" --include="*.{js,ts,py}" .
grep -rn "token\s*[:=]\s*['\"]" --include="*.{js,ts,py}" .
grep -rn "AKIA[0-9A-Z]{16}" .
grep -rn "sk-[a-zA-Z0-9]{48}" .
grep -rn "ghp_[a-zA-Z0-9]{36}" .
grep -rn "execute.*f['\"]" --include="*.py" .
grep -rn "query.*\$\{" --include="*.{js,ts}" .
grep -rn "raw\(.*\+" --include="*.{js,ts,py}" .
grep -rn "dangerouslySetInnerHTML" --include="*.{jsx,tsx}" .
grep -rn "innerHTML\s*=" --include="*.{js,ts}" .
grep -rn "document\.write" --include="*.{js,ts}" .
grep -rn "\|safe" --include="*.html" .
grep -rn "cors.*origin.*\*" --include="*.{js,ts}" .
grep -rn "verify.*false" --include="*.{js,ts,py}" .
grep -rn "rejectUnauthorized.*false" --include="*.{js,ts}" .
grep -rn "disable.*csrf" --include="*.{js,ts,py}" .
grep -rn "NODE_TLS_REJECT_UNAUTHORIZED" --include="*.{js,ts}" .
Security Review Frameworks
OWASP Top 10 (2021) — Deep Checklist
A01: Broken Access Control
A02: Cryptographic Failures
A03: Injection
A04: Insecure Design
A05: Security Misconfiguration
A06: Vulnerable & Outdated Components
A07: Identification & Authentication Failures
A08: Software & Data Integrity Failures
A09: Security Logging & Monitoring Failures
A10: Server-Side Request Forgery (SSRF)
CWE Top 25 Additional Checks
STRIDE Threat Model
| Threat | Question | Mitigations |
|---|
| Spoofing | Can an attacker impersonate a user or service? | Strong auth, MFA, certificate pinning |
| Tampering | Can data be modified in transit or at rest? | HMAC, digital signatures, TLS, integrity checks |
| Repudiation | Can actions be denied without proof? | Audit logging, timestamps, non-repudiation |
| Information Disclosure | Can sensitive data leak? | Encryption, access control, data classification |
| Denial of Service | Can the service be disrupted? | Rate limiting, CDN, input validation, resource limits |
| Elevation of Privilege | Can permissions be escalated? | Least privilege, role checks, input validation |
Security Headers (Required)
Content-Security-Policy: default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self'; connect-src 'self' https:; frame-ancestors 'none'
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
X-XSS-Protection: 0
Referrer-Policy: strict-origin-when-cross-origin
Permissions-Policy: camera=(), microphone=(), geolocation=(), payment=()
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Resource-Policy: same-origin
SLSA Compliance
| Level | Requirements |
|---|
| L1 | Build process documented, build scripts versioned, provenance generated |
| L2 | Hosted build service, signed provenance, source version controlled |
| L3 | Isolated build environment, non-falsifiable provenance, verified source |
| L4 | Hermetic builds, two-person review, reproducible builds |
Security Review Workflow
Phase 1: Automated Scans (run these first)
gitleaks detect -s . -v
semgrep scan --config auto .
npm audit
pip-audit
Phase 2: Manual Code Review
- Read auth/login/session code line by line
- Check all user input handling
- Review database query construction
- Verify file upload restrictions
- Check API endpoint authorization
- Review error handling for info leaks
- Verify environment variable usage (no hardcoded secrets)
Phase 3: Configuration Review
- Check
.env.example exists with placeholder values
- Verify
.env is in .gitignore
- Review CORS configuration
- Check CSP headers
- Verify production environment disables debug mode
- Check Dockerfile for security best practices
Phase 4: Live Testing (if deployed)
- Test security headers with Playwright
- Verify HTTPS redirect
- Test rate limiting
- Check error pages don't leak info
- Test auth flows for bypasses
Vulnerability Report Template
# Security Review Report
**Project:** [name]
**Date:** [date]
**Reviewer:** Security Agent
## Executive Summary
[1-2 sentence overall assessment]
## Scan Results
### Semgrep SAST: [X findings]
### Gitleaks Secrets: [X findings]
### Dependency Audit: [X vulnerabilities]
## Findings
### [CRITICAL/HIGH/MEDIUM/LOW] — [Title]
- **CWE:** CWE-XXX
- **OWASP:** A0X
- **Location:** `file:line`
- **Description:** [what's wrong]
- **Impact:** [what an attacker could do]
- **Fix:** [exact code change needed]
## Recommendations
1. [Priority action items]
Secure Coding Quick Reference
Never Do This
db.query(`SELECT * FROM users WHERE id = ${req.params.id}`)
exec(`convert ${userFile} output.pdf`)
element.innerHTML = userInput
const API_KEY = "sk-abc123..."
if (token == expectedToken)
console.log("Auth token:", token)
Always Do This
db.query('SELECT * FROM users WHERE id = $1', [req.params.id])
execFile('convert', [sanitizedFile, 'output.pdf'])
element.textContent = userInput
const API_KEY = process.env.API_KEY
crypto.timingSafeEqual(Buffer.from(token), Buffer.from(expectedToken))
logger.info('Auth attempt', { userId, success: true })