Differential Review
Reviews code changes through a security lens: git diffs, PRs, staged changes, or explicit file deltas. Scales automatically to change size.
When to Use
- User asks to review a PR, commit, or diff
- User asks "what could break" in a change
- Pre-merge security check
- Reviewing changes to auth, crypto, configuration, or data handling
- Starting point is
git diff, gh pr, or a set of changed files
When NOT to Use
- Full codebase audit from scratch → use deep code reading instead
- Code quality review without security focus → use
backend-code-review
- Reviewing a single isolated function with no change history
- The change is only comments, docs, or test fixtures with no logic
Rationalizations to Reject
These are shortcuts that compromise findings. Reject them explicitly:
- "It's a minor refactor, no security implications" — refactors regularly reintroduce removed fixes silently
- "Tests pass, so it's fine" — tests don't model attackers; passing tests ≠ secure code
- "The change is internal-only" — internal code runs with real privileges on real data
- "The original developer knows what they're doing" — even experts miss blast radius
- "This pattern is used elsewhere in the codebase" — widespread usage doesn't make a pattern correct
- "It's behind authentication" — auth bypasses are common; don't reduce security scrutiny
Workflow (7 Phases)
Phase 0 — Intake & Triage
Determine what changed and assign risk before diving in.
git diff HEAD~1 --stat # overview of files changed
git diff HEAD~1 # full diff
gh pr view --json files # if reviewing a PR
Classify scope:
| Size |
Files changed |
| SMALL |
< 20 |
| MEDIUM |
20–200 |
| LARGE |
200+ |
Risk tier per file:
| Tier |
File types / patterns |
| HIGH |
auth, crypto, session, config/env, external API calls, payment, validation removal, permissions |
| MEDIUM |
business logic, state mutations, new public APIs, DB queries |
| LOW |
comments, tests, UI, logging, docs |
Phase 1 — Changed Code Analysis
For every HIGH/MEDIUM file:
- Side-by-side comparison of before/after logic
- Run
git blame <file> on modified lines — trace history
- Regression check: was a security-related commit silently undone?
- Document at least one concrete attack scenario per HIGH-risk change
Immediate escalation flags:
- Removed validation without replacement
- Access control downgraded (private → public, admin → user)
- Hardcoded credentials or secrets introduced
- Unchecked return values from security-critical calls
- CVE-fix commit reverted or overwritten
Phase 2 — Test Coverage Analysis
- New functions without tests → escalate to HIGH risk
- Modified validation logic → require updated tests
- Complex logic (> 20 lines) without test coverage → flag
Phase 3 — Blast Radius
Count callers of every modified function using Grep:
| Callers |
Blast Radius |
| 1–5 |
LOW |
| 6–20 |
MEDIUM |
| 21–50 |
HIGH |
| 50+ |
CRITICAL |
CRITICAL blast radius + HIGH-risk change = immediate top-priority finding.
Phase 4 — Deep Context (HIGH-risk only)
For files/functions with HIGH or CRITICAL risk:
- Trace full call chains up and down
- Document invariants: what must always be true entering/leaving the function
- Map trust boundaries: where does untrusted data enter?
- Find shared mutable state modified by the change
See methodology.md for line-by-line analysis technique.
Phase 5 — Adversarial Modeling
For every HIGH finding, construct:
- Attacker model — who is the attacker, what access do they have
- Attack vector — concrete sequence of actions to exploit
- Exploitability — EASY / MEDIUM / HARD with justification
See adversarial.md for full framework.
Phase 6 — Report Generation
Generate structured markdown report. Template in reporting.md.
Mandatory sections:
- Executive Summary (severity table + recommendation)
- What Changed (file list, risk tiers, blast radius)
- Critical Findings (HIGH/CRITICAL with attack scenarios)
- Test Coverage Gaps
- Recommendations (immediate / pre-production / tech debt)
- Analysis Limitations (what was NOT covered and why)
Quality Thresholds
Before delivering the report, verify:
Supporting Files
| File |
Purpose |
| methodology.md |
Detailed per-phase analysis techniques |
| adversarial.md |
Attack modeling framework |
| reporting.md |
Report templates |
| patterns.md |
Vulnerability patterns by category |
1---2name: differential-review3description: Security-focused review of code changes (PRs, commits, diffs) with blast radius estimation and adversarial modeling. Seven-phase workflow from triage to final report. Adapted from Trail of Bits methodology.4---56# Differential Review78Reviews code changes through a security lens: git diffs, PRs, staged changes, or explicit file deltas. Scales automatically to change size.910## When to Use1112- User asks to review a PR, commit, or diff13- User asks "what could break" in a change14- Pre-merge security check15- Reviewing changes to auth, crypto, configuration, or data handling16- Starting point is `git diff`, `gh pr`, or a set of changed files1718## When NOT to Use1920- Full codebase audit from scratch → use deep code reading instead21- Code quality review without security focus → use `backend-code-review`22- Reviewing a single isolated function with no change history23- The change is only comments, docs, or test fixtures with no logic2425## Rationalizations to Reject2627These are shortcuts that compromise findings. Reject them explicitly:2829- **"It's a minor refactor, no security implications"** — refactors regularly reintroduce removed fixes silently30- **"Tests pass, so it's fine"** — tests don't model attackers; passing tests ≠ secure code31- **"The change is internal-only"** — internal code runs with real privileges on real data32- **"The original developer knows what they're doing"** — even experts miss blast radius33- **"This pattern is used elsewhere in the codebase"** — widespread usage doesn't make a pattern correct34- **"It's behind authentication"** — auth bypasses are common; don't reduce security scrutiny3536---3738## Workflow (7 Phases)3940### Phase 0 — Intake & Triage4142Determine what changed and assign risk before diving in.4344```bash45git diff HEAD~1 --stat # overview of files changed46git diff HEAD~1 # full diff47gh pr view --json files # if reviewing a PR48```4950**Classify scope:**51| Size | Files changed |52|--------|--------------|53| SMALL | < 20 |54| MEDIUM | 20–200 |55| LARGE | 200+ |5657**Risk tier per file:**58| Tier | File types / patterns |59|--------|----------------------|60| HIGH | auth, crypto, session, config/env, external API calls, payment, validation removal, permissions |61| MEDIUM | business logic, state mutations, new public APIs, DB queries |62| LOW | comments, tests, UI, logging, docs |6364---6566### Phase 1 — Changed Code Analysis6768For every HIGH/MEDIUM file:69- Side-by-side comparison of before/after logic70- Run `git blame <file>` on modified lines — trace history71- **Regression check:** was a security-related commit silently undone?72- Document at least one concrete attack scenario per HIGH-risk change7374**Immediate escalation flags:**75- Removed validation without replacement76- Access control downgraded (private → public, admin → user)77- Hardcoded credentials or secrets introduced78- Unchecked return values from security-critical calls79- CVE-fix commit reverted or overwritten8081---8283### Phase 2 — Test Coverage Analysis8485- New functions without tests → escalate to HIGH risk86- Modified validation logic → require updated tests87- Complex logic (> 20 lines) without test coverage → flag8889---9091### Phase 3 — Blast Radius9293Count callers of every modified function using Grep:9495| Callers | Blast Radius |96|---------|-------------|97| 1–5 | LOW |98| 6–20 | MEDIUM |99| 21–50 | HIGH |100| 50+ | CRITICAL |101102CRITICAL blast radius + HIGH-risk change = immediate top-priority finding.103104---105106### Phase 4 — Deep Context (HIGH-risk only)107108For files/functions with HIGH or CRITICAL risk:109- Trace full call chains up and down110- Document invariants: what must always be true entering/leaving the function111- Map trust boundaries: where does untrusted data enter?112- Find shared mutable state modified by the change113114See [methodology.md](methodology.md) for line-by-line analysis technique.115116---117118### Phase 5 — Adversarial Modeling119120For every HIGH finding, construct:1211. **Attacker model** — who is the attacker, what access do they have1222. **Attack vector** — concrete sequence of actions to exploit1233. **Exploitability** — EASY / MEDIUM / HARD with justification124125See [adversarial.md](adversarial.md) for full framework.126127---128129### Phase 6 — Report Generation130131Generate structured markdown report. Template in [reporting.md](reporting.md).132133Mandatory sections:1341. Executive Summary (severity table + recommendation)1352. What Changed (file list, risk tiers, blast radius)1363. Critical Findings (HIGH/CRITICAL with attack scenarios)1374. Test Coverage Gaps1385. Recommendations (immediate / pre-production / tech debt)1396. Analysis Limitations (what was NOT covered and why)140141---142143## Quality Thresholds144145Before delivering the report, verify:146- [ ] Every finding cites specific `file:line` reference147- [ ] Every HIGH finding includes a concrete attack scenario148- [ ] Blast radius calculated for every modified function149- [ ] Regression check performed (no silently removed security fixes)150- [ ] No vague language ("probably", "might", "could potentially")151- [ ] Coverage limitations explicitly stated152153---154155## Supporting Files156157| File | Purpose |158|------|---------|159| [methodology.md](methodology.md) | Detailed per-phase analysis techniques |160| [adversarial.md](adversarial.md) | Attack modeling framework |161| [reporting.md](reporting.md) | Report templates |162| [patterns.md](patterns.md) | Vulnerability patterns by category |