Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Find similar vulnerabilities across a codebase after discovering one instance. Uses pattern matching, AST search, Semgrep/CodeQL queries, and manual tracing to propagate findings. Adapted from Trail of Bits. Use after finding a bug to check if the same pattern exists elsewhere.
.claude/skills/variant-analysis/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-22 | ✗→✓ | ▲ Improved | — | — |
| case-06 | ✗→✓ | ▲ Improved | — | — |
| case-20 | ✗→✓ | ▲ Improved | — | — |
| case-13 | ✗→✓ | ▲ Improved | — | — |
| case-08 | ✗→✓ | ▲ Improved | — | — |
When you find a bug, the same mistake almost certainly exists elsewhere. Variant analysis systematically hunts for siblings of a known vulnerability.
Before searching, understand what makes this bug a bug:
ORIGINAL BUG:
File: src/api/users.ts:42
Type: Missing input validation
Pattern: req.params.id used directly in DB query without sanitization
Root cause: Developer assumed framework sanitizes params
Trigger: Untrusted input reaches database queryExtract the abstract pattern -- not the specific code, but the class of mistake:
For each bug class, create multiple search strategies:
bash# Example: SQL injection via concatenation rg "query\(.*\+.*\)" --type ts rg "execute\(.*\$\{" --type ts rg "\.raw\(.*\+" --type ts # Example: Missing auth middleware rg "router\.(get|post|put|delete)\(" --type ts -l | \ xargs rg -L "authenticate|authorize|requireAuth" # Example: Hardcoded secrets rg "(password|secret|key|token)\s*[=:]\s*['\"][^'\"]{8,}" --type ts
yaml# Example: SQL injection rules: - id: sql-injection-concatenation patterns: - pattern: $DB.query($X + ...) - pattern-not: $DB.query($X, [...]) message: "Potential SQL injection via string concatenation" severity: ERROR # Example: Missing null check before use rules: - id: null-deref-after-find patterns: - pattern: | const $X = await $DB.findOne(...) ... $X.$PROP - pattern-not: | const $X = await $DB.findOne(...) ... if ($X) { ... } message: "Using findOne result without null check" severity: WARNING
ql// Example: Tainted data reaching SQL import javascript from CallExpr call, DataFlow::Node source, DataFlow::Node sink where source = DataFlow::parameterNode(any(Function f).getAParameter()) and sink = call.getArgument(0) and call.getCalleeName() = "query" and DataFlow::localFlow(source, sink) select sink, "Untrusted input flows to SQL query"
For each match:
| Status | Meaning | Action | |--------|---------|--------| | CONFIRMED | Same bug pattern, exploitable | File as finding | | LIKELY | Same pattern, needs deeper analysis | Investigate further | | MITIGATED | Pattern present but other controls prevent exploitation | Document as defense-in-depth gap | | FALSE POSITIVE | Pattern matches but context makes it safe | Document why it's safe |
## Variant Analysis Report
**Original Finding**: [reference to original bug]
**Pattern**: [abstract description of the vulnerability class]
**Search Method**: [grep/semgrep/codeql/manual]
### Confirmed Variants
1. **[SEVERITY]** file.ts:42 -- [description]
2. **[SEVERITY]** other.ts:88 -- [description]
### Likely Variants (Need Investigation)
3. file2.ts:15 -- [why it might be vulnerable]
### Mitigated Instances
4. safe.ts:30 -- Same pattern but [mitigation] prevents exploitation
### Statistics
- Files scanned: X
- Matches found: Y
- Confirmed: Z
- False positives: WIf one endpoint lacks validation, check ALL endpoints:
bash# Find all route handlers rg "router\.(get|post|put|delete|patch)\(" --type ts -n # Check each for validation middleware # Missing validation = variant
If one route lacks auth, check all routes:
bash# Find routes without auth middleware rg "app\.(get|post)\(['\"]" --type ts | grep -v "auth\|protect\|require"
If one catch block leaks info, check all catch blocks:
bashrg "catch.*\{" -A 3 --type ts | grep -E "res\.(send|json).*err"
If one place uses weak crypto, check all crypto usage:
bashrg "createHash\(|createCipher\(|randomBytes\(" --type ts rg "MD5\|SHA1\|DES\|RC4" --type ts
If one TOCTOU exists, check similar check-then-act patterns:
bashrg "if.*await.*find" -A 5 --type ts | grep -E "await.*(update|delete|create)"
After fixing a bug, coroner should:
During review, if a finding is discovered:
When a fix is reviewed:
| Rationalization | Why It's Wrong | Required Action | |----------------|---------------|-----------------| | "It's just one instance" | Bugs travel in packs | Run variant analysis | | "The other code is different" | Same pattern, different syntax | Abstract the pattern | | "We already fixed this area" | Fix might be incomplete | Verify with search | | "Semgrep didn't find anything" | Rules might be too specific | Try multiple search methods | | "It's too many results" | Volume doesn't mean false positive | Triage each result |
Inspired by Trail of Bits variant-analysis plugin.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-22 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-09 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-02 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-06 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-19 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-04 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-18 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-21 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-20 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-10 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-01 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-16 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-13 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-05 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-17 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-11 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-15 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-03 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-07 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-08 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-12 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-14 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted, and 21 counted toward the lift figure. The other 1 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +27 percentage points is the difference between those two pass rates over the 21 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
The per-case answers from this run were removed by the retention sweep, so the case table below shows the verdicts without the text either arm produced. The counts above were recorded at the time and are unaffected. Answers are now kept for 180 days.
Other measured skills in the registry, with their headline benchmark lift.