/spwf:security-scanfrom spwf
On-demand deep security code review covering OWASP Top 10 (2021) with priority on SQL injection, command injection, broken access control, and cryptographic failures. Use when a PR touches auth, billing, user input handling, or database queries; when /approve-plan flagged ⚠ Security on a task; when auditing a new feature area; or when investigating a reported vulnerability. Accepts an optional path argument to scope the review. Complements pr-create (automated tool pre-flight) and approve-plan (design-time advisory) — this skill performs the deep manual analysis neither of those does.
Ships in spwf. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Deep security code review against OWASP Top 10 (2021) and SQL injection patterns. Read-only — proposes fixes, never applies them.
| Touchpoint | When | What it does |
|---|---|---|
/spwf:approve-plan Security lens | Pre-build | Flags which tasks touch security-sensitive surfaces |
/spwf:pr-create pre-flight | Ship time | Runs gitleaks / semgrep / dep-audit automatically |
/trailofbits:semgrep | On demand | Automated SAST with curated Trail of Bits rulesets, SARIF output |
| This skill | On demand | Deep manual code review: logic flaws, design issues, IDOR, second-order injection — things SAST misses |
Use this skill for any review where the question is "could a human attacker exploit this?" rather than "does this match a known vulnerability pattern?"
Optional path argument:
Identify entry points, database interaction, auth surfaces, file I/O, and external calls. These are the attack surface to review in Phase 2.
# HTTP entry points
grep -rn "Route::\|@app\.route\|router\.\(get\|post\|put\|patch\|delete\)\|express()\|http\.HandleFunc\|@(Get\|Post\|Put\|Delete\|Patch)" \
--include="*.php" --include="*.py" --include="*.js" --include="*.ts" --include="*.go" .
# Raw SQL — highest injection risk
grep -rn "DB::select\|DB::statement\|DB::raw\|\->query(\|\->execute(\|mysqli_query\|cursor\.execute\|db\.query\|sql\.Query\|sql\.Exec\|\$pdo->query\|pgx\." \
--include="*.php" --include="*.py" --include="*.js" --include="*.ts" --include="*.go" .
# Shell execution
grep -rn "exec(\|shell_exec\|passthru\|system(\|subprocess\.\|os\.system\|child_process\|execSync\|spawnSync\|os/exec" \
--include="*.php" --include="*.py" --include="*.js" --include="*.ts" --include="*.go" .
# File path operations
grep -rn "fopen\|file_get_contents\|readFile\|open(\|os\.Open\|fs\.\|path\.join\|__DIR__" \
--include="*.php" --include="*.py" --include="*.js" --include="*.ts" --include="*.go" .
# Outbound HTTP (SSRF surface)
grep -rn "curl_exec\|file_get_contents.*http\|requests\.\(get\|post\)\|fetch(\|axios\.\|http\.get\|net/http" \
--include="*.php" --include="*.py" --include="*.js" --include="*.ts" --include="*.go" .
Read the files at the locations found. Record which files contain which surface types — this informs where to focus Phase 2.
Work through each category. Skip categories with no relevant surface from Phase 1 — note the skip explicitly so the reader knows it was considered. Full language-specific patterns are in references/owasp-checklist.md.
The most common OWASP category. Check:
Order::find($id) with no ownership check is IDOR.Access-Control-Allow-Origin: * combined with Access-Control-Allow-Credentials: true is a critical misconfiguration.none algorithm accepted?-----BEGIN, password =, secret =, api_key =)rand(), Math.random(), time() as seed for security tokens — use random_bytes(), secrets.token_bytes(), crypto.randomBytes()verify=False in Python requests, rejectUnauthorized: false in Node, CURLOPT_SSL_VERIFYPEER set to falseSQL injection is covered in depth in Phase 3. Additional injection vectors:
Command injection — any user input reaching a shell:
// Critical — user controls command argument
exec("convert " . $_POST['filename'] . " output.jpg");
// Safe — escape or avoid shell entirely
exec("convert " . escapeshellarg($filename) . " output.jpg");
Path traversal — user-controlled path components:
# Vulnerable
path = "/uploads/" + request.args.get("file")
return send_file(path)
# Safe — resolve and verify within allowed directory
base = Path("/uploads").resolve()
target = (base / request.args.get("file")).resolve()
if not str(target).startswith(str(base)):
abort(403)
Template injection — user input rendered in server-side templates:
# Vulnerable — Jinja2 SSTI
render_template_string(user_input)
# Safe — pass data as context, not as template
render_template("page.html", content=user_input)
LDAP injection — look for user input in LDAP filter strings without escaping.
Logic-level issues SAST cannot catch:
APP_DEBUG=true or equivalent in production configThe pr-create pre-flight (npm audit / pip-audit) covers automated dependency scanning. Flag here only if there is a design-level risk:
unserialize(), Python pickle.loads(), Java ObjectInputStream)curl | bash without checksum verificationAny endpoint that accepts a URL and makes a server-side request:
# Vulnerable — attacker can target internal services
url = request.args.get("url")
response = requests.get(url) # Can reach http://169.254.169.254/metadata
# Safe — strict allowlist
ALLOWED_HOSTS = {"api.example.com", "cdn.example.com"}
parsed = urlparse(url)
if parsed.hostname not in ALLOWED_HOSTS:
abort(400)
Check for: webhook receivers, image proxies, PDF generators fetching URLs, OAuth redirect URIs, import-from-URL features.
For every raw query or ORM escape hatch found in Phase 1, apply the full pattern checklist. Full pattern library is in references/sql-injection.md.
String concatenation into query (always Critical):
// PHP — Critical
$query = "SELECT * FROM users WHERE id = " . $_GET['id'];
$result = $db->query("SELECT * FROM orders WHERE status = '" . $status . "'");
# Python — Critical
cursor.execute("SELECT * FROM users WHERE email = '" + email + "'")
cursor.execute(f"SELECT * FROM users WHERE name = '{name}'")
cursor.execute("SELECT * FROM users WHERE name = '%s'" % name) # % substitution is NOT safe
// JavaScript — Critical
db.query("SELECT * FROM orders WHERE user_id = " + userId)
db.query(`SELECT * FROM users WHERE email = '${email}'`)
Safe alternatives use parameterised queries:
cursor.execute("SELECT * FROM users WHERE email = %s", (email,)) # tuple form — safe
cursor.execute("SELECT * FROM users WHERE email = ?", [email]) # sqlite — safe
ORM escape hatches — disable parameterisation silently:
| Framework | Escape hatch | Risk |
|---|---|---|
| Laravel/Eloquent | DB::raw(), whereRaw(), selectRaw(), orderByRaw() | High if interpolating variables |
| Django ORM | RawSQL(), .raw(), extra(where=) | High if interpolating variables |
| Sequelize | Sequelize.literal(), sequelize.query() | High if not using bind parameters |
| Knex | .raw() | High if not using ? placeholders |
| SQLAlchemy | text() with % formatting | High; use text() with :param bindparams |
For each escape hatch found: read whether any variable is interpolated. If so: Critical if user-controlled, High if internally-controlled.
Dynamic identifiers — table names and column names cannot be parameterised; require an explicit allowlist:
# Vulnerable — user controls column name
column = request.args.get("sort_by")
cursor.execute(f"SELECT * FROM users ORDER BY {column}")
# Safe — explicit allowlist
ALLOWED_SORT = {"id", "name", "created_at"}
if column not in ALLOWED_SORT:
column = "id"
cursor.execute(f"SELECT * FROM users ORDER BY {column}") # Now safe
Second-order injection: a value arrives safely and is stored safely but is later read back and interpolated into a new query without re-parameterisation. Search for patterns where a stored user-supplied value (username, email, display name, address) is used in subsequent query construction.
Stored procedures with dynamic SQL: EXEC or EXECUTE IMMEDIATE inside stored procedures can be injection vectors if they accept user-supplied parameters and interpolate them.
Produce findings in descending severity order: Critical → High → Medium → Low.
For each finding:
### [CRITICAL|HIGH|MEDIUM|LOW] {OWASP category}: {Brief title}
**Location**: `{file}:{line}`
**Issue**: {What the vulnerability is and why it is exploitable}
**Attack vector**: {Concrete attack scenario — what an attacker would send and what they could achieve}
**Fix**:
Before (vulnerable):
```{lang}
{vulnerable code}
After (secure):
{fixed code}
End with a summary scorecard:
Scope: {path reviewed} Files reviewed: {N} Query date: {today}
| OWASP Category | Critical | High | Medium | Low |
|---|---|---|---|---|
| A01 Broken Access Control | ||||
| A02 Cryptographic Failures | ||||
| A03 Injection | ||||
| A04 Insecure Design | ||||
| A05 Misconfiguration | ||||
| A07 Auth Failures | ||||
| A09 Logging Failures | ||||
| A10 SSRF | ||||
| Total |
/trailofbits:semgrep in CI/spwf:pr-create guidance)
If no findings in a category: omit the row. If no findings at all: say so explicitly with the scope reviewed, so the reader knows it was not skipped.
---
## Gotchas
- **ORM use is not injection-proof.** Every major ORM has escape hatches (`DB::raw()`, `RawSQL()`, `Sequelize.literal()`) that silently disable parameterisation. Always check ORM escape hatch usage in addition to raw query presence.
- **`%s` in Python is context-dependent.** `cursor.execute("... WHERE x = '%s'" % val)` is injection-vulnerable. Only `cursor.execute("... WHERE x = %s", (val,))` (tuple second argument) is safe.
- **Second-order injection is invisible to grep.** Searching for concatenation finds first-order injection. Second-order requires tracing a stored value forward to where it is later used in query construction.
- **IDOR is the most common A01 finding and easiest to miss.** Every endpoint accepting an ID parameter: verify that the authenticated user owns that resource, not just that the record exists.
- **Session invalidation is server-side.** Deleting a cookie on logout is not sufficient — the server-side session must be destroyed. Look for what happens server-side on logout.
- **Dynamic ORDER BY / table names cannot be parameterised.** They require an explicit allowlist. Absence of parameterisation is not a bug here — absence of an allowlist is.
- **This skill reviews the working tree, not just the diff.** To scope to a PR's changes only, pass the specific files changed in the PR as the path argument.
## References
- `references/owasp-checklist.md` — Full OWASP Top 10 (2021) checklist with language-specific patterns and detection queries. Load for any category needing deeper investigation.
- `references/sql-injection.md` — Complete SQL injection pattern library: parameterisation patterns per language/ORM, escape hatch matrix, second-order injection, stored procedure risks, dynamic identifier handling.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub simon-potter/spwf --plugin spwf38 skills in this plugin
/address-reviewPhase 6.5 — Address Review. Turn review feedback into action. Sources feedback from either a local report file (e.g. {branch}-review.md from /spwf:pr-review or {branch}-self-review.md from /spwf:simplify) or fetched human comments on an open PR/MR. For each item runs READ → VERIFY → EVALUATE → implement-or-push-back, in priority order (blocking → important → nit). Forbids performative agreement ("you're absolutely right"). Use after pr-review, or whenever a reviewer leaves comments./agent-optimiseCross-cutting — Audit both the project .claude/ and personal ~/.claude/ for quality issues. Covers CLAUDE.md scope and length, agent descriptions, skill frontmatter, and settings.json conflicts. Always audits both scopes. Produces a prioritised P1/P2/P3 fix list./approve-planPhase 2 — Approve plan. Reviews the task list from spec for quality (atomicity, testability, clarity), then applies four adversarial lenses (Skeptic, Architect, Minimalist, Security) as advisory input for the human reviewer. Quality issues are blocking; adversarial findings are advisory. Security lens identifies tasks touching auth, billing, user input, or secrets so the builder has explicit awareness before writing those tasks. Presents everything for explicit human go/no-go before building starts./branch-rescueRecovery skill — moves commits that landed on the base branch onto a proper feature branch and resets local base, without touching origin. Resolves the active OpenSpec change, detects the pre-spec base commit (subject-line grep with manual-confirm fallback), performs three local-only safe git operations, and surfaces the force-push command for the user to run manually. Run standalone; pr-create's rescue offer runs the same procedure inline (_shared/branch-management.md §4), because this skill is user-only./briefPhase 1.5 — Explain a planned change before it is built. Runs between spec and approve-plan, so a mismatch costs a conversation rather than a change. Five sections, expanding then summarising — what will be built, why this way, the choices you didn't make, what it touches, and a short summary. Never blocks: it prints, offers one skippable prompt, and returns. Calibrated via .spwf/learner.md. Companion to recap and understand, which teach after the fact; this teaches before. Runs on changes, not bug fixes./buildPhase 3 orchestrator — Full Red-Green-Refactor cycle. For each pending task: invokes write-tests (Red: write failing tests), then opsx:apply (Green: implement via OpenSpec), then run-tests (Verify: confirm green before moving on). Loops until all tasks complete. After all tasks complete, runs opsx:verify (spec sign-off), then recommends simplify (Refactor).