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
patterns.md
Common Vulnerability Patterns
Quick reference for detecting common security issues in code changes.
Specialized Pattern Resources: For specific contexts, reference these additional pattern databases:
Domain-Specific:
domain-specific-audits/defi-bridges/resources/- 127 bridge-specific findingsdomain-specific-audits/tick-math/resources/- 81 tick math findingsdomain-specific-audits/merkle-trees/resources/- 67 merkle tree findings[Check
domain-specific-audits/skills/for additional domains]
Solidity-Specific:
not-so-smart-contracts- Automated Solidity vulnerability detectorstoken-integration-analyzer- Token integration safety patternsbuilding-secure-contracts/development-guidelines- Solidity best practices
These complement the generic patterns below.
Security Regressions
Pattern: Previously removed code is re-added
Detection:
# Code previously removed for security
git log -S "pattern" --all --grep="security\|fix\|CVE"Red flags:
Commit message contains "security", "fix", "CVE", "vulnerability"
Code removed <6 months ago
No explanation in current PR for re-addition
Example:
// Removed in commit abc123 "Fix reentrancy CVE-2024-1234"
// Re-added in current PR
function emergencyWithdraw() {
// REGRESSION: Reentrancy vulnerability re-introduced
}Double Decrease/Increase Bugs
Pattern: Same accounting operation twice for same event
Detection: Look for two state updates in related functions for same logical action
Example:
// Request exit
function requestExit() {
balance[user] -= amount; // First decrease
}
// Process exit
function processExit() {
balance[user] -= amount; // Second decrease - BUG!
}Impact: User balance decremented twice, protocol loses funds
Missing Validation
Pattern: Removed require/assert/check without replacement
Detection:
git diff <range> | grep "^-.*require"
git diff <range> | grep "^-.*assert"
git diff <range> | grep "^-.*revert"Questions to ask:
Was validation moved elsewhere?
Is it redundant (defensive programming)?
Does removal expose vulnerability?
Example:
function withdraw(uint256 amount) {
- require(amount > 0, "Zero amount");
- require(amount <= balance[msg.sender], "Insufficient");
balance[msg.sender] -= amount;
}Risk: Zero-amount withdrawals, underflow attacks now possible
Underflow/Overflow
Pattern: Arithmetic without SafeMath or checks
Detection:
Look for
+,-,*,/in Solidity <0.8.0Check if SafeMath removed
Look for unchecked blocks in Solidity >=0.8.0
Example:
// Solidity 0.7 without SafeMath
balance[user] -= amount; // Can underflow if amount > balance
// Solidity 0.8+ with unchecked
unchecked {
balance[user] -= amount; // Deliberately bypasses overflow check
}Risk: Integer wrap-around leads to incorrect balances
Reentrancy
Pattern: External call before state update
Detection: Look for CEI (Checks-Effects-Interactions) pattern violations
Example:
// VULNERABLE: External call before state update
function withdraw() {
uint amount = balances[msg.sender];
(bool success,) = msg.sender.call{value: amount}(""); // External call FIRST
require(success);
balances[msg.sender] = 0; // State update AFTER
}
// SAFE: State update before external call
function withdraw() {
uint amount = balances[msg.sender];
balances[msg.sender] = 0; // State update FIRST
(bool success,) = msg.sender.call{value: amount}(""); // External call AFTER
require(success);
}Impact: Attacker can recursively call withdraw() before balance is zeroed
Access Control Bypass
Pattern: Removed or relaxed permission checks
Detection:
git diff <range> | grep "^-.*onlyOwner"
git diff <range> | grep "^-.*onlyAdmin"
git diff <range> | grep "^-.*require.*msg.sender"Questions:
Who can now call this function?
What's the new trust model?
Was check moved to caller?
Example:
- function setConfig(uint value) external onlyOwner {
+ function setConfig(uint value) external {
config = value;
}Risk: Any user can now modify critical configuration
Race Conditions / Front-Running
Pattern: State-dependent logic without protection
Detection: Look for two-step processes without commit-reveal or timelocks
Example:
// Step 1: Approve
function approve(address spender, uint amount) {
allowance[msg.sender][spender] = amount;
}
// Step 2: User can front-run between approval changes
// Attacker sees tx changing approval from 100 to 50
// Front-runs to spend 100, then spends 50 after = 150 totalRisk: MEV/front-running exploits state transitions
Timestamp Manipulation
Pattern: Security logic depending on block.timestamp
Detection:
grep -r "block.timestamp" --include="*.sol"
grep -r "now\b" --include="*.sol" # Solidity <0.7Example:
// VULNERABLE
require(block.timestamp > deadline, "Too early");
// Miner can manipulate timestamp by ~15 seconds
// SAFER
require(block.number > deadlineBlock, "Too early");
// Block numbers are harder to manipulateRisk: Miners can manipulate timestamps within tolerance
Unchecked Return Values
Pattern: External call without checking success
Detection:
git diff <range> | grep "\.call\|\.send\|\.transfer"Example:
// VULNERABLE
token.transfer(user, amount); // Ignores return value
// SAFE
require(token.transfer(user, amount), "Transfer failed");
// Or use SafeERC20 wrapperRisk: Silent failures lead to inconsistent state
Denial of Service
Pattern: Unbounded loops, external call reverts blocking execution
Detection:
Arrays that grow without limit
Loops over user-controlled array
Critical function depends on external call success
Example:
// DOS: Attacker adds many users, making loop too expensive
function distributeRewards() {
for (uint i = 0; i < users.length; i++) {
users[i].transfer(reward); // Runs out of gas
}
}Risk: Function becomes unusable due to gas limits
Quick Detection Commands
Find removed security checks:
git diff <range> | grep "^-" | grep -E "require|assert|revert"Find new external calls:
git diff <range> | grep "^+" | grep -E "\.call|\.delegatecall|\.staticcall"Find changed access modifiers:
git diff <range> | grep -E "onlyOwner|onlyAdmin|internal|private|public|external"Find arithmetic changes:
git diff <range> | grep -E "\+|\-|\*|/"For detailed analysis workflow, see methodology.md For building exploit scenarios, see adversarial.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