Chuyển đến nội dung
Skillpedia
Bảo mật8.0k · #12739

variant-analysis

Skill này làm gì

Skill này nhận một lỗi bạn đã tìm thấy và tìm các trường hợp khác có cùng nguyên nhân gốc trong codebase. Skill dành cho kiểm toán viên bảo mật và lập trình viên vừa tìm ra một vấn đề.

Khi nào nên dùng

  • ✓Khi một lỗi được tìm thấy trong một file và bạn muốn biết nó còn xuất hiện ở đâu khác.
  • ✓Khi bạn được hỏi liệu một vấn đề mới có phải là cùng một lỗi với một lỗi trước đó không.
  • ✓Khi bạn muốn biến một lỗi đã biết thành một truy vấn tìm kiếm CodeQL hoặc luật Semgrep.

Liên kết skill

https://github.com/trailofbits/skills/blob/main/plugins/variant-analysis/skills/variant-analysis/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/trailofbits/skills/blob/main/plugins/variant-analysis/skills/variant-analysis/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Chúng tôi vừa tìm thấy một kiểm tra quyền bị thiếu trong file này. Có chỗ nào khác trong code mắc đúng sai lầm đó không?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Skill làm việc qua năm bước: tìm nguyên nhân gốc, viết một mẫu chỉ khớp với lỗi đã biết, tổng quát hóa mẫu đó, rồi tìm kiếm trong code các trường hợp khớp.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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

  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

Câu hỏi thường gặp

Skill này có dùng để tìm lỗi mới từ đầu không?

Không. Nó dùng để tìm thêm các trường hợp của một lỗi bạn đã biết.

Nó có viết bản vá không?

Không. Skill tập trung vào việc tìm các biến thể và không đưa ra đề xuất sửa lỗi.

Nó có giúp viết luật tìm kiếm không?

Có. Nó có thể giúp xây dựng truy vấn CodeQL hoặc Semgrep từ một trường hợp đã biết.

Chi tiết

Mô tả gốc của tác giả

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

Độ phổ biến

Sao GitHub
8.0k
Vị trí xếp hạng
#12739
Giấy phép
CC-BY-SA-4.0
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự