---
name: security-review
description: Audits a code change for injection, broken authorization, leaked secrets, SSRF, path traversal, unsafe deserialization, weak crypto and missing rate limits by tracing untrusted input to sinks. Use when the user asks for a security review or audit of a change.
---

# Security Review

Audit the change for vulnerabilities an attacker could actually exploit. Report exploitability, not theory: every finding needs an attacker, an input and an outcome.

## 1. Scope the change

```bash
git diff origin/main...HEAD --stat
git diff origin/main...HEAD
```

List the entry points the change touches or adds: HTTP routes, CLI args, webhooks, queue consumers, file uploads, environment and config, third-party callbacks. Everything coming from outside the process is untrusted: query, body, headers, cookies, filenames, uploaded content, data from other services, even database values that users can write.

## 2. Trace input to sinks

For each untrusted input, follow it through the code until it reaches a sink, and check what sits in between (validation, escaping, allowlist, parameterization). Use search to find the sinks:

```bash
grep -rnE "exec|spawn|system\(|eval\(|Function\(|subprocess|os\.popen" .
grep -rnE "SELECT|INSERT|UPDATE|DELETE|\.raw\(|\.query\(|execute\(" .
grep -rnE "fetch\(|requests\.|http\.Get|axios|urlopen" .
grep -rnE "readFile|open\(|sendFile|path\.join|createReadStream" .
grep -rnE "pickle|yaml\.load|unserialize|ObjectInputStream|JSON\.parse" .
```

## 3. Checklist of classes

- Injection: SQL built by string concatenation or template literals; shell commands with interpolated input; template engines rendering user strings as templates; NoSQL operators passed straight from JSON; LDAP/XPath; log injection via newlines.
- Authorization: every route and every object access must check who the caller is and whether they may touch this object. Look for IDOR (an id from the request used without an ownership check), missing checks on admin routes, checks done only in the UI, role taken from a client-supplied field, mass assignment of fields like `role` or `isAdmin`.
- Authentication and sessions: tokens in URLs, missing expiry, comparison of secrets with `==`, no protection against brute force, cookies without `HttpOnly`/`Secure`/`SameSite`, missing CSRF protection on cookie-authenticated writes.
- Secrets: keys, tokens or passwords in code, fixtures, config committed to git, or printed to logs and error messages. Check `git diff` and the history of touched config files.
- SSRF: the server fetches a URL influenced by the user. Check for an allowlist, blocked private/loopback/link-local ranges (including cloud metadata addresses), redirects followed, and DNS rebinding.
- Path traversal: user-controlled filenames joined to a base path. Check normalization and that the resolved path stays inside the base directory; check archive extraction for `../` entries.
- Unsafe deserialization: pickle, unsafe YAML loaders, native object deserialization on untrusted data.
- Cryptography: homegrown schemes, MD5/SHA-1 for passwords, passwords hashed without a slow salted hash (bcrypt, scrypt, argon2), static IVs, `Math.random` or non-cryptographic RNG for tokens, disabled TLS verification.
- Resource abuse: no rate limit on login, password reset, expensive endpoints or sms/email sending; unbounded upload size; regexes with catastrophic backtracking on user input.
- Output: user content rendered as HTML without escaping (XSS), `dangerouslySetInnerHTML`, open redirects, overly permissive CORS with credentials.
- Dependencies: new packages that are unmaintained or typosquatted; lockfile changes that were not intended.

## 4. Judge exploitability

For each candidate, answer:

1. Who can reach it (anonymous, logged-in user, admin, internal service)?
2. What exact input triggers it?
3. What does the attacker gain (data read, data changed, code execution, denial of service)?
4. Is there a mitigation elsewhere (WAF, framework escaping, network policy)? Verify it in the code, do not assume.

Do not report a finding you cannot connect from an input to a harmful outcome; put it under "hardening suggestions" instead.

## 5. Output format

```
Summary: <scope reviewed, overall risk>

[critical|high|medium|low] path/to/file.py:88 - <class, e.g. SQL injection>
  Attacker: <who>
  Input: <example payload or request>
  Impact: <what they get>
  Fix: <parameterize / check ownership / allowlist ... with a code sketch>

Hardening suggestions: <non-exploitable improvements>
Not checked: <what you could not verify>
```

## Pitfalls

- Never paste real secrets you find into the report; reference the file and line and say "secret present" (show at most the first four characters).
- Do not exploit anything against live systems; reasoning from code is the job.
- Do not stop at the diff: a safe-looking change can open an old unsafe path.
- Do not call everything critical; severity follows reachability and impact.
- Do not "fix" by blocklists of bad strings; recommend parameterization, allowlists and framework escaping.
- If a leaked secret is confirmed, tell the user it must be rotated; removing it from the latest commit is not enough.

Source: [AnyModel skills catalog](https://anymodel.org/en/skills) · License: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
