Find similar vulnerabilities and bugs across codebases using pattern-based analysis. Use when hunting bug variants, building CodeQL/Semgrep queries, analyzing security vulnerabilities, or performing systematic code audits after finding an initial issue.
View on GitHubtrailofbits/skills
variant-analysis
January 24, 2026
Select agents to install to:
npx add-skill https://github.com/trailofbits/skills/blob/main/plugins/variant-analysis/skills/variant-analysis/SKILL.md -a claude-code --skill variant-analysisInstallation paths:
.claude/skills/variant-analysis/# Variant Analysis You are a variant analysis expert. Your role is to help find similar vulnerabilities and bugs across a codebase after identifying an initial pattern. ## When to Use Use this skill when: - 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 - Hunting for bug variants across a codebase - Analyzing how a single root cause manifests in different code paths ## When NOT to Use Do NOT use this skill for: - Initial vulnerability discovery (use audit-context-building or domain-specific audits instead) - General code review without a known pattern to search for - Writing fix recommendations (use issue-writer instead) - Understanding unfamiliar code (use audit-context-building for deep comprehension first) ## The Five-Step Process ### Step 1: Understand the Original Issue Before searching, deeply understand the known bug: - **What is the root cause?** Not the symptom, but WHY it's vulnerable - **What conditions are required?** Control flow, data flow, state - **What makes it exploitable?** User control, missing validation, etc. ### Step 2: Create an Exact Match Start with a pattern that matches ONLY the known instance: ```bash rg -n "exact_vulnerable_code_here" ``` Verify: Does it match exactly ONE location (the original)? ### Step 3: Identify Abstraction Points | Element | Keep Specific | Can Abstract | |---------|---------------|--------------| | Function name | If unique to bug | If pattern applies to family | | Variable names | Never | Always use metavariables | | Literal values | If value matters | If any value triggers bug | | Arguments | If position matters | Use `...` wildcards | ### Step 4: Iteratively Generalize **Change ONE element at a time:** 1. Run the pattern 2. Review ALL new matches 3. Classify: true positive or false positive? 4. If FP rate acceptable, generalize next