Security Review Skill
Identify exploitable security vulnerabilities in code. Report only HIGH CONFIDENCE findings—clear vulnerable patterns with attacker-controlled input.
Scope: Research vs. Reporting
CRITICAL DISTINCTION:
- Report on: Only the specific file, diff, or code provided by the user
- Research: The ENTIRE codebase to build confidence before reporting
Before flagging any issue, you MUST research the codebase to understand:
- Where does this input actually come from? (Trace data flow)
- Is there validation/sanitization elsewhere?
- How is this configured? (Check settings, config files, middleware)
- What framework protections exist?
Do NOT report issues based solely on pattern matching. Investigate first, then report only what you're confident is exploitable.
Confidence Levels
| Level |
Criteria |
Action |
| HIGH |
Vulnerable pattern + attacker-controlled input confirmed |
Report with severity |
| MEDIUM |
Vulnerable pattern, input source unclear |
Note as "Needs verification" |
| LOW |
Theoretical, best practice, defense-in-depth |
Do not report |
Do Not Flag
General Rules
- Test files (unless explicitly reviewing test security)
- Dead code, commented code, documentation strings
- Patterns using constants or server-controlled configuration
- Code paths that require prior authentication to reach (note the auth requirement instead)
Server-Controlled Values (NOT Attacker-Controlled)
These are configured by operators, not controlled by attackers:
| Source |
Example |
Why It's Safe |
| Django settings |
settings.API_URL, settings.ALLOWED_HOSTS |
Set via config/env at deployment |
| Environment variables |
os.environ.get('DATABASE_URL') |
Deployment configuration |
| Config files |
config.yaml, app.config['KEY'] |
Server-side files |
| Framework constants |
django.conf.settings.* |
Not user-modifiable |
| Hardcoded values |
BASE_URL = "https://api.internal" |
Compile-time constants |
SSRF Example - NOT a vulnerability:
# SAFE: URL comes from Django settings (server-controlled)
response = requests.get(f"{settings.SEER_AUTOFIX_URL}{path}")
SSRF Example - IS a vulnerability:
# VULNERABLE: URL comes from request (attacker-controlled)
response = requests.get(request.GET.get('url'))
Framework-Mitigated Patterns
Check language guides before flagging. Common false positives:
| Pattern |
Why It's Usually Safe |
Django {{ variable }} |
Auto-escaped by default |
React {variable} |
Auto-escaped by default |
Vue {{ variable }} |
Auto-escaped by default |
User.objects.filter(id=input) |
ORM parameterizes queries |
cursor.execute("...%s", (input,)) |
Parameterized query |
innerHTML = "<b>Loading...</b>" |
Constant string, no user input |
Only flag these when:
- Django:
{{ var|safe }}, {% autoescape off %}, mark_safe(user_input)
- React:
dangerouslySetInnerHTML={{__html: userInput}}
- Vue:
v-html="userInput"
- ORM:
.raw(), .extra(), RawSQL() with string interpolation
Review Process
1. Detect Context
What type of code am I reviewing?
| Code Type |
Load These References |
| API endpoints, routes |
authorization.md, authentication.md, injection.md |
| Frontend, templates |
xss.md, csrf.md |
| File handling, uploads |
file-security.md |
| Crypto, secrets, tokens |
cryptography.md, data-protection.md |
| Data serialization |
deserialization.md |
| External requests |
ssrf.md |
| Business workflows |
business-logic.md |
| GraphQL, REST design |
api-security.md |
| Config, headers, CORS |
misconfiguration.md |
| CI/CD, dependencies |
supply-chain.md |
| Error handling |
error-handling.md |
| Audit, logging |
logging.md |
2. Load Language Guide
Based on file extension or imports:
| Indicators |
Guide |
.py, django, flask, fastapi |
languages/python.md |
.js, .ts, express, react, vue, next |
languages/javascript.md |
3. Load Infrastructure Guide (if applicable)
| File Type |
Guide |
Dockerfile, .dockerignore |
infrastructure/docker.md |
4. Research Before Flagging
For each potential issue, research the codebase to build confidence:
- Where does this value actually come from? Trace the data flow.
- Is it configured at deployment (settings, env vars) or from user input?
- Is there validation, sanitization, or allowlisting elsewhere?
- What framework protections apply?
Only report issues where you have HIGH confidence after understanding the broader context.
5. Verify Exploitability
For each potential finding, confirm:
Is the input attacker-controlled?
| Attacker-Controlled (Investigate) |
Server-Controlled (Usually Safe) |
request.GET, request.POST, request.args |
settings.X, app.config['X'] |
request.json, request.data, request.body |
os.environ.get('X') |
request.headers (most headers) |
Hardcoded constants |
request.cookies (unsigned) |
Internal service URLs from config |
URL path segments: /users/<id>/ |
Database content from admin/system |
| File uploads (content and names) |
Signed session data |
| Database content from other users |
Framework settings |
| WebSocket messages |
|
Does the framework mitigate this?
- Check language guide for auto-escaping, parameterization
- Check for middleware/decorators that sanitize
Is there validation upstream?
- Input validation before this code
- Sanitization libraries (DOMPurify, bleach, etc.)
6. Report HIGH Confidence Only
Skip theoretical issues. Report only what you've confirmed is exploitable after research.
Severity Classification
| Severity |
Impact |
Examples |
| Critical |
Direct exploit, severe impact, no auth required |
RCE, SQL injection to data, auth bypass, hardcoded secrets |
| High |
Exploitable with conditions, significant impact |
Stored XSS, SSRF to metadata, IDOR to sensitive data |
| Medium |
Specific conditions required, moderate impact |
Reflected XSS, CSRF on state-changing actions, path traversal |
| Low |
Defense-in-depth, minimal direct impact |
Missing headers, verbose errors, weak algorithms in non-critical context |
Quick Patterns Reference
Always Flag (Critical)
eval(user_input) # Any language
exec(user_input) # Any language
pickle.loads(user_data) # Python
yaml.load(user_data) # Python (not safe_load)
unserialize($user_data) # PHP
deserialize(user_data) # Java ObjectInputStream
shell=True + user_input # Python subprocess
child_process.exec(user) # Node.js
Always Flag (High)
innerHTML = userInput # DOM XSS
dangerouslySetInnerHTML={user} # React XSS
v-html="userInput" # Vue XSS
f"SELECT * FROM x WHERE {user}" # SQL injection
`SELECT * FROM x WHERE ${user}` # SQL injection
os.system(f"cmd {user_input}") # Command injection
Always Flag (Secrets)
password = "hardcoded"
api_key = "sk-..."
AWS_SECRET_ACCESS_KEY = "..."
private_key = "-----BEGIN"
Check Context First (MUST Investigate Before Flagging)
# SSRF - ONLY if URL is from user input, NOT from settings/config
requests.get(request.GET['url']) # FLAG: User-controlled URL
requests.get(settings.API_URL) # SAFE: Server-controlled config
requests.get(f"{settings.BASE}/{x}") # CHECK: Is 'x' user input?
# Path traversal - ONLY if path is from user input
open(request.GET['file']) # FLAG: User-controlled path
open(settings.LOG_PATH) # SAFE: Server-controlled config
open(f"{BASE_DIR}/{filename}") # CHECK: Is 'filename' user input?
# Open redirect - ONLY if URL is from user input
redirect(request.GET['next']) # FLAG: User-controlled redirect
redirect(settings.LOGIN_URL) # SAFE: Server-controlled config
# Weak crypto - ONLY if used for security purposes
hashlib.md5(file_content) # SAFE: File checksums, caching
hashlib.md5(password) # FLAG: Password hashing
random.random() # SAFE: Non-security uses (UI, sampling)
random.random() for token # FLAG: Security tokens need secrets module
Output Format
## Security Review: [File/Component Name]
### Summary
- **Findings**: X (Y Critical, Z High, ...)
- **Risk Level**: Critical/High/Medium/Low
- **Confidence**: High/Mixed
### Findings
#### [VULN-001] [Vulnerability Type] (Severity)
- **Location**: `file.py:123`
- **Confidence**: High
- **Issue**: [What the vulnerability is]
- **Impact**: [What an attacker could do]
- **Evidence**:
```python
[Vulnerable code snippet]
Needs Verification
[VERIFY-001] [Potential Issue]
- Location:
file.py:456
- Question: [What needs to be verified]
If no vulnerabilities found, state: "No high-confidence vulnerabilities identified."
---
## Reference Files
### Core Vulnerabilities (`references/`)
| File | Covers |
|------|--------|
| `injection.md` | SQL, NoSQL, OS command, LDAP, template injection |
| `xss.md` | Reflected, stored, DOM-based XSS |
| `authorization.md` | Authorization, IDOR, privilege escalation |
| `authentication.md` | Sessions, credentials, password storage |
| `cryptography.md` | Algorithms, key management, randomness |
| `deserialization.md` | Pickle, YAML, Java, PHP deserialization |
| `file-security.md` | Path traversal, uploads, XXE |
| `ssrf.md` | Server-side request forgery |
| `csrf.md` | Cross-site request forgery |
| `data-protection.md` | Secrets exposure, PII, logging |
| `api-security.md` | REST, GraphQL, mass assignment |
| `business-logic.md` | Race conditions, workflow bypass |
| `modern-threats.md` | Prototype pollution, LLM injection, WebSocket |
| `misconfiguration.md` | Headers, CORS, debug mode, defaults |
| `error-handling.md` | Fail-open, information disclosure |
| `supply-chain.md` | Dependencies, build security |
| `logging.md` | Audit failures, log injection |
### Language Guides (`languages/`)
- `python.md` - Django, Flask, FastAPI patterns
- `javascript.md` - Node, Express, React, Vue, Next.js
### Infrastructure (`infrastructure/`)
- `docker.md` - Container security
1---2name: security-review3description: Security code review for vulnerabilities. Use when asked to "security review", "find vulnerabilities", "check for security issues", "audit security", "OWASP review", or review code for injection, XSS, authentication, authorization, cryptography issues. Provides systematic review with confidence-based reporting.4license: LICENSE5---67<!--8Reference material based on OWASP Cheat Sheet Series (CC BY-SA 4.0)9https://cheatsheetseries.owasp.org/10-->1112# Security Review Skill1314Identify exploitable security vulnerabilities in code. Report only **HIGH CONFIDENCE** findings—clear vulnerable patterns with attacker-controlled input.1516## Scope: Research vs. Reporting1718**CRITICAL DISTINCTION:**1920- **Report on**: Only the specific file, diff, or code provided by the user21- **Research**: The ENTIRE codebase to build confidence before reporting2223Before flagging any issue, you MUST research the codebase to understand:24- Where does this input actually come from? (Trace data flow)25- Is there validation/sanitization elsewhere?26- How is this configured? (Check settings, config files, middleware)27- What framework protections exist?2829**Do NOT report issues based solely on pattern matching.** Investigate first, then report only what you're confident is exploitable.3031## Confidence Levels3233| Level | Criteria | Action |34|-------|----------|--------|35| **HIGH** | Vulnerable pattern + attacker-controlled input confirmed | **Report** with severity |36| **MEDIUM** | Vulnerable pattern, input source unclear | **Note** as "Needs verification" |37| **LOW** | Theoretical, best practice, defense-in-depth | **Do not report** |3839## Do Not Flag4041### General Rules42- Test files (unless explicitly reviewing test security)43- Dead code, commented code, documentation strings44- Patterns using **constants** or **server-controlled configuration**45- Code paths that require prior authentication to reach (note the auth requirement instead)4647### Server-Controlled Values (NOT Attacker-Controlled)4849These are configured by operators, not controlled by attackers:5051| Source | Example | Why It's Safe |52|--------|---------|---------------|53| Django settings | `settings.API_URL`, `settings.ALLOWED_HOSTS` | Set via config/env at deployment |54| Environment variables | `os.environ.get('DATABASE_URL')` | Deployment configuration |55| Config files | `config.yaml`, `app.config['KEY']` | Server-side files |56| Framework constants | `django.conf.settings.*` | Not user-modifiable |57| Hardcoded values | `BASE_URL = "https://api.internal"` | Compile-time constants |5859**SSRF Example - NOT a vulnerability:**60```python61# SAFE: URL comes from Django settings (server-controlled)62response = requests.get(f"{settings.SEER_AUTOFIX_URL}{path}")63```6465**SSRF Example - IS a vulnerability:**66```python67# VULNERABLE: URL comes from request (attacker-controlled)68response = requests.get(request.GET.get('url'))69```7071### Framework-Mitigated Patterns72Check language guides before flagging. Common false positives:7374| Pattern | Why It's Usually Safe |75|---------|----------------------|76| Django `{{ variable }}` | Auto-escaped by default |77| React `{variable}` | Auto-escaped by default |78| Vue `{{ variable }}` | Auto-escaped by default |79| `User.objects.filter(id=input)` | ORM parameterizes queries |80| `cursor.execute("...%s", (input,))` | Parameterized query |81| `innerHTML = "<b>Loading...</b>"` | Constant string, no user input |8283**Only flag these when:**84- Django: `{{ var|safe }}`, `{% autoescape off %}`, `mark_safe(user_input)`85- React: `dangerouslySetInnerHTML={{__html: userInput}}`86- Vue: `v-html="userInput"`87- ORM: `.raw()`, `.extra()`, `RawSQL()` with string interpolation8889## Review Process9091### 1. Detect Context9293What type of code am I reviewing?9495| Code Type | Load These References |96|-----------|----------------------|97| API endpoints, routes | `authorization.md`, `authentication.md`, `injection.md` |98| Frontend, templates | `xss.md`, `csrf.md` |99| File handling, uploads | `file-security.md` |100| Crypto, secrets, tokens | `cryptography.md`, `data-protection.md` |101| Data serialization | `deserialization.md` |102| External requests | `ssrf.md` |103| Business workflows | `business-logic.md` |104| GraphQL, REST design | `api-security.md` |105| Config, headers, CORS | `misconfiguration.md` |106| CI/CD, dependencies | `supply-chain.md` |107| Error handling | `error-handling.md` |108| Audit, logging | `logging.md` |109110### 2. Load Language Guide111112Based on file extension or imports:113114| Indicators | Guide |115|------------|-------|116| `.py`, `django`, `flask`, `fastapi` | `languages/python.md` |117| `.js`, `.ts`, `express`, `react`, `vue`, `next` | `languages/javascript.md` |118119### 3. Load Infrastructure Guide (if applicable)120121| File Type | Guide |122|-----------|-------|123| `Dockerfile`, `.dockerignore` | `infrastructure/docker.md` |124125### 4. Research Before Flagging126127**For each potential issue, research the codebase to build confidence:**128129- Where does this value actually come from? Trace the data flow.130- Is it configured at deployment (settings, env vars) or from user input?131- Is there validation, sanitization, or allowlisting elsewhere?132- What framework protections apply?133134Only report issues where you have HIGH confidence after understanding the broader context.135136### 5. Verify Exploitability137138For each potential finding, confirm:139140**Is the input attacker-controlled?**141142| Attacker-Controlled (Investigate) | Server-Controlled (Usually Safe) |143|-----------------------------------|----------------------------------|144| `request.GET`, `request.POST`, `request.args` | `settings.X`, `app.config['X']` |145| `request.json`, `request.data`, `request.body` | `os.environ.get('X')` |146| `request.headers` (most headers) | Hardcoded constants |147| `request.cookies` (unsigned) | Internal service URLs from config |148| URL path segments: `/users/<id>/` | Database content from admin/system |149| File uploads (content and names) | Signed session data |150| Database content from other users | Framework settings |151| WebSocket messages | |152153**Does the framework mitigate this?**154- Check language guide for auto-escaping, parameterization155- Check for middleware/decorators that sanitize156157**Is there validation upstream?**158- Input validation before this code159- Sanitization libraries (DOMPurify, bleach, etc.)160161### 6. Report HIGH Confidence Only162163Skip theoretical issues. Report only what you've confirmed is exploitable after research.164165---166167## Severity Classification168169| Severity | Impact | Examples |170|----------|--------|----------|171| **Critical** | Direct exploit, severe impact, no auth required | RCE, SQL injection to data, auth bypass, hardcoded secrets |172| **High** | Exploitable with conditions, significant impact | Stored XSS, SSRF to metadata, IDOR to sensitive data |173| **Medium** | Specific conditions required, moderate impact | Reflected XSS, CSRF on state-changing actions, path traversal |174| **Low** | Defense-in-depth, minimal direct impact | Missing headers, verbose errors, weak algorithms in non-critical context |175176---177178## Quick Patterns Reference179180### Always Flag (Critical)181```182eval(user_input) # Any language183exec(user_input) # Any language184pickle.loads(user_data) # Python185yaml.load(user_data) # Python (not safe_load)186unserialize($user_data) # PHP187deserialize(user_data) # Java ObjectInputStream188shell=True + user_input # Python subprocess189child_process.exec(user) # Node.js190```191192### Always Flag (High)193```194innerHTML = userInput # DOM XSS195dangerouslySetInnerHTML={user} # React XSS196v-html="userInput" # Vue XSS197f"SELECT * FROM x WHERE {user}" # SQL injection198`SELECT * FROM x WHERE ${user}` # SQL injection199os.system(f"cmd {user_input}") # Command injection200```201202### Always Flag (Secrets)203```204password = "hardcoded"205api_key = "sk-..."206AWS_SECRET_ACCESS_KEY = "..."207private_key = "-----BEGIN"208```209210### Check Context First (MUST Investigate Before Flagging)211```212# SSRF - ONLY if URL is from user input, NOT from settings/config213requests.get(request.GET['url']) # FLAG: User-controlled URL214requests.get(settings.API_URL) # SAFE: Server-controlled config215requests.get(f"{settings.BASE}/{x}") # CHECK: Is 'x' user input?216217# Path traversal - ONLY if path is from user input218open(request.GET['file']) # FLAG: User-controlled path219open(settings.LOG_PATH) # SAFE: Server-controlled config220open(f"{BASE_DIR}/{filename}") # CHECK: Is 'filename' user input?221222# Open redirect - ONLY if URL is from user input223redirect(request.GET['next']) # FLAG: User-controlled redirect224redirect(settings.LOGIN_URL) # SAFE: Server-controlled config225226# Weak crypto - ONLY if used for security purposes227hashlib.md5(file_content) # SAFE: File checksums, caching228hashlib.md5(password) # FLAG: Password hashing229random.random() # SAFE: Non-security uses (UI, sampling)230random.random() for token # FLAG: Security tokens need secrets module231```232233---234235## Output Format236237```markdown238## Security Review: [File/Component Name]239240### Summary241- **Findings**: X (Y Critical, Z High, ...)242- **Risk Level**: Critical/High/Medium/Low243- **Confidence**: High/Mixed244245### Findings246247#### [VULN-001] [Vulnerability Type] (Severity)248- **Location**: `file.py:123`249- **Confidence**: High250- **Issue**: [What the vulnerability is]251- **Impact**: [What an attacker could do]252- **Evidence**:253 ```python254 [Vulnerable code snippet]255 ```256- **Fix**: [How to remediate]257258### Needs Verification259260#### [VERIFY-001] [Potential Issue]261- **Location**: `file.py:456`262- **Question**: [What needs to be verified]263```264265If no vulnerabilities found, state: "No high-confidence vulnerabilities identified."266267---268269## Reference Files270271### Core Vulnerabilities (`references/`)272| File | Covers |273|------|--------|274| `injection.md` | SQL, NoSQL, OS command, LDAP, template injection |275| `xss.md` | Reflected, stored, DOM-based XSS |276| `authorization.md` | Authorization, IDOR, privilege escalation |277| `authentication.md` | Sessions, credentials, password storage |278| `cryptography.md` | Algorithms, key management, randomness |279| `deserialization.md` | Pickle, YAML, Java, PHP deserialization |280| `file-security.md` | Path traversal, uploads, XXE |281| `ssrf.md` | Server-side request forgery |282| `csrf.md` | Cross-site request forgery |283| `data-protection.md` | Secrets exposure, PII, logging |284| `api-security.md` | REST, GraphQL, mass assignment |285| `business-logic.md` | Race conditions, workflow bypass |286| `modern-threats.md` | Prototype pollution, LLM injection, WebSocket |287| `misconfiguration.md` | Headers, CORS, debug mode, defaults |288| `error-handling.md` | Fail-open, information disclosure |289| `supply-chain.md` | Dependencies, build security |290| `logging.md` | Audit failures, log injection |291292### Language Guides (`languages/`)293- `python.md` - Django, Flask, FastAPI patterns294- `javascript.md` - Node, Express, React, Vue, Next.js295296### Infrastructure (`infrastructure/`)297- `docker.md` - Container security