Security-Focused Code Review
Adapted from the review-security skill in borkweb/skills
(MIT License, Copyright (c) 2025 Matthew Batchelder). The original is a large
reference library of twenty evidence-based pattern files grounded in real CVEs
from the Linux kernel, OpenSSL, Chromium, curl, Go, Rust, and other major
open-source projects; this skill condenses its workflow and severity model
into a single self-contained pass over four high-frequency categories:
injection, authentication/authorization, secrets, and unsafe deserialization.
Step 1: Pin the scope
Before looking for anything, know exactly what you are reviewing:
- Record the base and head commits (or the exact diff/file list) you are reviewing.
- If the scope changes mid-review (new commits land, files are added), re-pin
and note that the earlier findings were against an older snapshot.
- Prefer reviewing
git diff <base>...<head>, not just the files touched —
a one-line change to a validation function can matter more than the diff
around it suggests, so trace callers when a changed function is
security-relevant.
Step 2: Walk each category against the diff
Do not scan impressionistically. For each changed file, ask the four
questions below in order, and cite file:line for every finding — "looks
fine" without a line reference is not a finding and not a clearance.
Injection
Core question: does any string built from user-controlled input reach an
interpreter (SQL, shell, template engine, HTML renderer, regex engine,
deserializer, ORM .raw()/.extra() call) without passing through a
parameterized API or an escaping function designed for that exact sink?
- Check: SQL built with f-strings/concatenation instead of parameterized
queries or an ORM's bound-parameter methods.
- Check: shell commands built with string interpolation (
subprocess.run(cmd, shell=True) with an f-string) instead of an argument list.
- Check: HTML/JS built by string-concatenating user input instead of using
the templating engine's auto-escaping, or
innerHTML/dangerouslySetInnerHTML
fed from a request body.
- Red flag: any
f"...{user_input}..." or + string-building that is then
passed to execute(), eval(), exec(), os.system(), or a template
renderer with autoescape disabled.
Authentication & authorization
Core question: for this new or changed endpoint/handler, what proves the
caller is who they claim to be, and what proves they are allowed to do this
specific action on this specific resource (not just "logged in")?
- Check: every new route/handler has an explicit auth check, not an inherited
one you're assuming from a decorator applied two files away — confirm it.
- Check: object-level authorization ("IDOR") — does the handler verify the
authenticated user owns/can-access the specific
id in the request, or
does it trust any ID a caller supplies?
- Check: session/token validation happens before any side-effecting work, not
after, and failure paths deny by default rather than falling through.
- Red flag: a new
/admin/* or resource-mutating route with no visible
permission check in the diff, or an authorization check that compares
against a value also supplied by the client.
Secrets
Core question: could this change cause a credential, API key, token, or
private key to be written somewhere it can leak — source control, logs,
error messages, or a client-visible response?
- Check: no literal API keys, passwords, or tokens added to source, config
committed to the repo, test fixtures, or example files.
- Check: logging statements and exception messages don't include
full request/response bodies, headers (
Authorization, Cookie), or
config objects that may contain secrets.
- Check: new config/env var plumbing reads secrets from environment or a
secret manager, not from a hardcoded default used as a fallback.
- Red flag:
password=, api_key=, secret=, token= followed by a quoted
literal in a diff; print(request) or logger.debug(config) style logging
of whole objects.
Unsafe deserialization
Core question: does this change deserialize data from an untrusted
source (network request, uploaded file, queue message, cache) using a format
or library that can execute code or construct arbitrary objects as a side
effect of parsing?
- Check: Python
pickle.loads/yaml.load (without SafeLoader) on anything
that isn't fully trusted and generated by your own process.
- Check: Java/
.NET native (de)serialization of attacker-reachable byte
streams instead of a safe, schema-constrained format (JSON with a strict
schema, protobuf).
- Check: JS
eval()/Function() or Node's vm module on configuration or
request data instead of JSON.parse.
- Red flag: any new call to a format-agnostic "load arbitrary object graph"
deserializer fed directly from a request body, upload, or queue payload.
Step 3: Record findings with a severity
For every finding, use this shape so a reviewer or author can act on it
without re-deriving the reasoning:
[SEVERITY] category file:line
Problem: <1-2 lines, what's wrong>
Evidence: <the pattern matched, e.g. "string-built SQL reaches execute()">
Fix: <concrete, specific suggestion>
Severity:
- CRITICAL — remotely exploitable without authentication, or leads to
RCE, auth bypass, or data exfiltration.
- HIGH — exploitable by an authenticated user beyond their own data/scope.
- INFORMATIONAL — a real gap, but not currently reachable, or a hygiene
issue (e.g. a secret-shaped literal that turns out to be a test fixture
already rotated out of use).
Step 4: Verdict
Close every review with one of:
- PASS — no CRITICAL/HIGH findings.
- PASS WITH REMEDIATIONS — CRITICAL/HIGH findings existed and were fixed
and re-verified before merge.
- FAIL — unresolved CRITICAL/HIGH findings; list each with what's needed
to close it. Do not merge.
Never write "looks fine overall" as a substitute for walking the four
categories explicitly — the point of this skill is that each category gets
its own deliberate pass, not a single impression of the diff.
1---2name: security-focused3skill_id: code-review/security-focused4title: Security-Focused Code Review5description: Review a diff for injection, auth, secrets, and unsafe deserialization issues.6source_url: https://github.com/borkweb/skills/blob/46d2091b6da43e3afe0c22c5f04a92afa28d8590/skills/core/review-security/SKILL.md7license: MIT8shelf: quality9metadata:10 source: https://skillmd.com/skills/aletheore/security-focused11---1213# Security-Focused Code Review1415Adapted from the `review-security` skill in [borkweb/skills](https://github.com/borkweb/skills)16(MIT License, Copyright (c) 2025 Matthew Batchelder). The original is a large17reference library of twenty evidence-based pattern files grounded in real CVEs18from the Linux kernel, OpenSSL, Chromium, curl, Go, Rust, and other major19open-source projects; this skill condenses its workflow and severity model20into a single self-contained pass over four high-frequency categories:21**injection, authentication/authorization, secrets, and unsafe deserialization**.2223## Step 1: Pin the scope2425Before looking for anything, know exactly what you are reviewing:26- Record the base and head commits (or the exact diff/file list) you are reviewing.27- If the scope changes mid-review (new commits land, files are added), re-pin28 and note that the earlier findings were against an older snapshot.29- Prefer reviewing `git diff <base>...<head>`, not just the files touched —30 a one-line change to a validation function can matter more than the diff31 around it suggests, so trace callers when a changed function is32 security-relevant.3334## Step 2: Walk each category against the diff3536Do not scan impressionistically. For each changed file, ask the four37questions below in order, and cite `file:line` for every finding — "looks38fine" without a line reference is not a finding and not a clearance.3940### Injection41**Core question:** does any string built from user-controlled input reach an42interpreter (SQL, shell, template engine, HTML renderer, regex engine,43deserializer, ORM `.raw()`/`.extra()` call) without passing through a44parameterized API or an escaping function designed for that exact sink?45- Check: SQL built with f-strings/concatenation instead of parameterized46 queries or an ORM's bound-parameter methods.47- Check: shell commands built with string interpolation (`subprocess.run(cmd,48 shell=True)` with an f-string) instead of an argument list.49- Check: HTML/JS built by string-concatenating user input instead of using50 the templating engine's auto-escaping, or `innerHTML`/`dangerouslySetInnerHTML`51 fed from a request body.52- Red flag: any `f"...{user_input}..."` or `+` string-building that is then53 passed to `execute()`, `eval()`, `exec()`, `os.system()`, or a template54 renderer with autoescape disabled.5556### Authentication & authorization57**Core question:** for this new or changed endpoint/handler, what proves the58caller is who they claim to be, and what proves they are allowed to do this59specific action on this specific resource (not just "logged in")?60- Check: every new route/handler has an explicit auth check, not an inherited61 one you're assuming from a decorator applied two files away — confirm it.62- Check: object-level authorization ("IDOR") — does the handler verify the63 authenticated user owns/can-access the specific `id` in the request, or64 does it trust any ID a caller supplies?65- Check: session/token validation happens before any side-effecting work, not66 after, and failure paths deny by default rather than falling through.67- Red flag: a new `/admin/*` or resource-mutating route with no visible68 permission check in the diff, or an authorization check that compares69 against a value also supplied by the client.7071### Secrets72**Core question:** could this change cause a credential, API key, token, or73private key to be written somewhere it can leak — source control, logs,74error messages, or a client-visible response?75- Check: no literal API keys, passwords, or tokens added to source, config76 committed to the repo, test fixtures, or example files.77- Check: logging statements and exception messages don't include78 full request/response bodies, headers (`Authorization`, `Cookie`), or79 config objects that may contain secrets.80- Check: new config/env var plumbing reads secrets from environment or a81 secret manager, not from a hardcoded default used as a fallback.82- Red flag: `password=`, `api_key=`, `secret=`, `token=` followed by a quoted83 literal in a diff; `print(request)` or `logger.debug(config)` style logging84 of whole objects.8586### Unsafe deserialization87**Core question:** does this change deserialize data from an untrusted88source (network request, uploaded file, queue message, cache) using a format89or library that can execute code or construct arbitrary objects as a side90effect of parsing?91- Check: Python `pickle.loads`/`yaml.load` (without `SafeLoader`) on anything92 that isn't fully trusted and generated by your own process.93- Check: Java/`.NET` native (de)serialization of attacker-reachable byte94 streams instead of a safe, schema-constrained format (JSON with a strict95 schema, protobuf).96- Check: JS `eval()`/`Function()` or Node's `vm` module on configuration or97 request data instead of `JSON.parse`.98- Red flag: any new call to a format-agnostic "load arbitrary object graph"99 deserializer fed directly from a request body, upload, or queue payload.100101## Step 3: Record findings with a severity102103For every finding, use this shape so a reviewer or author can act on it104without re-deriving the reasoning:105106```107[SEVERITY] category file:line108 Problem: <1-2 lines, what's wrong>109 Evidence: <the pattern matched, e.g. "string-built SQL reaches execute()">110 Fix: <concrete, specific suggestion>111```112113Severity:114- **CRITICAL** — remotely exploitable without authentication, or leads to115 RCE, auth bypass, or data exfiltration.116- **HIGH** — exploitable by an authenticated user beyond their own data/scope.117- **INFORMATIONAL** — a real gap, but not currently reachable, or a hygiene118 issue (e.g. a secret-shaped literal that turns out to be a test fixture119 already rotated out of use).120121## Step 4: Verdict122123Close every review with one of:124- **PASS** — no CRITICAL/HIGH findings.125- **PASS WITH REMEDIATIONS** — CRITICAL/HIGH findings existed and were fixed126 and re-verified before merge.127- **FAIL** — unresolved CRITICAL/HIGH findings; list each with what's needed128 to close it. Do not merge.129130Never write "looks fine overall" as a substitute for walking the four131categories explicitly — the point of this skill is that each category gets132its own deliberate pass, not a single impression of the diff.