Threat Modeling logo

Threat Modeling

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

Overview

Publisherfr33d3m0n
Repositorythreat-modeling
Skill namethreat-modeling
Stars
356
Forks
48
Bundled files
159
LicenseBSD-3-Clause
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 159 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by fr33d3m0n on GitHub. Read the source before you install it.

Installation

Install the Threat Modeling AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/fr33d3m0n/threat-modeling/tree/main
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/fr33d3m0n/threat-modeling.git \
  .claude/skills/threat-modeling
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Threat Modeling in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Threat Modeling on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Threat Modeling is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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)

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

and 99 more files.

Frequently asked questions

What does the Threat Modeling AI skill do?

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: 威胁建模, 安全评估, 渗透测试, 安全分...

Why use Threat Modeling on TypingMind?

Because you install it once and use it with any model. Threat Modeling is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Threat Modeling in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/fr33d3m0n/threat-modeling/tree/main. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Threat Modeling?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Threat Modeling?

As many as you like. As long as a model supports skills, you can use Threat Modeling with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Threat Modeling AI skill free?

Yes. It is published on GitHub by fr33d3m0n under the BSD-3-Clause license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇