agentleFS
scadastrangelovescadastrangelove/rust-in-peace/.claude/skills/threat-model/SKILL.md

threat-model

Skill25 starsChanged 4 months agoApache-2.0View on GitHub

Build a threat model for a target codebase. Three modes: "interview" walks an application owner through the four-question framework and produces a threat model from their answers; "bootstrap" derives a threat model from the code plus past vulnerabilities (CVEs, git history, pentest reports) when no owner is available; "bootstrap-then-interview" chains the two when both owner and codebase are present. All write THREAT_MODEL.md in a shared schema. Use when asked to "threat model", "build a threat model", "map the attack surface", or "what should we be worried about in this codebase".

61 other projects use a version of this, 4 of them edited.

Adopted by

Most recently taken up by

Used with

Projects with it also use supply-chain-review, orbit and 7 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.
  • MesteriisSkill

    supply-chain-review

    Reviews lockfiles, installers, provenance, CI permissions, dependency confusion, artifacts, registries, and publishing.

    Also in 3 projects that use this

  • mbwsimsSkill

    orbit

    Run for repo-wide or diff-wide readiness sweeps: "/orbit", "/orbit pr", "/orbit deep", "/orbit quick", "audit this project", "project-wide review", "is this PR ready overall", or "combined security, tests, codebase, evolution, and instruction review". Use this for broad multi-system assessment, not for a single-file review or a one-domain question.

    Also in 3 projects that use this

  • mbwsimsSkill

    test-plan

    This skill should be used when the user asks to "plan tests", "what should I test", "what tests do I need", "test plan for", "testing strategy for", "test matrix for", "what cases should I cover", "help me plan tests", mentions "/test-plan", or wants to understand what tests are needed before writing any test code.

    Also in 3 projects that use this

  • Sagargupta16Skill

    dependency-audit

    Audit project dependencies for security vulnerabilities, licensing issues, maintenance health, and optimization opportunities. Use it during regular security audits (monthly or quarterly); before a major release when you want to ensure the dependency tree is clean; when evaluating whether to adopt or replace a dependency; after a security advisory affects one of your dependencies; when your install times or bundle sizes have grown noticeably.

    Also in 4 projects that use this

  • patrickserranoSkill

    performance-audit

    Audit and improve SwiftUI runtime performance. Use for requests to diagnose slow rendering, janky scrolling, high CPU/memory usage, excessive view updates, or layout thrash in SwiftUI apps.

    Also in 3 projects that use this

  • asterkinSkill

    adr

    Create Architecture Decision Records (ADRs) following project standards. Guides template usage, process, and best practices for documenting architecturally significant decisions.

    Also in 6 projects that use this

The file

Show its rules and text

We split this skill into the rules it gives an agent

13 rules. 0 are common, 5 are distinctive, and 8 are very specific to this project.

  • 0

    Common

    Most of the 55 edited versions we read keep these.

  • 5

    Distinctive

    This author's own choices. Worth a look.

  • 8

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Litmus test: If patching one line of code makes an entry disappear, it was a vulnerability, not a threat.

    line 37
  2. Distinctive:

    Before proceeding, confirm and state in your first response:

    line 57
  3. Very specific:

    If --vulns points at a URL or you are asked to "fetch CVEs", you will query only public advisory databases (NVD, GitHub Security …

    line 61
  4. Very specific:

    If the user asks you to validate a threat by running an exploit, decline and point them at the vuln-pipeline (README Step 2) instead.

    line 65
  5. Very specific:

    All modes write the same artifact (THREAT_MODEL.md, schema in schema.md) so downstream consumers (pipeline recon/judge, verifier agents) do …

    line 81
  6. Very specific:

    Do not read interview.md or bootstrap.md in full up front.

    line 95
  7. Very specific:

    If a re-read via the Read tool is refused as "file unchanged", the prior result was evicted.

    line 98
  8. Distinctive:

    When the owner is available *and* the codebase is checked out, this is the recommended path: the owner's time goes to refining a …

    line 113
  9. Very specific:

    Read bootstrap.md and follow it end-to-end.

    line 121
  10. Very specific:

    Before deriving threats, classify the target into ONE layer and record it as target_layer in section 1.

    line 137
  11. Distinctive:

    Release-diff is mandatory: If the checkout is a dev pin, note the latest released tag and flag which threats are shipped vs dev-only-new vs …

    line 159
  12. Very specific:

    All modes MUST emit <target-dir>/THREAT_MODEL.md conforming to schema.md in this directory.

    line 172
  13. Distinctive:

    After writing the file, print to the user:

    line 177

“Common” is measured: kept by at least 6 in 10 of the 55 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

threat-model

A threat model answers "what could go wrong with this system, who would do it, and what should we do about it?" independently of whether any specific bug has been found yet. It is the map; vulnerability discovery is the metal detector. A good threat model tells the pipeline where to look and tells triage which findings matter.

Litmus test: If patching one line of code makes an entry disappear, it was a vulnerability, not a threat. A threat ("attacker achieves memory disclosure via untrusted binary parsing") still stands after every known bug is fixed; a vulnerability ("Table::sum_record reads an unsafe slice at an attacker-controlled data_off without a bounds check") does not. This skill produces threats. Vulnerabilities appear only as evidence that raises a threat's likelihood score.

Invocation: /threat-model [bootstrap-then-interview|bootstrap|interview] <target-dir> [flags]


Step 0 — Safety preamble (always runs first)

This skill performs static analysis only. It reads source, git history, and any vulnerability reports the user supplies, and writes a single output file (<target-dir>/THREAT_MODEL.md). It does not build, execute, fuzz, or modify the target, and does not make network requests against the target's infrastructure.

Before proceeding, confirm and state in your first response:

  1. The target directory exists and is a local checkout you can read.
  2. You will not execute any code from the target directory.
  3. If --vulns points at a URL or you are asked to "fetch CVEs", you will query only public advisory databases (NVD, GitHub Security Advisories, the project's own issue tracker) and never the target's live deployment.

If the user asks you to validate a threat by running an exploit, decline and point them at the vuln-pipeline (README Step 2) instead.


Step 1 — Route to a mode

Parse $ARGUMENTS:

First tokenRoute to
interviewRead interview.md in this directory and follow it.
bootstrapRead bootstrap.md in this directory and follow it.
bootstrap-then-interviewBootstrap first, then interview seeded from the draft. See below.
anything else, or emptyAsk the user: "Is someone who owns or built this system available to answer questions in this session?" Yes and the codebase is checked out → recommend bootstrap-then-interview. Yes but no codebase → interview.md. No → bootstrap.md.

All modes write the same artifact (THREAT_MODEL.md, schema in schema.md) so downstream consumers (pipeline recon/judge, verifier agents) do not need to know which mode produced it.

interviewbootstrap
NeedsAn application owner present in the sessionA local checkout; optionally past vulns
MethodFour-question framework: conversational walk through what are we working on → what can go wrong → what are we going to do about it → did we do a good jobFive stages: parallel research swarm → synthesize sections 1-3 + vuln table → generalize vulns into threat classes → STRIDE gap-fill → emit
Best forNew systems, design reviews, systems where the risk lives in business logic the code doesn't showInherited systems, third-party code, OSS dependencies, anything with a CVE history
Provenance taginterviewbootstrap

Context durability. Interview mode is multi-turn; tool results from early reads may be evicted before you need them. To stay resilient:

  • Do not read interview.md or bootstrap.md in full up front. Read the mode file (or the relevant section of it) at the point you need it, one question or stage at a time.
  • If a re-read via the Read tool is refused as "file unchanged", the prior result was evicted; reload with cat <path> via Bash instead.

Interview backbone (so you can proceed even if interview.md is unavailable mid-session):

QQuestionFills schema sections
Q1What are we working on?section 1 context, section 2 assets, section 3 entry points
Q2What can go wrong?section 4 threat rows (id, threat, actor, surface, asset)
Q3What are we going to do about it?section 4 impact/likelihood/status/controls; section 5 deprioritized; section 8 recommended mitigations
Q4Did we do a good job?validate ranking, coverage check, section 6 open questions

bootstrap-then-interview mode

When the owner is available and the codebase is checked out, this is the recommended path: the owner's time goes to refining a code-grounded draft instead of describing the system from scratch.

  1. Tell the owner: "I'll read the code first and come back with a draft (about 5-10 min), then we'll walk it together. Want that, or would you rather start cold?" Only proceed if they opt in; otherwise fall back to interview.md.
  2. Read bootstrap.md and follow it end-to-end. Write <target-dir>/THREAT_MODEL.md.
  3. Immediately continue into interview mode: read interview.md and follow it with --seed <target-dir>/THREAT_MODEL.md in effect. The section 6 open questions from bootstrap become your Q1-Q4 prompts; the owner confirms, corrects, and adds rather than starting from nothing.
  4. Overwrite <target-dir>/THREAT_MODEL.md with the refined model. Set provenance mode: bootstrap-then-interview.

The same flow is available manually: run bootstrap first, then interview --seed <THREAT_MODEL.md> in a later session.


Step 1.5 — Classify the target's LAYER (bug-class & tool router) [ADR-1]

Before deriving threats, classify the target into ONE layer and record it as target_layer in section 1. The layer decides the primary bug-class to hunt and the primary tool — routing this deliberately is the difference between finding the class that ships and re-running a fuzzer over already-fuzzed code (see LESSONS.md L42–L44).

LayerSignalPrimary bug-classPrimary methodAdd finders
data-format parserbytes → structure; a decode/parse/from_bytes entry over untrusted inputpanic / OOB / overflow / alloc-DoS on malformed inputfuzz-firstclassic cargo-fuzz + find→fuzz CWE→oracle table
protocol / state-machinehandshakes, sessions, negotiated params, client+server sidesmissing/asymmetric enforcement, downgrade, state-transition data-loss, protocol-tied resource growthinvariant-firstinvariant-symmetry + silent-failure differential
API-contract / libraryserialization, containers, config, fs helpers; a documented contractcontract violation, silent failure, spec/impl divergencedifferential-firstspec-vs-impl + control-vs-attack differential

Rules:

  • Fuzz only when layer = parser (or a parser sub-surface) and not already well-covered by OSS-Fuzz and the class is crash/OOB/alloc. Otherwise deprioritize byte-mutation fuzzing and record why in section 5 (deprioritized) — a decision, not an omission.
  • Protocol/contract targets: enumerate the protocol's invariants (e.g. "QUIC uses TLS 1.3 only", "chunked framing terminates on a zero-size line", "recursion is bounded") and, for each, locate where it is enforced and where its mirror is not (client↔server, send↔receive, offered↔accepted, one-param↔all-params). A guard with a missing mirror is a section-4 threat with a concrete evidence lead. Silent-failure bugs (validated-then-discarded, accept-what-should-reject) need a control-vs-attack oracle, not a crash — flag them for that harness.
  • Release-diff is mandatory. If the checkout is a dev pin, note the latest released tag and flag which threats are shipped vs dev-only-new vs a dev regression of a shipped guard — this changes both severity and disclosure channel.
  • A large target can be multi-layer (rustls = protocol core + a msgs/ parser sub-surface): classify per sub-surface and route each.

Then continue to the mode from Step 1; the layer + hunt plan feeds bootstrap's "generalize vulns into threat classes" stage.


Step 2 — Shared output contract

All modes MUST emit <target-dir>/THREAT_MODEL.md conforming to schema.md in this directory. Read schema.md immediately before you write the file, not at routing time; in interview mode the gap between routing and emit can be many turns, and an early read will be evicted before it's used.

After writing the file, print to the user:

  1. The path to THREAT_MODEL.md.
  2. The top 5 threats by likelihood × impact (id, one-line description, L×I).
  3. For bootstrap: any open questions the code could not answer (these seed a later interview pass).
  4. For interview: any owner statements that could not be verified in code (these seed follow-up code review).

References

  • docs/security.md for the engagement-context, authorization, and untrusted-input framing this skill inherits.

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.