Differential Review
Trail of BitsOfficialPublished by Trail of Bits
- Skill
- Review and audit
- Security
- CC-BY-SA-4.0
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
Differential Review provides a structured, risk-based methodology for auditing code changes. It helps developers and security engineers identify potential vulnerabilities by analyzing git history, assessing test coverage, and calculating the blast radius of modifications. The skill is designed to scale its analysis depth based on codebase size and risk level, ensuring that critical changes receive rigorous scrutiny while maintaining efficiency. It produces comprehensive markdown reports that document findings, evidence, and potential attack scenarios.
What it does
- Performs security-focused differential analysis on PRs, commits, and diffs
- Adapts analysis depth based on codebase size and risk level
- Uses git history to identify regressions and security-related code removals
- Calculates blast radius by identifying transitive callers of modified code
- Checks test coverage for modified code to identify untested security risks
- Generates structured markdown reports with concrete findings and evidence
When to use it
- When reviewing PRs or commits for potential security vulnerabilities
- When assessing the impact of refactors on existing security invariants
- When investigating whether a change re-introduces previously fixed bugs
- When determining if modified code lacks sufficient test coverage
- When performing deep audits on critical system changes like authentication rewrites
Advantages
- Risk-first approach prioritizes critical areas like auth and crypto
- Evidence-based findings linked to git history and line numbers
- Scalable methodology suitable for small PRs or large-scale audits
- Quantifiable blast radius analysis reduces blind spots
- Standardized reporting ensures consistent and actionable audit documentation
Usage examples
- “Review this PR for security vulnerabilities and generate a report.”
- The agent analyzes the diff, checks git history for removed security code, calculates the blast radius, and outputs a markdown report detailing any identified risks.
- “Does this refactor introduce any security regressions?”
- The agent performs a differential review, focusing on the refactored logic and comparing it against historical git blame data to identify potential regressions.
- “Perform a deep audit on this authentication system rewrite.”
- The agent applies the surgical strategy, building baseline context, performing deep analysis on auth changes, and conducting adversarial modeling to identify potential exploits.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/trailofbits/differential-review/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip differential-review.zip -d .agents/skills
Documentation by Trail of Bits
Differential Security Review
Security-focused code review for PRs, commits, and diffs.
Core Principles
Risk-First: Focus on auth, crypto, value transfer, external calls
Evidence-Based: Every finding backed by git history, line numbers, attack scenarios
Adaptive: Scale to codebase size (SMALL/MEDIUM/LARGE)
Honest: Explicitly state coverage limits and confidence level
Output-Driven: Always generate comprehensive markdown report file
Rationalizations (Do Not Skip)
| Rationalization | Why It's Wrong | Required Action |
|---|---|---|
| "Small PR, quick review" | Heartbleed was 2 lines | Classify by RISK, not size |
| "I know this codebase" | Familiarity breeds blind spots | Build explicit baseline context |
| "Git history takes too long" | History reveals regressions | Never skip Phase 1 |
| "Blast radius is obvious" | You'll miss transitive callers | Calculate quantitatively |
| "No tests = not my problem" | Missing tests = elevated risk rating | Flag in report, elevate severity |
| "Just a refactor, no security impact" | Refactors break invariants | Analyze as HIGH until proven LOW |
| "I'll explain verbally" | No artifact = findings lost | Always write report |
Quick Reference
Codebase Size Strategy
| Codebase Size | Strategy | Approach |
|---|---|---|
| SMALL (<20 files) | DEEP | Read all deps, full git blame |
| MEDIUM (20-200) | FOCUSED | 1-hop deps, priority files |
| LARGE (200+) | SURGICAL | Critical paths only |
Risk Level Triggers
| Risk Level | Triggers |
|---|---|
| HIGH | Auth, crypto, external calls, value transfer, validation removal |
| MEDIUM | Business logic, state changes, new public APIs |
| LOW | Comments, tests, UI, logging |
Workflow Overview
Pre-Analysis → Phase 0: Triage → Phase 1: Code Analysis → Phase 2: Test Coverage
↓ ↓ ↓ ↓
Phase 3: Blast Radius → Phase 4: Deep Context → Phase 5: Adversarial → Phase 6: ReportDecision Tree
Starting a review?
├─ Need detailed phase-by-phase methodology?
│ └─ Read: methodology.md
│ (Pre-Analysis + Phases 0-4: triage, code analysis, test coverage, blast radius)
│
├─ Analyzing HIGH RISK change?
│ ├─ Read: adversarial.md
│ │ (Phase 5: Attacker modeling, exploit scenarios, exploitability rating)
│ └─ Or delegate to: differential-review:adversarial-modeler agent
│ (Autonomous attacker modeling with concrete exploit scenarios)
│
├─ Writing the final report?
│ └─ Read: reporting.md
│ (Phase 6: Report structure, templates, formatting guidelines)
│
├─ Looking for specific vulnerability patterns?
│ └─ Read: patterns.md
│ (Regressions, reentrancy, access control, overflow, etc.)
│
└─ Quick triage only?
└─ Use Quick Reference above, skip detailed docsAgents
differential-review:adversarial-modeler — Models attacker perspectives and
builds exploit scenarios for HIGH RISK code changes. Follows the 5-step
adversarial methodology (attacker model, attack vectors, exploitability rating,
exploit scenario, baseline cross-reference) and produces structured vulnerability
reports. Delegate to this agent when Phase 5 analysis is needed on high-risk
changes, passing that full namespaced name as subagent_type — a bare
adversarial-modeler is unregistered and the dispatch fails at runtime.
Quality Checklist
Before delivering:
[ ] All changed files analyzed
[ ] Git blame on removed security code
[ ] Blast radius calculated for HIGH risk
[ ] Attack scenarios are concrete (not generic)
[ ] Findings reference specific line numbers + commits
[ ] Report file generated
[ ] User notified with summary
Integration
audit-context-building skill:
Pre-Analysis: Build baseline context
Phase 4: Deep context on HIGH RISK changes
issue-writer skill:
Transform findings into formal audit reports
Command:
issue-writer --input DIFFERENTIAL_REVIEW_REPORT.md --format audit-report
Example Usage
Quick Triage (Small PR)
Input: 5 file PR, 2 HIGH RISK files
Strategy: Use Quick Reference
1. Classify risk level per file (2 HIGH, 3 LOW)
2. Focus on 2 HIGH files only
3. Git blame removed code
4. Generate minimal report
Time: ~30 minutesStandard Review (Medium Codebase)
Input: 80 files, 12 HIGH RISK changes
Strategy: FOCUSED (see methodology.md)
1. Full workflow on HIGH RISK files
2. Surface scan on MEDIUM
3. Skip LOW risk files
4. Complete report with all sections
Time: ~3-4 hoursDeep Audit (Large, Critical Change)
Input: 450 files, auth system rewrite
Strategy: SURGICAL + audit-context-building
1. Baseline context with audit-context-building
2. Deep analysis on auth changes only
3. Blast radius analysis
4. Adversarial modeling
5. Comprehensive report
Time: ~6-8 hoursWhen NOT to Use This Skill
Greenfield code (no baseline to compare)
Documentation-only changes (no security impact)
Formatting/linting (cosmetic changes)
User explicitly requests quick summary only (they accept risk)
For these cases, use standard code review instead.
Red Flags (Stop and Investigate)
Immediate escalation triggers:
Removed code from "security", "CVE", or "fix" commits
Access control modifiers removed (onlyOwner, internal → external)
Validation removed without replacement
External calls added without checks
High blast radius (50+ callers) + HIGH risk change
These patterns require adversarial analysis even in quick triage.
Tips for Best Results
Do:
Start with git blame for removed code
Calculate blast radius early to prioritize
Generate concrete attack scenarios
Reference specific line numbers and commits
Be honest about coverage limitations
Always generate the output file
Don't:
Skip git history analysis
Make generic findings without evidence
Claim full analysis when time-limited
Forget to check test coverage
Miss high blast radius changes
Output report only to chat (file required)
Supporting Documentation
methodology.md - Detailed phase-by-phase workflow (Phases 0-4)
adversarial.md - Attacker modeling and exploit scenarios (Phase 5)
reporting.md - Report structure and formatting (Phase 6)
patterns.md - Common vulnerability patterns reference
For first-time users: Start with methodology.md to understand the complete workflow.
For experienced users: Use this page's Quick Reference and Decision Tree to navigate directly to needed content.
Files
- ATTRIBUTION.mdAdded by AutoGineer951 B
- LICENSELicence file added by AutoGineer19.7 KiB
- SKILL.md7.3 KiB
- adversarial.md4.9 KiB
- agents/openai.yaml245 B
- assets/trail-of-bits-mark.svg3.0 KiB
- methodology.md6.6 KiB
- patterns.md6.8 KiB
- reporting.md6.8 KiB
methodology.md
Differential Review Methodology
Detailed phase-by-phase workflow for security-focused code review.
Pre-Analysis: Baseline Context Building
FIRST ACTION - Build complete baseline understanding:
If audit-context-building skill is available:
# Checkout baseline commit
git checkout <baseline_commit>
# Invoke audit-context-building skill on baseline codebase
# Scope = entire relevant project (e.g., packages/contracts/contracts/ for Solidity, src/ for Rust, etc.)
audit-context-building --scope [entire project or main contract directory] --focus invariants,trust-boundaries,validation-patterns,call-graphs,state-flows
# Examples:
# For Solidity: audit-context-building --scope packages/contracts/contracts
# For Rust: audit-context-building --scope src
# For full repo: audit-context-building --scope .Capture from baseline analysis:
System-wide invariants (what must ALWAYS be true across all code)
Trust boundaries and privilege levels (who can do what)
Validation patterns (what gets checked where - defense-in-depth)
Complete call graphs for critical functions (who calls what)
State flow diagrams (how state changes)
External dependencies and trust assumptions
Why this matters:
Understand what the code was SUPPOSED to do before changes
Identify implicit security assumptions in baseline
Detect when changes violate baseline invariants
Know which patterns are system-wide vs local
Catch when changes break defense-in-depth
Store baseline context for reference during differential analysis.
After baseline analysis, checkout back to head commit to analyze changes.
Phase 0: Intake & Triage
Extract changes:
# For commit range
git diff <base>..<head> --stat
git log <base>..<head> --oneline
# For PR
gh pr view <number> --json files,additions,deletions
# Get all changed files
git diff <base>..<head> --name-onlyAssess codebase size:
find . -name "*.sol" -o -name "*.rs" -o -name "*.go" -o -name "*.ts" | wc -lClassify complexity:
SMALL: <20 files → Deep analysis (read all deps)
MEDIUM: 20-200 files → Focused analysis (1-hop deps)
LARGE: 200+ files → Surgical (critical paths only)
Risk score each file:
HIGH: Auth, crypto, external calls, value transfer, validation removal
MEDIUM: Business logic, state changes, new public APIs
LOW: Comments, tests, UI, logging
Phase 1: Changed Code Analysis
For each changed file:
Read both versions (baseline and changed)
Analyze each diff region:
BEFORE: [exact code] AFTER: [exact code] CHANGE: [behavioral impact] SECURITY: [implications]Git blame removed code:
# When was it added? Why? git log -S "removed_code" --all --oneline git blame <baseline> -- file.sol | grep "pattern"Red flags:
Removed code from "fix", "security", "CVE" commits → CRITICAL
Recently added (<1 month) then removed → HIGH
Check for regressions (re-added code):
git log -S "added_code" --all -pPattern: Code added → removed for security → re-added now = REGRESSION
Micro-adversarial analysis for each change:
What attack did removed code prevent?
What new surface does new code expose?
Can modified logic be bypassed?
Are checks weaker? Edge cases covered?
Generate concrete attack scenarios:
SCENARIO: [attack goal] PRECONDITIONS: [required state] STEPS: 1. [specific action] 2. [expected outcome] 3. [exploitation] WHY IT WORKS: [reference code change] IMPACT: [severity + scope]
Phase 2: Test Coverage Analysis
Identify coverage gaps:
# Production code changes (exclude tests)
git diff <range> --name-only | grep -v "test"
# Test changes
git diff <range> --name-only | grep "test"
# For each changed function, search for tests
grep -r "test.*functionName" test/ --include="*.sol" --include="*.js"Risk elevation rules:
NEW function + NO tests → Elevate risk MEDIUM→HIGH
MODIFIED validation + UNCHANGED tests → HIGH RISK
Complex logic (>20 lines) + NO tests → HIGH RISK
Phase 3: Blast Radius Analysis
Calculate impact:
# Count callers for each modified function
grep -r "functionName(" --include="*.sol" . | wc -lClassify blast radius:
1-5 calls: LOW
6-20 calls: MEDIUM
21-50 calls: HIGH
50+ calls: CRITICAL
Priority matrix:
| Change Risk | Blast Radius | Priority | Analysis Depth |
|---|---|---|---|
| HIGH | CRITICAL | P0 | Deep + all deps |
| HIGH | HIGH/MEDIUM | P1 | Deep |
| HIGH | LOW | P2 | Standard |
| MEDIUM | CRITICAL/HIGH | P1 | Standard + callers |
Phase 4: Deep Context Analysis
If audit-context-building skill is available, invoke it to help answer all the questions below for each HIGH RISK changed function:
# Run audit-context-building on the changed function and its dependencies
audit-context-building --scope [file containing changed function] --focus flow-analysis,call-graphs,invariants,root-causeThe audit-context-building skill will help you answer:
Map complete function flow:
Entry conditions (preconditions, requires, modifiers)
State reads (which variables accessed)
State writes (which variables modified)
External calls (to contracts, APIs, system)
Return values and side effects
Trace internal calls:
List all functions called
Recursively map their flows
Build complete call graph
Trace external calls:
Identify trust boundaries crossed
List assumptions about external behavior
Check for reentrancy risks
Identify invariants:
What must ALWAYS be true?
What must NEVER happen?
Are invariants maintained after changes?
Five Whys root cause:
WHY was this code changed?
WHY did the original code exist?
WHY might this break?
WHY is this approach chosen?
WHY could this fail in production?
If audit-context-building skill is NOT available, manually perform the line-by-line analysis above using Read, Grep, and code tracing.
Cross-cutting pattern detection:
# Find repeated validation patterns
grep -r "require.*amount > 0" --include="*.sol" .
grep -r "onlyOwner" --include="*.sol" .
# Check if any removed in diff
git diff <range> | grep "^-.*require.*amount > 0"Flag if removal breaks defense-in-depth.
Next steps:
For HIGH RISK changes, proceed to adversarial.md
For report generation, see reporting.md
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Declares allowed tools
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Trail of Bits
- Publisher
- Trail of Bits (Official)
- Source
- trailofbits/skills · plugins/differential-review/skills/differential-review · commit e4dd0bb
- Licence
- Creative Commons Attribution-ShareAlike 4.0 International (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Trail of Bits.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download differential-review.zip