Skip to content

Commit 53b80ba

Browse files
authored
Add warden config and security review skills (#150)
1 parent 297d403 commit 53b80ba

File tree

84 files changed

+14466
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+14466
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The reference material in this skill is derived from the OWASP Cheat Sheet Series.
2+
3+
Source: https://cheatsheetseries.owasp.org/
4+
OWASP Foundation: https://owasp.org/
5+
6+
Original content is licensed under:
7+
8+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
9+
https://creativecommons.org/licenses/by-sa/4.0/
10+
11+
You are free to:
12+
- Share — copy and redistribute the material in any medium or format
13+
- Adapt — remix, transform, and build upon the material for any purpose,
14+
even commercially
15+
16+
Under the following terms:
17+
- Attribution — You must give appropriate credit, provide a link to the
18+
license, and indicate if changes were made.
19+
- ShareAlike — If you remix, transform, or build upon the material, you
20+
must distribute your contributions under the same license as the original.
21+
22+
Full license text: https://creativecommons.org/licenses/by-sa/4.0/legalcode
Lines changed: 313 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,313 @@
1+
---
2+
name: security-review
3+
description: 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.
4+
model: sonnet
5+
allowed-tools: Read Grep Glob Bash Task
6+
license: LICENSE
7+
---
8+
9+
<!--
10+
Reference material based on OWASP Cheat Sheet Series (CC BY-SA 4.0)
11+
https://cheatsheetseries.owasp.org/
12+
-->
13+
14+
# Security Review Skill
15+
16+
Identify exploitable security vulnerabilities in code. Report only **HIGH CONFIDENCE** findings—clear vulnerable patterns with attacker-controlled input.
17+
18+
## Scope: Research vs. Reporting
19+
20+
**CRITICAL DISTINCTION:**
21+
22+
- **Report on**: Only the specific file, diff, or code provided by the user
23+
- **Research**: The ENTIRE codebase to build confidence before reporting
24+
25+
Before flagging any issue, you MUST research the codebase to understand:
26+
- Where does this input actually come from? (Trace data flow)
27+
- Is there validation/sanitization elsewhere?
28+
- How is this configured? (Check settings, config files, middleware)
29+
- What framework protections exist?
30+
31+
**Do NOT report issues based solely on pattern matching.** Investigate first, then report only what you're confident is exploitable.
32+
33+
## Confidence Levels
34+
35+
| Level | Criteria | Action |
36+
|-------|----------|--------|
37+
| **HIGH** | Vulnerable pattern + attacker-controlled input confirmed | **Report** with severity |
38+
| **MEDIUM** | Vulnerable pattern, input source unclear | **Note** as "Needs verification" |
39+
| **LOW** | Theoretical, best practice, defense-in-depth | **Do not report** |
40+
41+
## Do Not Flag
42+
43+
### General Rules
44+
- Test files (unless explicitly reviewing test security)
45+
- Dead code, commented code, documentation strings
46+
- Patterns using **constants** or **server-controlled configuration**
47+
- Code paths that require prior authentication to reach (note the auth requirement instead)
48+
49+
### Server-Controlled Values (NOT Attacker-Controlled)
50+
51+
These are configured by operators, not controlled by attackers:
52+
53+
| Source | Example | Why It's Safe |
54+
|--------|---------|---------------|
55+
| Django settings | `settings.API_URL`, `settings.ALLOWED_HOSTS` | Set via config/env at deployment |
56+
| Environment variables | `os.environ.get('DATABASE_URL')` | Deployment configuration |
57+
| Config files | `config.yaml`, `app.config['KEY']` | Server-side files |
58+
| Framework constants | `django.conf.settings.*` | Not user-modifiable |
59+
| Hardcoded values | `BASE_URL = "https://api.internal"` | Compile-time constants |
60+
61+
**SSRF Example - NOT a vulnerability:**
62+
```python
63+
# SAFE: URL comes from Django settings (server-controlled)
64+
response = requests.get(f"{settings.SEER_AUTOFIX_URL}{path}")
65+
```
66+
67+
**SSRF Example - IS a vulnerability:**
68+
```python
69+
# VULNERABLE: URL comes from request (attacker-controlled)
70+
response = requests.get(request.GET.get('url'))
71+
```
72+
73+
### Framework-Mitigated Patterns
74+
Check language guides before flagging. Common false positives:
75+
76+
| Pattern | Why It's Usually Safe |
77+
|---------|----------------------|
78+
| Django `{{ variable }}` | Auto-escaped by default |
79+
| React `{variable}` | Auto-escaped by default |
80+
| Vue `{{ variable }}` | Auto-escaped by default |
81+
| `User.objects.filter(id=input)` | ORM parameterizes queries |
82+
| `cursor.execute("...%s", (input,))` | Parameterized query |
83+
| `innerHTML = "<b>Loading...</b>"` | Constant string, no user input |
84+
85+
**Only flag these when:**
86+
- Django: `{{ var|safe }}`, `{% autoescape off %}`, `mark_safe(user_input)`
87+
- React: `dangerouslySetInnerHTML={{__html: userInput}}`
88+
- Vue: `v-html="userInput"`
89+
- ORM: `.raw()`, `.extra()`, `RawSQL()` with string interpolation
90+
91+
## Review Process
92+
93+
### 1. Detect Context
94+
95+
What type of code am I reviewing?
96+
97+
| Code Type | Load These References |
98+
|-----------|----------------------|
99+
| API endpoints, routes | `authorization.md`, `authentication.md`, `injection.md` |
100+
| Frontend, templates | `xss.md`, `csrf.md` |
101+
| File handling, uploads | `file-security.md` |
102+
| Crypto, secrets, tokens | `cryptography.md`, `data-protection.md` |
103+
| Data serialization | `deserialization.md` |
104+
| External requests | `ssrf.md` |
105+
| Business workflows | `business-logic.md` |
106+
| GraphQL, REST design | `api-security.md` |
107+
| Config, headers, CORS | `misconfiguration.md` |
108+
| CI/CD, dependencies | `supply-chain.md` |
109+
| Error handling | `error-handling.md` |
110+
| Audit, logging | `logging.md` |
111+
112+
### 2. Load Language Guide
113+
114+
Based on file extension or imports:
115+
116+
| Indicators | Guide |
117+
|------------|-------|
118+
| `.py`, `django`, `flask`, `fastapi` | `languages/python.md` |
119+
| `.js`, `.ts`, `express`, `react`, `vue`, `next` | `languages/javascript.md` |
120+
| `.go`, `go.mod` | `languages/go.md` |
121+
| `.rs`, `Cargo.toml` | `languages/rust.md` |
122+
| `.java`, `spring`, `@Controller` | `languages/java.md` |
123+
124+
### 3. Load Infrastructure Guide (if applicable)
125+
126+
| File Type | Guide |
127+
|-----------|-------|
128+
| `Dockerfile`, `.dockerignore` | `infrastructure/docker.md` |
129+
| K8s manifests, Helm charts | `infrastructure/kubernetes.md` |
130+
| `.tf`, Terraform | `infrastructure/terraform.md` |
131+
| GitHub Actions, `.gitlab-ci.yml` | `infrastructure/ci-cd.md` |
132+
| AWS/GCP/Azure configs, IAM | `infrastructure/cloud.md` |
133+
134+
### 4. Research Before Flagging
135+
136+
**For each potential issue, research the codebase to build confidence:**
137+
138+
- Where does this value actually come from? Trace the data flow.
139+
- Is it configured at deployment (settings, env vars) or from user input?
140+
- Is there validation, sanitization, or allowlisting elsewhere?
141+
- What framework protections apply?
142+
143+
Only report issues where you have HIGH confidence after understanding the broader context.
144+
145+
### 5. Verify Exploitability
146+
147+
For each potential finding, confirm:
148+
149+
**Is the input attacker-controlled?**
150+
151+
| Attacker-Controlled (Investigate) | Server-Controlled (Usually Safe) |
152+
|-----------------------------------|----------------------------------|
153+
| `request.GET`, `request.POST`, `request.args` | `settings.X`, `app.config['X']` |
154+
| `request.json`, `request.data`, `request.body` | `os.environ.get('X')` |
155+
| `request.headers` (most headers) | Hardcoded constants |
156+
| `request.cookies` (unsigned) | Internal service URLs from config |
157+
| URL path segments: `/users/<id>/` | Database content from admin/system |
158+
| File uploads (content and names) | Signed session data |
159+
| Database content from other users | Framework settings |
160+
| WebSocket messages | |
161+
162+
**Does the framework mitigate this?**
163+
- Check language guide for auto-escaping, parameterization
164+
- Check for middleware/decorators that sanitize
165+
166+
**Is there validation upstream?**
167+
- Input validation before this code
168+
- Sanitization libraries (DOMPurify, bleach, etc.)
169+
170+
### 6. Report HIGH Confidence Only
171+
172+
Skip theoretical issues. Report only what you've confirmed is exploitable after research.
173+
174+
---
175+
176+
## Severity Classification
177+
178+
| Severity | Impact | Examples |
179+
|----------|--------|----------|
180+
| **Critical** | Direct exploit, severe impact, no auth required | RCE, SQL injection to data, auth bypass, hardcoded secrets |
181+
| **High** | Exploitable with conditions, significant impact | Stored XSS, SSRF to metadata, IDOR to sensitive data |
182+
| **Medium** | Specific conditions required, moderate impact | Reflected XSS, CSRF on state-changing actions, path traversal |
183+
| **Low** | Defense-in-depth, minimal direct impact | Missing headers, verbose errors, weak algorithms in non-critical context |
184+
185+
---
186+
187+
## Quick Patterns Reference
188+
189+
### Always Flag (Critical)
190+
```
191+
eval(user_input) # Any language
192+
exec(user_input) # Any language
193+
pickle.loads(user_data) # Python
194+
yaml.load(user_data) # Python (not safe_load)
195+
unserialize($user_data) # PHP
196+
deserialize(user_data) # Java ObjectInputStream
197+
shell=True + user_input # Python subprocess
198+
child_process.exec(user) # Node.js
199+
```
200+
201+
### Always Flag (High)
202+
```
203+
innerHTML = userInput # DOM XSS
204+
dangerouslySetInnerHTML={user} # React XSS
205+
v-html="userInput" # Vue XSS
206+
f"SELECT * FROM x WHERE {user}" # SQL injection
207+
`SELECT * FROM x WHERE ${user}` # SQL injection
208+
os.system(f"cmd {user_input}") # Command injection
209+
```
210+
211+
### Always Flag (Secrets)
212+
```
213+
password = "hardcoded"
214+
api_key = "sk-..."
215+
AWS_SECRET_ACCESS_KEY = "..."
216+
private_key = "-----BEGIN"
217+
```
218+
219+
### Check Context First (MUST Investigate Before Flagging)
220+
```
221+
# SSRF - ONLY if URL is from user input, NOT from settings/config
222+
requests.get(request.GET['url']) # FLAG: User-controlled URL
223+
requests.get(settings.API_URL) # SAFE: Server-controlled config
224+
requests.get(f"{settings.BASE}/{x}") # CHECK: Is 'x' user input?
225+
226+
# Path traversal - ONLY if path is from user input
227+
open(request.GET['file']) # FLAG: User-controlled path
228+
open(settings.LOG_PATH) # SAFE: Server-controlled config
229+
open(f"{BASE_DIR}/{filename}") # CHECK: Is 'filename' user input?
230+
231+
# Open redirect - ONLY if URL is from user input
232+
redirect(request.GET['next']) # FLAG: User-controlled redirect
233+
redirect(settings.LOGIN_URL) # SAFE: Server-controlled config
234+
235+
# Weak crypto - ONLY if used for security purposes
236+
hashlib.md5(file_content) # SAFE: File checksums, caching
237+
hashlib.md5(password) # FLAG: Password hashing
238+
random.random() # SAFE: Non-security uses (UI, sampling)
239+
random.random() for token # FLAG: Security tokens need secrets module
240+
```
241+
242+
---
243+
244+
## Output Format
245+
246+
```markdown
247+
## Security Review: [File/Component Name]
248+
249+
### Summary
250+
- **Findings**: X (Y Critical, Z High, ...)
251+
- **Risk Level**: Critical/High/Medium/Low
252+
- **Confidence**: High/Mixed
253+
254+
### Findings
255+
256+
#### [VULN-001] [Vulnerability Type] (Severity)
257+
- **Location**: `file.py:123`
258+
- **Confidence**: High
259+
- **Issue**: [What the vulnerability is]
260+
- **Impact**: [What an attacker could do]
261+
- **Evidence**:
262+
```python
263+
[Vulnerable code snippet]
264+
```
265+
- **Fix**: [How to remediate]
266+
267+
### Needs Verification
268+
269+
#### [VERIFY-001] [Potential Issue]
270+
- **Location**: `file.py:456`
271+
- **Question**: [What needs to be verified]
272+
```
273+
274+
If no vulnerabilities found, state: "No high-confidence vulnerabilities identified."
275+
276+
---
277+
278+
## Reference Files
279+
280+
### Core Vulnerabilities (`references/`)
281+
| File | Covers |
282+
|------|--------|
283+
| `injection.md` | SQL, NoSQL, OS command, LDAP, template injection |
284+
| `xss.md` | Reflected, stored, DOM-based XSS |
285+
| `authorization.md` | Authorization, IDOR, privilege escalation |
286+
| `authentication.md` | Sessions, credentials, password storage |
287+
| `cryptography.md` | Algorithms, key management, randomness |
288+
| `deserialization.md` | Pickle, YAML, Java, PHP deserialization |
289+
| `file-security.md` | Path traversal, uploads, XXE |
290+
| `ssrf.md` | Server-side request forgery |
291+
| `csrf.md` | Cross-site request forgery |
292+
| `data-protection.md` | Secrets exposure, PII, logging |
293+
| `api-security.md` | REST, GraphQL, mass assignment |
294+
| `business-logic.md` | Race conditions, workflow bypass |
295+
| `modern-threats.md` | Prototype pollution, LLM injection, WebSocket |
296+
| `misconfiguration.md` | Headers, CORS, debug mode, defaults |
297+
| `error-handling.md` | Fail-open, information disclosure |
298+
| `supply-chain.md` | Dependencies, build security |
299+
| `logging.md` | Audit failures, log injection |
300+
301+
### Language Guides (`languages/`)
302+
- `python.md` - Django, Flask, FastAPI patterns
303+
- `javascript.md` - Node, Express, React, Vue, Next.js
304+
- `go.md` - Go-specific security patterns
305+
- `rust.md` - Rust unsafe blocks, FFI security
306+
- `java.md` - Spring, Java EE patterns
307+
308+
### Infrastructure (`infrastructure/`)
309+
- `docker.md` - Container security
310+
- `kubernetes.md` - K8s RBAC, secrets, policies
311+
- `terraform.md` - IaC security
312+
- `ci-cd.md` - Pipeline security
313+
- `cloud.md` - AWS/GCP/Azure security

0 commit comments

Comments
 (0)