agentleFS
mahumadadmahumadad/quarry/skills/sast/variant-analysis/SKILL.md

variant-analysis

Skill1 starsChanged 11 days agoMITView on GitHub

Propagate one confirmed vulnerability pattern across the entire codebase or API surface. Use immediately after ANY finding is confirmed with source access: extract the abstract pattern (sink + missing guard + dataflow shape) and search for siblings — same vulnerable call, same missing check, same endpoint template. Turns one finding into complete coverage of its class. Keywords: variant analysis, pattern propagation, codeql variant, semgrep rule from finding, siblings, same-bug-different-location, systematic coverage. Do NOT use before at least one finding is confirmed (that is hunting, not variant analysis) or without source/schema access.

15 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use yara-rule-authoring, second-opinion and 1 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • TheWatcher01Skill

    yara-rule-authoring

    Guides authoring of high-quality YARA-X detection rules for malware identification. Use when writing, reviewing, or optimizing YARA rules. Covers naming conventions, string selection, performance optimization, migration from legacy YARA, and false positive reduction. Triggers on: YARA, YARA-X, malware detection, threat hunting, IOC, signature, crx module, dex module.

    Also in 3 projects that use this

  • MicrosoftSkill

    second-opinion

    Independent review of current work or a past session. USE WHEN a user wants a second opinion. DO NOT USE WHEN ordinary code review is wanted — use code-review.

    Also in 3 projects that use this

  • SentrySkill

    security-review

    Finds exploitable application security vulnerabilities in code changes. Use for Warden security scans, appsec review, OWASP-style checks, authentication or authorization bugs, injection, XSS, SSRF, path traversal, secrets, unsafe crypto, webhook verification, open redirects, or sensitive data exposure.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 15 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Write it as a one-line predicate: "calls to X where argument contains request-derived data and no call to Y in the same handler".

    line 40
  2. Distinctive:

    Sweep the whole repo / service map: Every hit is a VARIANT CANDIDATE — not a finding.

    line 50
  3. Distinctive:

    NOT 12 near-duplicate findings.

    line 66

“Common” is measured: kept by at least 6 in 10 of the 15 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Purpose

Finding one SQLi is luck; finding ALL SQLi built the same way is analysis. Clients fix the instance you report and leave the 11 siblings. Variant analysis is the discipline that converts a confirmed finding into class-wide coverage — and it's also how you verify a fix ("the patch closed endpoint A; the same pattern in B, C, D remains").

Methodology

  1. Abstract the confirmed finding into a pattern. From the PoC, extract:
    • the SINK (exact function/API: db.execute(, render_template_string(, exec(, an HTTP client call...),
    • the missing GUARD (no parameterization, no authorization decorator, no allowlist check),
    • the SOURCE shape (request param → sink distance, any wrappers). Write it as a one-line predicate: "calls to X where argument contains request-derived data and no call to Y in the same handler".
  2. Encode the pattern as a query:
    • Semgrep rule (fastest; one YAML per pattern, run in seconds),
    • CodeQL query when a database already exists (static-analysis-toolkit),
    • fallback: structured grep / ast-grep for simple shapes. Iterate until the rule fires on the ORIGINAL finding location — if it can't find the bug you know, it won't find its siblings.
  3. Sweep the whole repo / service map. Every hit is a VARIANT CANDIDATE — not a finding. Triage each: same source reachability? same guard really absent? sanitization happening in a wrapper the pattern can't see?
  4. Confirm candidates per class rules. Variants get the same evidence bar as the original: live trigger where in scope, or Inferred with the code-path evidence (source → sink trace + absent guard) clearly attached. Mass-reporting unverified variants violates the anti-fabrication rules.
  5. No-source variant analysis (black-box): pattern = endpoint shape. If /api/v1/users/{id}/export had IDOR, enumerate sibling routes from api-discovery and replay the identity-swap (session-context) across all handlers sharing the route template. Route-naming symmetry is the pattern.
  6. Report as a family. One finding per distinct root cause, with a variant table (location, status: demonstrated/inferred/not-reachable) — NOT 12 near-duplicate findings. Report-writing skill has the family format.

Tooling

  • semgrep --config pattern.yml . — primary pattern engine.
  • codeql database analyze — deep dataflow variants on an existing DB.
  • ast-grep / sg — fast syntactic sweeps.
  • Router/framework route dumps (Rails routes, Flask url_map, OpenAPI paths) for black-box sibling enumeration.

Validation Gate (minimum proof)

  • The pattern rule demonstrably matches the original confirmed finding.
  • Each reported variant carries: location, source→sink trace (or live evidence), guard-absence note, and status tag. Unverifiable variants go in the finding's variant table as Inferred, never as separate Demonstrated findings.

Gotchas

  • Wrapper blindness: sanitization/authorization in middleware or decorators makes naive patterns over-fire — extend the pattern with the wrapper's signature once discovered, and re-sweep.
  • Copy-paste drift: siblings often have subtle differences (one HAS the check). Verify each hit individually; the pattern finds candidates, humans (validators) confirm.
  • Generated code and vendored dirs: exclude vendor/, node_modules/, generated protobuf — or you'll drown in out-of-scope hits (supply-chain findings are the other skill's job).
  • Record sweep coverage: files/routes searched, exclusions — the variant table's completeness claim depends on it.

Chain Anchors

  1. Variant family mapped → which variant sits on the highest-value asset (admin panel, payment service)? Retest that one first for Demonstrated.
  2. Guard missing systematically (e.g., no authorization decorator anywhere in a service) → that is a structural finding: report root cause once, cite all affected routes.
  3. Fix-verification mode: after client remediation, re-run the same pattern — unfixed siblings become the retest report's core content.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.