threat-model

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

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 RCE via untrusted media parsing") still stands after every known bug is fixed; a vulnerability ("
dr_wav.h:412
doesn't bounds-check
chunk_size
") 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]

威胁模型旨在回答**「这个系统可能出现什么问题?谁会发起攻击?我们该如何应对?」**,无论是否已发现具体漏洞,都能给出答案。它就像一张地图,而漏洞发现则是金属探测器。优质的威胁模型能指导流程排查方向,并帮助优先级划分判断哪些发现更为关键。
验证测试:如果修补一行代码就能消除某个条目,那它是漏洞而非威胁。威胁(如「攻击者通过不可信媒体解析实现RCE」)在所有已知漏洞修复后依然存在;而漏洞(如「
dr_wav.h:412
未对
chunk_size
进行边界检查」)则会随着修复消失。本工具生成的是威胁内容,漏洞仅作为提升威胁可能性评分的证据出现。
调用方式
/threat-model [bootstrap-then-interview|bootstrap|interview] <target-dir> [flags]

Step 0 — Safety preamble (always runs first)

步骤0 — 安全前置说明(始终优先执行)

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.

本工具仅执行静态分析。它会读取源代码、git历史记录以及用户提供的任何漏洞报告,并生成单个输出文件(
<target-dir>/THREAT_MODEL.md
)。它不会构建、执行、模糊测试或修改目标代码,也不会针对目标基础设施发起网络请求。
在开始前,请在首次回复中确认并声明:
  1. 目标目录存在且为可读取的本地检出版本。
  2. 不会执行目标目录中的任何代码。
  3. 如果
    --vulns
    指向URL或被要求「获取CVE」,仅会查询公开咨询数据库(NVD、GitHub安全咨询、项目自身的问题追踪器),绝不会访问目标的实时部署环境。
如果用户要求通过运行漏洞利用程序验证威胁,请拒绝并引导他们使用
vuln-pipeline
(README步骤2)。

Step 1 — Route to a mode

步骤1 — 路由至对应模式

Parse
$ARGUMENTS
:
First tokenRoute to
interview
Read
interview.md
in this directory and follow it.
bootstrap
Read
bootstrap.md
in this directory and follow it.
bootstrap-then-interview
Bootstrap 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.
interview
bootstrap
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 tag
interview
bootstrap
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
解析
$ARGUMENTS
第一个参数路由至
interview
读取本目录下的
interview.md
并遵循其流程。
bootstrap
读取本目录下的
bootstrap.md
并遵循其流程。
bootstrap-then-interview
先执行引导模式,再基于草稿启动访谈模式。详情见下文。
其他内容或为空询问用户:「是否有该系统的所有者或构建者可在本次会话中回答问题?」 是且代码库已检出 → 推荐
bootstrap-then-interview
模式;是但无代码库 → 使用
interview.md
;否 → 使用
bootstrap.md
所有模式都会生成相同的产物(
THREAT_MODEL.md
,架构定义在
schema.md
中),因此下游消费者(流程中的
recon
/
judge
、验证Agent)无需关心产物由哪种模式生成。
interview
模式
bootstrap
模式
所需条件会话中有应用所有者在场本地代码检出版本;可选提供过往漏洞信息
方法四问题框架:通过对话梳理「我们正在开发什么 → 可能出现什么问题 → 我们将如何应对 → 我们做得好不好」五个阶段:并行研究集群 → 整合第1-3部分及漏洞表格 → 将漏洞归纳为威胁类别 → STRIDE框架补全 → 生成输出
最佳适用场景新系统、设计评审、风险存在于代码未体现的业务逻辑中的系统继承系统、第三方代码、OSS依赖、有CVE历史记录的任何系统
来源标签
interview
bootstrap
上下文持久性:访谈模式为多轮对话;早期读取的工具结果可能在需要前被清除。为保持稳定性:
  • 不要预先完整读取
    interview.md
    bootstrap.md
    。仅在需要时读取模式文件(或其中相关章节),一次一个问题或阶段。
  • 如果通过Read工具重新读取时被提示「文件未更改」,说明之前的结果已被清除;请改用Bash的
    cat <path>
    命令重新加载。
访谈核心框架(即使会话中途无法访问
interview.md
,也可依此推进):
问题编号问题内容填充架构章节
Q1我们正在开发什么?第1部分上下文、第2部分资产、第3部分入口点
Q2可能出现什么问题?第4部分威胁行(ID、威胁内容、攻击者、攻击面、资产)
Q3我们将如何应对?第4部分影响/可能性/状态/控制措施;第5部分低优先级内容;第8部分推荐缓解措施
Q4我们做得好不好?验证优先级排序、覆盖范围检查、第6部分未解决问题

bootstrap-then-interview
mode

bootstrap-then-interview
模式

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.

当所有者可用代码库已检出时,推荐使用此路径:所有者的时间将用于优化基于代码生成的草稿,而非从头描述系统。
  1. 告知所有者:「我将先读取代码,然后返回一份草稿(约5-10分钟),之后我们一起梳理。您是否同意?还是想直接开始访谈?」仅在对方同意后继续;否则 fallback 至
    interview.md
    流程。
  2. 读取
    bootstrap.md
    并完成全流程。生成
    <target-dir>/THREAT_MODEL.md
    文件。
  3. 立即进入访谈模式:读取
    interview.md
    并启用
    --seed <target-dir>/THREAT_MODEL.md
    参数。引导模式中第6部分的未解决问题将作为Q1-Q4的提示;所有者只需确认、修正和补充内容,无需从零开始。
  4. 用优化后的模型覆盖
    <target-dir>/THREAT_MODEL.md
    文件。设置来源标签
    mode: bootstrap-then-interview
也可手动执行相同流程:先运行
bootstrap
模式,之后在后续会话中运行
interview --seed <THREAT_MODEL.md>

Step 2 — Shared output contract

步骤2 — 统一输出约定

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).

所有模式必须生成符合本目录下
schema.md
规范的
<target-dir>/THREAT_MODEL.md
文件。请在写入文件前立即读取
schema.md
,而非在路由阶段读取;访谈模式中路由到生成文件的间隔可能有多个对话轮次,提前读取的内容可能在需要时已被清除。
写入文件后,向用户输出以下内容:
  1. THREAT_MODEL.md
    的路径。
  2. 按可能性×影响排名前5的威胁(ID、单行描述、可能性×影响得分)。
  3. 若为
    bootstrap
    模式:代码无法回答的所有未解决问题(这些将作为后续
    interview
    流程的种子)。
  4. 若为
    interview
    模式:所有无法通过代码验证的所有者陈述(这些将作为后续代码审查的种子)。

References

参考资料

  • docs/security.md and docs/prompting.md for the engagement-context and authorization framing this skill inherits.
  • docs/security.mddocs/prompting.md:本工具继承的参与上下文和授权框架。