变异分析

其他 社区

技能解读

当前原文的自动摘译,尚未人工审校。

何时使用

已发现漏洞,您需要搜索类似实例 构建或改进安全模式的 CodeQL/Semgrep 查询 在初始问题发现后执行系统代码审核 分析单个根本原因在不同代码路径中的表现

何时不使用

初始漏洞发现 — 使用审计上下文构建或特定于域的审计 没有已知模式的一般代码审查来搜索 编写修复建议 — 使用问题编写器 了解不熟悉的代码 — 首先使用审计上下文构建

五个步骤

当您到达某个步骤时,请阅读该步骤的参考。 1.了解原来的问题。提取根本原因——为什么代码是错误的,而不是它做了什么——并枚举变体可能隐藏的方向:相关标识符、同一错误的其他表现、数据类型边缘情况。 → 参考文献/root-cause.md

将其作为工作流程运行

这个插件附带了/variant-analysis:variants,它跨并行子代理运行五个步骤——每个扩展轴一个,循环直到扫描停止发现任何新的东西。每个阶段都会阅读上面与其工作相匹配的参考资料。当代码库很大或根本原因有多种表现形式时,请使用工作流。当搜索范围很窄或者您想在每个概括中都有发言权时,请直接执行步骤。

是什么导致狩猎失败

范围狭窄 — 只搜索原始 bug 所在的模块 模式太具体 — 搜索一个属性并错过它周围的系列 一个漏洞类别 — 追寻根本原因的单一表现 快乐路径测试 — 从不尝试 null、空和边界情况 泛化速度太快 — 一次抽象多个元素,因此噪声无法被消除

流狐档案 运行与权限由流狐静态检查推断,不代表作者声明或实际测试结果。
领域
通用
作者声明的智能体
未找到明确声明;不据此推断已兼容或已测试
静态检查
88 / 100 · 启发式扫描,不代表运行安全
运行环境证据
未执行;当前没有隔离运行测试证据
作者 / 版本 / 许可证
@trailofbits · 未声明许可证
上下文用量评级
低消耗
接入复杂程度
即装即用
是否需要外部接口密钥
不需要
兼容的系统
未声明(默认跨平台)
运行环境要求
Python
检测到的文件与系统行为
  • 只读
  • 允许写入 / 修改
网络行为
仅限本地
安装命令数
无(仅作为资料)

需要注意: 未声明工具权限范围;实际权限由运行环境决定。

作者说明文件(原文) SKILL.md

# 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](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](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](references/triage.md)

**Then write it up**, including the patterns that failed and a CI rule to prevent regression.
→ [references/reporting.md](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

1. **Narrow scope** — searching only the module the original bug was in
2. **Pattern too specific** — searching one attribute and missing the family around it
3. **One vulnerability class** — chasing a single manifestation of the root cause
4. **Happy-path testing** — never trying the null, empty, and boundary cases
5. **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`

讨论

基于 GitHub Discussions。登录 GitHub 即可参与讨论、点赞、订阅更新。