Variant Analysis
Trail of BitsOfficialPublished by Trail of Bits
- Skill
- Workflow
- Security
- CC-BY-SA-4.0
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
Variant Analysis is a structured process for hunting down recurring bugs. Once a root cause is identified, this skill guides you through defining the vulnerability, creating an exact match pattern, and iteratively generalizing that pattern to discover similar manifestations elsewhere in the codebase. It emphasizes a methodical approach—moving from specific instances to broader pattern families—while providing a framework for triaging findings and documenting the search process to ensure reproducibility and prevent future regressions.
What it does
- Extracts the root cause of a known vulnerability to define search parameters.
- Guides the creation of exact-match patterns to confirm the initial bug.
- Facilitates iterative generalization of patterns to find related bug variants.
- Provides a triage framework to validate findings and assess severity.
- Supports the creation of regression tests and CI rules based on discovered variants.
- Offers a parallelized workflow for large codebases to maximize search efficiency.
When to use it
- Immediately after discovering a vulnerability, logic bug, or bad pattern.
- When you need to determine if a bug exists in other parts of the codebase.
- When refining security queries for tools like CodeQL or Semgrep.
- During systematic code audits following an initial issue discovery.
Advantages
- Reduces the likelihood of leaving similar vulnerabilities unfixed.
- Provides a reproducible methodology for security audits.
- Helps identify the full scope of a root cause beyond the initial finding.
- Prevents regression by generating CI-ready rules from successful patterns.
Usage examples
- “I found a SQL injection in user_controller.py. Are there others like this?”
- The agent will initiate the variant analysis workflow, starting by extracting the root cause and searching for similar patterns across the codebase.
- “Is this the same bug? I found a similar pattern in the auth module.”
- The agent will compare the new finding against the known root cause and guide you through triaging the candidate.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/trailofbits/variant-analysis/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip variant-analysis.zip -d .agents/skills
Documentation by Trail of Bits
Variant Analysis
Find the other instances of a bug you have already found. One root cause usually has several manifestations, and they are rarely in the module where you found the first one.
When to Use
A vulnerability has been found and you need to search for similar instances
Building or refining CodeQL/Semgrep queries for security patterns
Performing systematic code audits after an initial issue discovery
Analyzing how a single root cause manifests in different code paths
When NOT to Use
Initial vulnerability discovery — use audit-context-building or a domain-specific audit
General code review with no known pattern to search for
Writing fix recommendations — use issue-writer
Understanding unfamiliar code — use audit-context-building first
The Five Steps
Read the reference for a step when you reach it.
1. Understand the original issue. Extract the root cause — why the code is wrong, not what it does — and enumerate the directions a variant could hide in: related identifiers, other manifestations of the same mistake, data-type edge cases. → references/root-cause.md
2. Create an exact match. Write a pattern matching ONLY the known instance and confirm it hits. A pattern that matches nothing means you have misunderstood the bug, and every search built on it is calibrated against the wrong code.
3–4. Generalize one element at a time. Climb from the exact match toward the pattern family, running and reading all matches after each single change. Stop when more than half the matches are noise. → references/searching.md — abstraction ladder, tool selection, false-positive filters
5. Triage. Decide which candidates are real, and say so with a severity attached. → references/triage.md
Then write it up, including the patterns that failed and a CI rule to prevent regression. → references/reporting.md
Running it as a Workflow
This plugin ships /variant-analysis:variants, which runs the five steps across parallel
subagents — one per expansion axis, looping until the sweep stops finding anything new.
Each stage reads the reference above that matches its job.
Use the workflow when the codebase is large or the root cause has many manifestations. Work the steps directly when the search is narrow or you want a say in each generalization.
What Makes Hunts Fail
Narrow scope — searching only the module the original bug was in
Pattern too specific — searching one attribute and missing the family around it
One vulnerability class — chasing a single manifestation of the root cause
Happy-path testing — never trying the null, empty, and boundary cases
Generalizing too fast — abstracting several elements at once, so noise cannot be attributed to any one of them
The first three are covered in root-cause.md and searching.md, the fourth in triage.md.
Resources
CodeQL (resources/codeql/): python.ql, javascript.ql, java.ql, go.ql, cpp.ql
Semgrep (resources/semgrep/): python.yaml, javascript.yaml, java.yaml, go.yaml, cpp.yaml
Report: resources/variant-report-template.md
Files
- ATTRIBUTION.mdAdded by AutoGineer942 B
- LICENSELicence file added by AutoGineer19.7 KiB
- SKILL.md3.8 KiB
- agents/openai.yaml247 B
- assets/trail-of-bits-mark.svg3.0 KiB
- references/reporting.md1.5 KiB
- references/root-cause.md4.1 KiB
- references/searching.md4.5 KiB
- references/triage.md3.5 KiB
- resources/codeql/cpp.ql3.4 KiB
- resources/codeql/go.ql2.0 KiB
- resources/codeql/java.ql2.3 KiB
- resources/codeql/javascript.ql1.7 KiB
- resources/codeql/python.ql2.4 KiB
- resources/semgrep/cpp.yaml2.7 KiB
- resources/semgrep/go.yaml1.8 KiB
- resources/semgrep/java.yaml2.0 KiB
- resources/semgrep/javascript.yaml1.7 KiB
- resources/semgrep/python.yaml2.0 KiB
- resources/variant-report-template.md1.3 KiB
references/root-cause.md
Root Cause and Expansion Axes
Strategy for the first stage of a variant hunt: turning one known bug into the set of independent directions worth searching. Everything downstream is calibrated against what you produce here, so a shallow root cause caps the quality of the entire hunt.
Why Variants Exist
Vulnerabilities cluster because developers make consistent mistakes:
Developer habits: the same person writes similar code and makes similar errors
Copy-paste propagation: boilerplate spreads a bug across the codebase
API misuse patterns: complex APIs invite consistent misunderstandings
Framework idioms: framework patterns create predictable vulnerability shapes
Incomplete fixes: the original bug was fixed in one place and missed elsewhere
Understanding WHY a variant exists predicts WHERE to find it. A copy-paste bug clusters in sibling files; an API misuse bug clusters at every call site of that API, anywhere.
Extracting the Root Cause
Ask these four questions before writing anything:
What operation is dangerous? (
eval(),system(), raw SQL, an authorization check)What data makes it dangerous? (user-controlled input, a null, an attacker-chosen size)
What's missing? (sanitization, validation, a bounds check, a null guard)
What context enables it? (authentication state, an error path, a specific caller)
Then formulate a statement:
"This vulnerability exists because [UNTRUSTED DATA] reaches [DANGEROUS OPERATION] without [REQUIRED PROTECTION]."
Examples:
"User input reaches
eval()without sanitization""Attacker-controlled size reaches
malloc()without an overflow check""Untrusted path reaches
open()without canonicalization"
For logic bugs that have no data flow, state the violated invariant instead: "this function must return False for unauthenticated callers, and it returns True when both IDs are null."
That statement IS the search pattern. Everything below expands it.
The Expansion Checklist
A single root cause manifests in several ways. Enumerate all of them before searching.
1. Semantically related identifiers
If the bug involves one name, every name that plays the same role is in scope:
isAuthenticated: alsoisActive,isAdmin,isVerified,isLoggedInuserId: alsoownerId,creatorId,authorId
Ground these in the codebase. Grep for the names before claiming them: a list of plausible identifiers that don't exist wastes an entire search axis.
2. Other boolean-logic errors
The same mistake in a different shape:
Inverted conditions (
if not xwhereif xwas meant)Wrong default return (
return Trueon the fall-through path)Short-circuit evaluation errors (
orwhereandwas meant)
3. Data-type edge cases
Null/None/undefined comparisons, especially where both sides can be null
Empty string vs null
Zero vs null
Empty arrays and collections
4. Documentation/code mismatches
A function whose behavior contradicts its own name or docstring. Search for functions named
with deny, restrict, block, forbid, check, validate and confirm the return value
means what the name says.
What Makes a Good Axis
Each axis is handed to a separate agent that knows nothing about the others. So an axis must be:
Independently searchable — it names concrete identifiers or code constructs to look for, not a theme like "authorization problems"
Non-overlapping — two axes that find the same code waste an agent
Grounded — its leads exist in this codebase
Pitfalls at This Stage
Pattern too specific. Using only the exact attribute from the original bug misses variants built on related constructs. Enumerate the whole family, not the one instance.
Single vulnerability class. Focusing on one manifestation misses the others. A "returns allow when the condition is false" bug also hides as a null-equality bypass, a docs/code mismatch, and an inverted conditional. List every manifestation before searching.
Ungrounded axes. Plausible-sounding identifiers that don't appear in the codebase produce an agent that searches hard and finds nothing.
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: Needs Python
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/variant-analysis/skills/variant-analysis · 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 or Trail of Bits.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download variant-analysis.zip