Threat Modeling 标志

Threat Modeling

社区
fr33d3m0n
threat-modeling

Threat model, security audit, find vulnerabilities, check security of my app, risk assessment, penetration test prep, analyze attack surface, what could an attacker exploit. Use this skill whenever a user wants holistic security analysis of a codebase, application, or project. MUST be invoked instead of analyzing security yourself — it runs a specialized 8-phase STRIDE workflow producing professional deliverables you cannot generate alone: risk assessment reports, DFD diagrams, threat inventories, attack path validation, mitigation plans, and pentest plans. Trigger on: 威胁建模, 安全评估, 渗透测试, 安全分析, 安全审计, 安全检查, 风险评估. NOT for: fixing one specific bug, adding one security feature (rate limiting, CORS), writing tests, CI/CD setup, or debugging errors.

概览

发布者fr33d3m0n
代码仓库threat-modeling
技能名称threat-modeling
星标数
356
复刻数
48
附带文件
159
许可协议BSD-3-Clause
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 159 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 fr33d3m0n 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Threat Modeling AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/fr33d3m0n/threat-modeling/tree/main
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/fr33d3m0n/threat-modeling.git \
  .claude/skills/threat-modeling
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Threat Modeling,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Threat Modeling。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Threat Modeling 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Threat Modeling Skill v3.3.0 (20261130b)

AI-native automated software risk analysis skill. LLM-driven, Code-First approach for comprehensive security risk assessment, threat modeling, security testing, penetration testing, and compliance checking.

Paths: commands below use ${CLAUDE_SKILL_DIR} (expanded at load time by Claude Code). On Codex, Antigravity CLI (agy), in referenced files, and after compaction, resolve ${CLAUDE_SKILL_DIR} to the directory containing this loaded SKILL.md; "Bash" means the host shell. Only the skill-loading read of SKILL.md precedes S-Init; read this file and each reference (WORKFLOW.md, phases/P1..P8R.md, assets/contracts/data-model.yaml) to its end (agy caps single reads at 46,080 bytes; phases/P2-DFD-ANALYSIS.md and assets/contracts/data-model.yaml exceed that limit).

After a compaction: Read Risk_Assessment_Report/.phase_working/{SESSION_ID}/task_queue.yaml, _session.yaml, and Risk_Assessment_Report/.phase_working/_session_meta.yaml first, re-read this SKILL.md in full so paths, gates, and mirror rules stay in context, reconcile the host task list if mirrored, and resume from the saved TESM + workflow phase (S1..S4, P1..P8).

Version Banner

━━━ 🛡️ Threat Modeling Skill v3.3.0 (20261130b) ━━━

Command Line Flags

FlagDescriptionDefault
--debugPublish internal YAML data files, KB queries, coverage validation, and evaluation reportOFF
--lang=xxSet output language (en, zh, ja, ko, es, fr, de, pt, ru)Auto-detect
--detailedAuto-trigger P8R (detailed per-VR analysis reports) after P8 completesOFF

Usage: /threat-model @my-project [--debug] [--lang=zh] [--detailed]


S-Init

  • S-Init a (Session + Queue): Run python3 "${CLAUDE_SKILL_DIR}/scripts/phase_data.py" --init --project <PROJECT> --path . [--detailed] --root . (creates Risk_Assessment_Report/.phase_working/{SESSION_ID}/ and auto-seeds task_queue.yaml with T-01..T-08, or T-01..T-09 with --detailed).
  • S-Init b (Verify State): Run python3 "${CLAUDE_SKILL_DIR}/scripts/task_state.py" --state "Risk_Assessment_Report/.phase_working/{SESSION_ID}/task_queue.yaml" --summary to confirm active queue and DAG dependencies.
  • S-Init c (Conditional Host Mirror): Follow Task Surface Sync below only if your current tool definitions include a complete host task-list interface.

Task Surface Sync (TESM ↔ Host Task UI)

task_state.py YAML is the single source of truth; a host task list is a view of it, kept only where the host offers one (WORKFLOW.md "Host task list"; read it before mirroring).

  • Capability: mirror only when the tool definitions in your current context include a task-list interface with every tool its procedure needs (TaskCreate + TaskUpdate + TaskList; or TodoWrite; or Codex's update_plan; or agy's update_steps; manage_task and TaskStop are not task lists). A tool the host lists by name as deferred, with its schema not yet loaded, counts as offered: load its schema with the host's tool-search call (Claude Code: ToolSearch with select:TaskCreate,TaskUpdate,TaskList) before its first call, and never call it unloaded. Loading a schema is not a probe. Never call an absent tool to find out. A call answered "no such tool", "disabled" or a permission refusal ends the mirror: do not retry it for later tasks or through a subagent. After a resume or a compaction, look at the tool definitions again.
  • Ownership: a TaskCreate carries the subject T-NN [<session-id>] <description>, TESM: <abs task_queue.yaml> on line 1 of description and an activeForm (e.g. S3 executing: Analyzing P2 data flows); change or delete only an entry you can show is this session's (subject and TESM path); leave any other alone.
  • When: once a transition is saved (exit 0, or phase_state saved), mirror it (start → in_progress, complete → completed or update_steps's done; also after S-Init c, --set-phase, pause, block, unblock and skip). Update-before-dispatch: when mirroring, mark the ACTIVE task in_progress before long-running work (a subagent, a Skill, Bash > 5s). Reconcile (with the Task tools: a lone TaskList call first, then create what is missing but never a SKIPPED task, and correct each status) after S-Init c, after a resume or compaction, and before the final report.
  • No usable tool: TESM alone is the record; at the final summary say once, with the reason, that the host task list was not kept in step (if it stopped midway: earlier entries may be stale).
  • Single writer: only the Lead runs task_state.py / phase_data.py and the mirror; parallel sub-agents (e.g. P2 traversal workers, P4 reviewers) return results to the Lead, which records them. Each command that writes locks its state file, so concurrent writes are serialized instead of lost; read-only queries (--summary, --next, --query, --verify) take no write lock. The order of transitions is still the Lead's to decide.

⚠️ CRITICAL: Data vs Report Separation

PRINCIPLE: Markdown is for reports (human-readable), YAML is for data (machine-readable). Writing reports AFTER YAML is MANDATORY!

Output LayerFormat & OrderPurposePath
1. DATA (PRIMARY).yaml written FIRSTStructured machine-readable phase input (FORBIDDEN: scraping .md prose/tables as YAML; fenced ```yaml:{block} extraction via --phase-end supported)Risk_Assessment_Report/.phase_working/{SESSION_ID}/data/P{N}_*.yaml
2. REPORT (SECONDARY).md written AFTER .yamlHuman-readable review & deliverables (illustrative YAML or fenced ```yaml:{block} blocks only)Risk_Assessment_Report/.phase_working/{SESSION_ID}/reports/P{N}-*.md

§1 Execution Model

Mode: Full Assessment Only — P1→P8 executed sequentially, synchronized with TESM step FSM (S1-THINKING → S2-PLANNING → S3-EXECUTING → S4-REFLECTING) per phase.

Phase Gate Protocol:

text
FOR N in [1..8] (and P8R if --detailed):
  1. Task start: task_state.py --start --id T-0N --state .../task_queue.yaml (+ --set-phase S1-THINKING -> S2-PLANNING -> S3-EXECUTING)
  2. Read: ${CLAUDE_SKILL_DIR}/phases/P{N}-*.md (read to end!) + previous YAML data/P{N-1}_*.yaml
  3. Write PRIMARY:  Risk_Assessment_Report/.phase_working/{SESSION_ID}/data/P{N}_*.yaml
  4. Write SECONDARY: Risk_Assessment_Report/.phase_working/{SESSION_ID}/reports/P{N}-*.md
  5. Gate: python3 ${CLAUDE_SKILL_DIR}/scripts/phase_data.py --phase-end --phase N --session-id {SESSION_ID} --root .
  6. IF exit != 0: keep phase cursor fixed, resolve blocking issues, re-run --phase-end (use task_state.py --reopen --phase N when replaying changed DONE phases; phase_data.py --p8r-open for late P8R)
  7. IF exit == 0: task_state.py --set-phase S4-REFLECTING -> --complete --id T-0N (mirror if enabled), advance to N+1

§2 Output Convention

Output Modes

ModePublished DeliverablesInternal Data (Risk_Assessment_Report/.phase_working/)
Default4 required reports (RISK-ASSESSMENT, RISK-INVENTORY, MITIGATION-MEASURES, PENETRATION-TEST-PLAN) + 7 phase reports (P1..P7-*.md)Kept internal (_session.yaml, task_queue.yaml, data/*.yaml, reports/*.md)
--debugAll 8 reports (+ ARCHITECTURE-ANALYSIS, DFD-DIAGRAM, COMPLIANCE-REPORT, ATTACK-PATH-VALIDATION) + 7 phase reports + EVALUATION-REPORT.mdPublished with data/*.yaml, P5_knowledge_base_queries.yaml, P8_coverage_validation.yaml

Directory Structure

text
{PROJECT_ROOT}/Risk_Assessment_Report/
├── {PROJECT}-RISK-ASSESSMENT-REPORT.md       ← Required (P8); DEBUG adds ARCHITECTURE-ANALYSIS, DFD-DIAGRAM,
├── {PROJECT}-RISK-INVENTORY.md               ← Required (P6)     COMPLIANCE-REPORT, ATTACK-PATH-VALIDATION
├── {PROJECT}-MITIGATION-MEASURES.md          ← Required (P7)
├── {PROJECT}-PENETRATION-TEST-PLAN.md        ← Required (P6)
├── P1-PROJECT-UNDERSTANDING.md .. P7-MITIGATION-PLAN.md  ← Published phase reports
├── [--detailed] detailed/VR-001-{slug}.md    ← Per-VR detailed reports (P8R)
├── [--debug] EVALUATION-REPORT.md            ← Internal evaluation summary
├── html/{index.html, *.html, detailed/}      ← HTML batch output (report_generator.py)
└── .phase_working/                           ← Internal state (published only with --debug)
    ├── _session_meta.yaml                    ← Global active/completed session index
    └── {SESSION_ID}/
        ├── {_session.yaml, task_queue.yaml}
        ├── data/P{1..8,P8R}_*.yaml           ← PRIMARY machine-readable phase artifacts (+ P5/P8 aux YAMLs)
        └── reports/P{1..8}-*.md              ← Working phase reports before final publish

Naming Convention

  • PROJECT: Uppercase, max 30 chars, format: ^[A-Z][A-Z0-9-]{0,29}$
  • Example: OPEN-WEBUI, MY-PROJECT, STRIDE-DEMO

Session ID Format

  • SESSION_ID: {PROJECT_NAME}_{YYYYMMDD_HHMMSS}
  • Example: OPEN-WEBUI_20260130_143022

Session Metadata

yaml
# File: Risk_Assessment_Report/.phase_working/{SESSION_ID}/_session.yaml
# Global index: Risk_Assessment_Report/.phase_working/_session_meta.yaml
schema_version: "3.3.0"
session_id: "OPEN-WEBUI_20260130_143022"
project_name: "OPEN-WEBUI"
project_path: "/path/to/project"
skill_version: "3.3.0 (20261130b)"
current_phase: 1
phases_completed: []

§3 Core Data Model

See @assets/contracts/data-model.yaml for complete schema definitions.

Entity Types

EntityID FormatPhaseDescription
ModuleM-{Seq:03d}P1Code modules/components
FindingF-P{N}-{Seq:03d}P1-P3Security observations (factual)
GapGAP-{Seq:03d}P4Security control deficiencies
ThreatT-{STRIDE}-{Element}-{Seq}P5STRIDE threats
ValidatedRiskVR-{Seq:03d}P6Verified risks
MitigationMIT-{Seq:03d}P7Remediation measures
POCPOC-{Seq:03d}P6Proof of concept
AttackPathAP-{Seq:03d}P6Attack vectors (single path)
AttackChainAC-{Seq:03d}P6Multi-step attack sequences
TestCaseTC-{Seq:03d}P8Penetration test cases
DetailedRiskRpt(uses VR-{Seq:03d})P8RPer-VR analysis report

Finding vs Gap Semantic Boundary

  • Finding (F-P{N}-xxx): A factual observation from phases 1-3 that MAY have security implications. Findings are objective facts about architecture, data flows, or boundaries. Example: "API endpoint uses HTTP instead of HTTPS"

  • Gap (GAP-xxx): A security control deficiency identified in P4 after analyzing findings against security domains. Gaps represent missing or inadequate controls. Example: "Missing TLS enforcement (NETWORK domain)"

Transition Rule: Findings from P1-P3 feed into P4 analysis. P4 evaluates findings against 16 security domains and produces Gaps where controls are deficient.

DFD Element IDs

Element TypePrefixFormatExample
External InteractorEIEI-{NNN}EI-001
ProcessPP-{NNN}P-001
Data StoreDSDS-{NNN}DS-001
Data FlowDFDF-{NNN}DF-001
Trust BoundaryTBTB-{NNN}TB-001

Count Conservation (P5→P6 Threat Accounting)

P5.threat_count = P6.verified + P6.theoretical + P6.pending + P6.excluded

All threats from P5 must be accounted for in P6 (no threat loss).

Semantic Distinction:

  • Count Conservation: P5→P6 threat accounting (threats flow from P5 to P6 dispositions)
  • Element Coverage Verification: P2→P5 element coverage (every DFD element has STRIDE analysis)

§4 Security Knowledge Architecture

See @knowledge/ for complete reference materials (~11 MB, 113 files).

  1. Security Control Set (What to do): 16 Security Domains (AUTHN, AUTHZ, INPUT, ...), Control Sets (18 files, 107 controls), OWASP (74 items), Compliance (14 frameworks).
  2. Threat Pattern Set (What to know): CWE (974), CAPEC (615), ATT&CK (835), CVE/KEV (323K+).
  3. Verification Set (How to test): WSTG (109), MASTG (92), ASVS (345).
  • 11 Security Principles: DID (Defense in Depth), LP (Least Privilege), ZT (Zero Trust), FS (Fail Secure), SOD (Separation of Duties), SBD (Secure by Default), CM (Complete Mediation), EOM (Economy of Mechanism), OD (Open Design), IV (Input Validation), LA (Least Agency — limit AI agent autonomy).

STRIDE Categories

STRIDENameCWEsCAPEC
SSpoofingCWE-287, 290, 307CAPEC-151, 194, 600
TTamperingCWE-20, 77, 78, 89CAPEC-66, 88, 248
RRepudiationCWE-117, 223, 778CAPEC-93
IInformation DisclosureCWE-200, 209, 311CAPEC-116, 157
DDenial of ServiceCWE-400, 770, 918CAPEC-125, 227
EElevation of PrivilegeCWE-269, 284, 862CAPEC-122, 233

§5 Knowledge Base Queries

bash
KB="${CLAUDE_SKILL_DIR}/kb"  # unified_kb_query.py accepts --kb-path PATH to override DB location
"$KB" --stride spoofing && "$KB" --stride-controls S && "$KB" --cwe CWE-89
"$KB" --full-chain CWE-89 && "$KB" --capec CAPEC-89 && "$KB" --attack-technique T1078
"$KB" --stride-tests S && "$KB" --wstg-category ATHN
"$KB" --all-llm && "$KB" --ai-component llm_inference_service

§6 Language Adaptation

Output language follows context language unless --lang=xx specified.

ContextFile NamesContent
ChineseP1-项目理解.md中文
EnglishP1-PROJECT-UNDERSTANDING.mdEnglish

Supported: en, zh, ja, ko, es, fr, de, pt, ru


§7 Progressive Context Loading

  1. Always Loaded: SKILL.md + WORKFLOW.md (orchestration & Host task list) at session start (S-Init a/b/c).
  2. Per Phase: Load ${CLAUDE_SKILL_DIR}/phases/P{N}-*.md on entry; write data/P{N}_*.yaml then reports/P{N}-*.md; gate via --phase-end.
  3. Post-P8 (Optional): With --detailed or confirmation, load ${CLAUDE_SKILL_DIR}/phases/P8R-DETAILED-REPORT.md.

§8 Reference Files

PathPurpose
@WORKFLOW.mdOrchestration contracts, phase gates, Host task list
@phases/P{1-8}-*.mdPhase-specific instructions
@assets/contracts/data-model.yamlEntity schemas
@knowledge/security-design.yaml16 security domains
@knowledge/security-principles.yaml11 security principles
@knowledge/sast-rules.yamlSAST tool configs and STRIDE mappings
@scripts/task_state.pyTESM step FSM (S1..S4) & locked task_queue.yaml manager
@scripts/module_discovery.pyP1 three-layer module discovery
@scripts/phase_data.pyPhase validation, session management, coverage checks
@scripts/unified_kb_query.pyKnowledge base queries
@scripts/report_generator.pyMD→HTML batch converter
@phases/P8R-DETAILED-REPORT.mdOptional per-VR detailed reports
@docs/TASK-SURFACE-MIRROR-AND-ARCH-DESIGN.mdv3.3.0 architecture & tri-host task mirror design
@skill_path.shPOSIX skill directory resolution helper

§9 Quick Start

Invoke /threat-model @my-project (--detailed for P8R per-VR reports, --debug for YAML + coverage artifacts, --lang=zh for Chinese). Run S-Init a/b/c, load WORKFLOW.md, then execute P1..P8 sequentially into Risk_Assessment_Report/.


§10 Core Execution Constraints (Invariants)

PRINCIPLE: The quality of threat modeling depends on execution rigor. The following constraints are INVIOLABLE.

Three Absolute Prohibitions

ConstraintDescriptionViolation Consequence
❌ NO MOCK DATAAll analysis must be based on real code evidenceAnalysis results invalid
❌ NO SIMPLIFIED IMPLEMENTATIONSEach phase must be fully executedCoverage requirements not met
❌ NO BYPASSING PROBLEMSMust diagnose root cause when blockedData chain broken

Phase Execution Invariant

∀ Phase N ∈ [1..8]:
  - Input: P{N-1}_*.yaml (except P1)
  - Output: P{N}_*.yaml (PRIMARY) + P{N}-*.md (SECONDARY)
  - Gate: phase_data.py --phase-end must return exit 0
  - Transition: Only proceed to N+1 after gate passes

Execution Protocol Details: See WORKFLOW.md §2 Phase Execution Protocol


§11 Phase Isolation Constraints

INVARIANT: Each Phase is an independent execution unit. FSM state transitions MUST follow strict sequential order.

Forbidden State Transitions

Illegal TransitionReason
Pn → Pn+2 (skip)Violates FSM order invariant (S1)
Pn → Pn+1 (unvalidated)Violates data contract completeness (S2)
Parallel Phase executionData dependencies cannot be satisfied

Complete FSM Specification: See WORKFLOW.md §1 Formal Properties: See docs/SKILL-ARCHITECTURE-DESIGN.md §0.2


End of SKILL.md (~540 lines, ~5.5K tokens)

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

还有 99 个文件。

常见问题

Threat Modeling AI 技能有什么作用?

Threat model, security audit, find vulnerabilities, check security of my app, risk assessment, penetration test prep, analyze attack surface, what could an attacker exploit. Use this skill whenever a user wants holistic security analysis of a codebase, application, or project. MUST be invoked instead of analyzing security yourself — it runs a specialized 8-phase STRIDE workflow producing professional deliverables you cannot generate alone: risk assessment reports, DFD diagrams, threat inventories, attack path validation, mitigation plans, and pentest plans. Trigger on: 威胁建模, 安全评估, 渗透测试, 安全分...

为什么在 TypingMind 中使用 Threat Modeling?

因为您只需安装一次,就能搭配任何模型使用。Threat Modeling 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Threat Modeling?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/fr33d3m0n/threat-modeling/tree/main。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Threat Modeling?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Threat Modeling 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Threat Modeling 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Threat Modeling AI 技能免费吗?

是的。fr33d3m0n 已在 GitHub 上根据 BSD-3-Clause 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇