variant-analysis
What it does
This skill takes a bug you have already found and searches for other instances of the same root cause across a codebase. It is for security auditors and developers who have just found an issue.
When to use it
- βWhen a bug is found in one file and you want to know where else it occurs.
- βWhen you are asked whether a new problem is the same bug as an earlier one.
- βWhen you want to turn one known bug into a CodeQL or Semgrep search rule.
Skill link
https://github.com/trailofbits/skills/blob/main/plugins/variant-analysis/skills/variant-analysis/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βWe just found a missing permission check in this file. Are there other places in the code where the same mistake happens?β
5 new skills a week. 1 minute to read.
How it works
It works in five steps: it finds the root cause, writes a pattern that matches only the known bug, generalizes that pattern, and then searches the code for matches.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
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
FAQ
Is this for finding new bugs from scratch?
No. It is for finding more instances of a bug you already know about.
Does it write the fix?
No. The skill focuses on finding variants and does not write fix recommendations.
Can it help write search rules?
Yes. It can help build CodeQL or Semgrep queries from a known instance.
Details
Original description by the author
Hunts for the other instances of a bug already found β the variants of one root cause across a codebase. Use immediately after a vulnerability, logic bug, or bad pattern turns up in a specific file and the question becomes where else it occurs, including the bare conversational form ("are there others like this?", "is this the same bug?"). Also for generalizing one known instance into a CodeQL or Semgrep query for its whole pattern family, and for triaging a set of look-alike candidates against a known root cause. Not for initial discovery with no bug in hand.
repo: trailofbits/skills
Popularity
- GitHub stars
- 8.0k
- Ranking position
- #12739
- License
- CC-BY-SA-4.0
- Updated
- 11/2/2026
Comments
- β¦
More skills from this repository
audit-context-building
8.0kHelps your agent learn an unfamiliar codebase before a security review, mapping what each function assumes, guarantees and depends on.
algorand-vulnerability-scanner
8.0kHelps your agent scan Algorand smart contracts, written in TEAL or PyTeal, for 11 common security problems such as rekeying attacks and unchecked fees.
audit-prep-assistant
8.0kHelps your agent get a codebase ready for an outside security review, with static analysis, test coverage, dead-code cleanup and clear documentation.
cairo-vulnerability-scanner
8.0kHelps your agent scan Cairo smart contracts on StarkNet for 6 serious problems, including arithmetic overflow, risky cross-layer messages and signature replay.
Similar skills
reverse-engineer-anything
422kHelps your agent look inside shipped apps and packages to explain features, compare versions, or guide a rebuild, using the REA tool.
1password
394kHelps your agent set up the 1Password CLI, sign in, and read or inject secrets without printing their values into chat.
healthcheck
394kHelps your agent audit the computer or server that runs OpenClaw for security risks, such as SSH, firewall, updates, and backups, then suggest safe fixes.