Security Review
CRITICAL: Every security assessment must classify the activity BEFORE providing assistance. If the classification is ambiguous, ask for authorization context.
Activity Classification
Permitted — Assist Freely
- Authorized security testing: Pentesting with explicit scope, red team exercises, bug bounty programs
- Defensive security: Hardening, vulnerability patching, security monitoring, incident response
- CTF challenges: Capture-the-flag competitions and training exercises
- Educational: Explaining attack vectors, demonstrating vulnerabilities in controlled environments, security training materials
- Code review: Identifying vulnerabilities in the user's own code
Forbidden — Refuse
- Destructive techniques: Malware creation, ransomware, wipers
- Denial of service: DoS/DDoS attacks, resource exhaustion against production systems
- Mass targeting: Credential stuffing at scale, spam infrastructure, mass exploitation
- Supply chain compromise: Backdooring dependencies, typosquatting packages, poisoning build pipelines
- Detection evasion for malicious purposes: Obfuscation specifically to evade security controls for unauthorized access
Context Required — Ask Before Assisting
Dual-use security tools and techniques require clear authorization context:
- C2 frameworks (Cobalt Strike, Metasploit)
- Credential testing tools
- Exploit development and proof-of-concept code
- Network scanning and reconnaissance tools
- Reverse engineering and binary analysis
Acceptable contexts: pentesting engagements, CTF competitions, security research, defensive use cases. If the user hasn't established context, ask: "What's the authorization context for this? (e.g., pentest engagement, CTF, security research)"
Code Security Checklist
When reviewing code for security, check these categories systematically:
Input Validation & Injection
- SQL injection: Parameterized queries, not string concatenation
- Command injection: No user input in shell commands without sanitization; prefer APIs over
exec/spawn with user data
- XSS: Output encoding for HTML contexts; Content Security Policy headers
- Path traversal: Validate and canonicalize file paths; reject
../ sequences
- Template injection: No user input in template strings evaluated server-side
- Deserialization: No untrusted data in
eval(), pickle.loads(), JSON.parse() of unvalidated input used to construct objects
Authentication & Authorization
- Session tokens: sufficient entropy, secure flags (HttpOnly, Secure, SameSite)
- Password storage: bcrypt/scrypt/argon2, never plaintext or reversible encryption
- Authorization checks: on every request, not just UI-level gating
- Token expiration and rotation
- Rate limiting on auth endpoints
Payment Processing
- Never generate custom credit card handling logic — no raw card numbers, CVVs, or custom tokenization. Flag any code that touches PAN data directly.
- Mandate established payment processors (Stripe, Braintree, Square, RevenueCat) with their official SDKs. Custom payment flows violate PCI-DSS unless the project has explicit SAQ-D certification.
- Verify that client-side payment forms use processor-hosted elements (Stripe Elements, Braintree Drop-in) rather than plain
<input> fields that touch card data.
Webhook Validation
- Any incoming webhook endpoint must verify the sender's cryptographic signature before processing the payload (e.g., Stripe's
webhook-signature, Slack's X-Slack-Signature, GitHub's X-Hub-Signature-256).
- Flag webhook handlers that parse and act on payloads without signature verification — an unsigned webhook endpoint is an unauthenticated API.
- Verify that webhook secrets are loaded from environment variables, not hardcoded.
Data Protection
- Secrets not hardcoded in source (API keys, passwords, tokens)
- Sensitive data not logged (passwords, tokens, PII)
- HTTPS enforced for all external communication
- Encryption at rest for sensitive fields
- No secrets in client-side code or public assets
System Boundaries
- Validate at system boundaries: user input, external APIs, file uploads, webhook payloads
- Don't validate for scenarios that can't happen — trust internal code and framework guarantees
- Treat all data crossing a trust boundary as untrusted until validated
- Validate schema/shape, not just presence
Dependencies
- Known vulnerabilities in dependencies (
npm audit, pip audit, cargo audit)
- Dependency pinning to avoid supply chain drift
- Minimal dependency surface — fewer deps = smaller attack surface
Boundary Analysis Framework
For any change touching a trust boundary:
- Identify the boundary: Where does trusted code meet untrusted input?
- Enumerate inputs: What data crosses this boundary? (form fields, headers, query params, file contents, API responses)
- Check validation: Is each input validated for type, length, format, and allowed values?
- Check encoding: Is output properly encoded for its context? (HTML, SQL, shell, URL)
- Check authorization: Does the operation verify the caller has permission?
- Check error handling: Do errors leak internal details? (stack traces, file paths, SQL queries)
Output Format
For each finding:
### Finding: [title]
**Severity**: CRITICAL / HIGH / MEDIUM / LOW / INFO
**Location**: file:line
**Issue**: What the vulnerability is
**Impact**: What an attacker could do
**Fix**: Specific remediation
End with a summary verdict:
- SECURE: No findings above INFO
- ISSUES FOUND: List severity counts (e.g., 1 HIGH, 2 MEDIUM)
CRITICAL REMINDER: Classify the activity first. Refuse forbidden activities. Require authorization context for dual-use tools. Check system boundaries, not internal code paths.
Related Skills
- Use
code-verification patterns to prove security fixes actually work (e.g., curl with malicious input after patching).
- Use
codebase-exploration patterns to trace data flow across trust boundaries.
- Security findings often feed into
architectural-planning for systemic fixes.
Project Customization
If user-config.md exists alongside this file, read it and let its contents override or extend the defaults above. Common customizations:
- Project-specific security requirements (compliance frameworks, security policies)
- Known trust boundaries and their expected validation
- Security scanning tools configured for the project
- Domain-specific threat model (e.g., financial, healthcare, infrastructure)
1---2name: security-review3description: Security analysis for code changes and requests. Classifies activities as permitted, forbidden, or requiring authorization context. Covers OWASP risks, boundary validation, and dual-use tool guidance. Use when reviewing code for security, handling security-related requests, performing threat modeling, or when asked to assess security posture.4---56# Security Review78CRITICAL: Every security assessment must classify the activity BEFORE providing assistance. If the classification is ambiguous, ask for authorization context.910## Activity Classification1112### Permitted — Assist Freely13- **Authorized security testing**: Pentesting with explicit scope, red team exercises, bug bounty programs14- **Defensive security**: Hardening, vulnerability patching, security monitoring, incident response15- **CTF challenges**: Capture-the-flag competitions and training exercises16- **Educational**: Explaining attack vectors, demonstrating vulnerabilities in controlled environments, security training materials17- **Code review**: Identifying vulnerabilities in the user's own code1819### Forbidden — Refuse20- **Destructive techniques**: Malware creation, ransomware, wipers21- **Denial of service**: DoS/DDoS attacks, resource exhaustion against production systems22- **Mass targeting**: Credential stuffing at scale, spam infrastructure, mass exploitation23- **Supply chain compromise**: Backdooring dependencies, typosquatting packages, poisoning build pipelines24- **Detection evasion for malicious purposes**: Obfuscation specifically to evade security controls for unauthorized access2526### Context Required — Ask Before Assisting27Dual-use security tools and techniques require clear authorization context:28- C2 frameworks (Cobalt Strike, Metasploit)29- Credential testing tools30- Exploit development and proof-of-concept code31- Network scanning and reconnaissance tools32- Reverse engineering and binary analysis3334Acceptable contexts: pentesting engagements, CTF competitions, security research, defensive use cases. If the user hasn't established context, ask: "What's the authorization context for this? (e.g., pentest engagement, CTF, security research)"3536## Code Security Checklist3738When reviewing code for security, check these categories systematically:3940### Input Validation & Injection41- **SQL injection**: Parameterized queries, not string concatenation42- **Command injection**: No user input in shell commands without sanitization; prefer APIs over `exec`/`spawn` with user data43- **XSS**: Output encoding for HTML contexts; Content Security Policy headers44- **Path traversal**: Validate and canonicalize file paths; reject `../` sequences45- **Template injection**: No user input in template strings evaluated server-side46- **Deserialization**: No untrusted data in `eval()`, `pickle.loads()`, `JSON.parse()` of unvalidated input used to construct objects4748### Authentication & Authorization49- Session tokens: sufficient entropy, secure flags (HttpOnly, Secure, SameSite)50- Password storage: bcrypt/scrypt/argon2, never plaintext or reversible encryption51- Authorization checks: on every request, not just UI-level gating52- Token expiration and rotation53- Rate limiting on auth endpoints5455### Payment Processing56- Never generate custom credit card handling logic — no raw card numbers, CVVs, or custom tokenization. Flag any code that touches PAN data directly.57- Mandate established payment processors (Stripe, Braintree, Square, RevenueCat) with their official SDKs. Custom payment flows violate PCI-DSS unless the project has explicit SAQ-D certification.58- Verify that client-side payment forms use processor-hosted elements (Stripe Elements, Braintree Drop-in) rather than plain `<input>` fields that touch card data.5960### Webhook Validation61- Any incoming webhook endpoint must verify the sender's cryptographic signature before processing the payload (e.g., Stripe's `webhook-signature`, Slack's `X-Slack-Signature`, GitHub's `X-Hub-Signature-256`).62- Flag webhook handlers that parse and act on payloads without signature verification — an unsigned webhook endpoint is an unauthenticated API.63- Verify that webhook secrets are loaded from environment variables, not hardcoded.6465### Data Protection66- Secrets not hardcoded in source (API keys, passwords, tokens)67- Sensitive data not logged (passwords, tokens, PII)68- HTTPS enforced for all external communication69- Encryption at rest for sensitive fields70- No secrets in client-side code or public assets7172### System Boundaries73- Validate at system boundaries: user input, external APIs, file uploads, webhook payloads74- Don't validate for scenarios that can't happen — trust internal code and framework guarantees75- Treat all data crossing a trust boundary as untrusted until validated76- Validate schema/shape, not just presence7778### Dependencies79- Known vulnerabilities in dependencies (`npm audit`, `pip audit`, `cargo audit`)80- Dependency pinning to avoid supply chain drift81- Minimal dependency surface — fewer deps = smaller attack surface8283## Boundary Analysis Framework8485For any change touching a trust boundary:86871. **Identify the boundary**: Where does trusted code meet untrusted input?882. **Enumerate inputs**: What data crosses this boundary? (form fields, headers, query params, file contents, API responses)893. **Check validation**: Is each input validated for type, length, format, and allowed values?904. **Check encoding**: Is output properly encoded for its context? (HTML, SQL, shell, URL)915. **Check authorization**: Does the operation verify the caller has permission?926. **Check error handling**: Do errors leak internal details? (stack traces, file paths, SQL queries)9394## Output Format9596For each finding:97```98### Finding: [title]99**Severity**: CRITICAL / HIGH / MEDIUM / LOW / INFO100**Location**: file:line101**Issue**: What the vulnerability is102**Impact**: What an attacker could do103**Fix**: Specific remediation104```105106End with a summary verdict:107- **SECURE**: No findings above INFO108- **ISSUES FOUND**: List severity counts (e.g., 1 HIGH, 2 MEDIUM)109110CRITICAL REMINDER: Classify the activity first. Refuse forbidden activities. Require authorization context for dual-use tools. Check system boundaries, not internal code paths.111112## Related Skills113114- Use `code-verification` patterns to prove security fixes actually work (e.g., curl with malicious input after patching).115- Use `codebase-exploration` patterns to trace data flow across trust boundaries.116- Security findings often feed into `architectural-planning` for systemic fixes.117118## Project Customization119120If `user-config.md` exists alongside this file, read it and let its contents override or extend the defaults above. Common customizations:121- Project-specific security requirements (compliance frameworks, security policies)122- Known trust boundaries and their expected validation123- Security scanning tools configured for the project124- Domain-specific threat model (e.g., financial, healthcare, infrastructure)