Skip to content
Back to search

threat-modeling

SkillWorks with Claude CodeGitHub

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.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today

Check it deeper on your machine

Its scripts were only partly scanned.

As a Claude Code plugin, install it and then ask Claude Code:

/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/fr33d3m0n/threat-modeling with scanskillsafety

Or from a terminal, clone it and run it:

git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/fr33d3m0n/threat-modeling'

It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/fr33d3m0n--threat-modeling/badge.svg)](/listings/fr33d3m0n--threat-modeling)

HTML

<a href="/listings/fr33d3m0n--threat-modeling"><img src="/api/listings/fr33d3m0n--threat-modeling/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Option 1: Global Installation (Recommended)

# Clone to global skills directory
git clone https://github.com/fr33d3m0n/threat-modeling.git \
    ~/.claude/skills/threat-modeling

Option 2: Project-Local Installation

# Clone to project's .claude/skills directory
mkdir -p .claude/skills
git clone https://github.com/fr33d3m0n/threat-modeling.git \
    .claude/skills/threat-modeling

Requirements

- Claude Code CLI - Python 3.10+ - SQLite3 (for knowledge base queries)

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

SKILL.md · Manifest · 528 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. ---
  2. name: threat-modeling
  3. description: |
  4. Threat model, security audit, find vulnerabilities, check security of my app, risk
  5. assessment, penetration test prep, analyze attack surface, what could an attacker exploit.
  6. Use this skill whenever a user wants holistic security analysis of a codebase, application,
  7. or project. MUST be invoked instead of analyzing security yourself — it runs a specialized
  8. 8-phase STRIDE workflow producing professional deliverables you cannot generate alone: risk
  9. assessment reports, DFD diagrams, threat inventories, attack path validation, mitigation
  10. plans, and pentest plans.
  11. Trigger on: 威胁建模, 安全评估, 渗透测试, 安全分析, 安全审计, 安全检查, 风险评估.
  12. NOT for: fixing one specific bug, adding one security feature (rate limiting, CORS),
  13. writing tests, CI/CD setup, or debugging errors.
  14. ---
  15. <!-- Threat Modeling Skill | Version 3.2.0 (20260512a) | https://github.com/fr33d3m0n/threat-modeling | License: BSD-3-Clause -->
  16. > **Note**: All relative paths in this skill are relative to `SKILL_PATH` / `CLAUDE_SKILL_DIR` (the directory containing this SKILL.md file). Use `${SKILL_PATH:-$CLAUDE_SKILL_DIR}` in Bash commands for cross-runtime compatibility.
  17. # Threat Modeling Skill v3.2.0 (20260512a)
  18. 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.
  19. ## Version Banner
  20. ```
  21. ━━━ 🛡️ Threat Modeling Skill v3.2.0 (20260512a) ━━━
  22. ```
  23. ## Command Line Flags
  24. | Flag | Description | Default |
  25. |------|-------------|---------|
  26. | `--debug` | Publish internal YAML data files, KB queries, coverage validation, and evaluation report | OFF |
  27. | `--lang=xx` | Set output language (en, zh, ja, ko, es, fr, de, pt, ru) | Auto-detect |
  28. | `--detailed` | Auto-trigger P8R (detailed per-VR analysis reports) after P8 completes | OFF |
  29. **Usage Examples**:
  30. ```bash
  31. # Default mode - 11 deliverable files only
  32. /threat-model @my-project
  33. # Debug mode - all internal files published
  34. /threat-model @my-project --debug
  35. # Chinese output with debug
  36. /threat-model @my-project --lang=zh --debug
  37. # Generate detailed per-VR analysis reports after P8
  38. /threat-model @my-project --detailed
  39. # Full options
  40. /threat-model @my-project --detailed --debug --lang=zh
  41. ```
  42. ---
  43. ## ⚠️ CRITICAL: Data vs Report Separation
  44. > **PRINCIPLE**: Markdown is for reports (human-readable), YAML is for data (machine-readable). They MUST be separated!
  45. ```
  46. ┌─────────────────────────────────────────────────────────────────────┐
  47. │ DUAL OUTPUT MODEL - Each phase produces TWO files: │
  48. ├─────────────────────────────────────────────────────────────────────┤
  49. │ │
  50. │ 1. DATA FILE (.yaml) - PRIMARY │
  51. │ • Written FIRST │
  52. │ • Structured, machine-readable │
  53. │ • Used by NEXT phase as input │
  54. │ • Path: .phase_working/{SESSION_ID}/data/P{N}_*.yaml │
  55. │ │
  56. │ 2. REPORT FILE (.md) - SECONDARY │
  57. │ • Written AFTER data file │
  58. │ • Human-readable, formatted │
  59. │ • For review and documentation │
  60. │ • Path: .phase_working/{SESSION_ID}/reports/P{N}-*.md │
  61. │ │
  62. │ ❌ FORBIDDEN: Reading .md files for data extraction │
  63. │ ❌ FORBIDDEN: Embedding data as yaml blocks inside .md AS SOURCE │
  64. │ ✅ ALLOWED: YAML blocks in .md for schema documentation/examples │
  65. │ ✅ REQUIRED: Data flows via .yaml files only │
  66. │ │
  67. └─────────────────────────────────────────────────────────────────────┘
  68. ```
  69. ---
  70. ## §1 Execution Model
  71. **Mode**: Full Assessment Only - All 8 phases executed sequentially.
  72. ```
  73. Phase 1 ──► Phase 2 ──► Phase 3 ──► Phase 4 ──► Phase 5 ──► Phase 6 ──► Phase 7 ──► Phase 8
  74. │ │ │ │ │ │ │
  75. ▼ ▼ ▼ ▼ ▼ ▼ ▼
  76. P1.yaml ──► P2.yaml ──► P3.yaml ──► P4.yaml ──► P5.yaml ──► P6.yaml ──► P7.yaml ──► P8.yaml
  77. ```
  78. **Rules**:
  79. 1. Phases execute strictly in order (1→8)
  80. 2. Each phase reads previous phase's YAML, writes its own YAML
  81. 3. Each phase also writes a human-readable .md report
  82. 4. Validation runs on YAML files, not .md files
  83. 5. Phase 6 = Risk Validation (NOT mitigation)
  84. 6. Phase 7 = Mitigation Planning (AFTER validation)
  85. **Phase Gate Protocol**:
  86. ```
  87. FOR each phase N in [1..8]:
  88. 1. Read: @phases/P{N}-*.md (instructions)
  89. 2. Read: .phase_working/{SESSION_ID}/data/P{N-1}_*.yaml (input, except P1)
  90. 3. Execute analysis per phase instructions
  91. 4. Write: .phase_working/{SESSION_ID}/data/P{N}_*.yaml (PRIMARY output)
  92. 5. Write: .phase_working/{SESSION_ID}/reports/P{N}-*.md (SECONDARY output)
  93. 6. Validate: python ${SKILL_PATH:-$CLAUDE_SKILL_DIR}/scripts/phase_data.py --phase-end --phase N --root .
  94. 7. IF exit != 0: Fix YAML and rewrite, re-run --phase-end
  95. 8. IF exit == 0: Update session meta, continue to N+1
  96. ```
  97. ---
  98. ## §2 Output Convention
  99. ### Output Modes
  100. ```
  101. ┌─────────────────────────────────────────────────────────────────────┐
  102. │ OUTPUT MODES - Control what files are generated │
  103. ├─────────────────────────────────────────────────────────────────────┤
  104. │ │
  105. │ DEFAULT MODE (Production) │
  106. │ ───────────────────────────────────────────────────────────────── │
  107. │ Only user-deliverable files are published: │
  108. │ ✅ 4 Required Reports (RISK-ASSESSMENT, INVENTORY, MITIGATION, │
  109. │ PENETRATION-TEST-PLAN) │
  110. │ ✅ 7 Phase Reports (P1-P7-*.md) for audit trail │
  111. │ ❌ .phase_working/ - NOT published (kept internally) │
  112. │ ❌ YAML data files - NOT published │
  113. │ ❌ EVALUATION-REPORT.md - NOT published │
  114. │ │
  115. │ DEBUG MODE (--debug flag) │
  116. │ ───────────────────────────────────────────────────────────────── │
  117. │ All files are published including internal data: │
  118. │ ✅ All default mode outputs │
  119. │ ✅ .phase_working/{SESSION_ID}/data/*.yaml - Published │
  120. │ ✅ P5_knowledge_base_queries.yaml - Published │
  121. │ ✅ P8_coverage_validation.yaml - Published │
  122. │ ✅ EVALUATION-REPORT.md - Published │
  123. │ │
  124. │ Usage: /threat-model @project --debug │
  125. │ │
  126. └─────────────────────────────────────────────────────────────────────┘
  127. ```
  128. ### Directory Structure
  129. **Default Mode** (11 files published):
  130. ```
  131. {PROJECT_ROOT}/
  132. └── Risk_Assessment_Report/
  133. ├── {PROJECT}-RISK-ASSESSMENT-REPORT.md ← Required (P8)
  134. ├── {PROJECT}-RISK-INVENTORY.md ← Required (P6)
  135. ├── {PROJECT}-MITIGATION-MEASURES.md ← Required (P7)
  136. ├── {PROJECT}-PENETRATION-TEST-PLAN.md ← Required (P6)
  137. ├── P1-PROJECT-UNDERSTANDING.md ← Phase reports
  138. ├── P2-DFD-ANALYSIS.md
  139. ├── P3-TRUST-BOUNDARY.md
  140. ├── P4-SECURITY-DESIGN-REVIEW.md
  141. ├── P5-STRIDE-THREATS.md
  142. ├── P6-RISK-VALIDATION.md
  143. ├── P7-MITIGATION-PLAN.md
  144. ├── detailed/ ← P8R only (--detailed flag)
  145. │ ├── VR-001-{title-slug}.md
  146. │ └── ...
  147. └── html/ ← HTML output (report_generator.py)
  148. ├── index.html
  149. ├── {PROJECT}-RISK-ASSESSMENT-REPORT.html
  150. ├── ...
  151. └── detailed/
  152. └── VR-001-{slug}.html
  153. ```
  154. **Debug Mode** (--debug, full structure):
  155. ```
  156. {PROJECT_ROOT}/
  157. └── Risk_Assessment_Report/
  158. ├── {PROJECT}-RISK-ASSESSMENT-REPORT.md ← Main report (from P8)
  159. ├── {PROJECT}-RISK-INVENTORY.md ← From P6 YAML
  160. ├── {PROJECT}-MITIGATION-MEASURES.md ← From P7 YAML
  161. ├── {PROJECT}-PENETRATION-TEST-PLAN.md ← From P6 YAML
  162. ├── {PROJECT}-ARCHITECTURE-ANALYSIS.md ← From P1-P3 YAML
  163. ├── {PROJECT}-DFD-DIAGRAM.md ← From P2 YAML
  164. ├── {PROJECT}-COMPLIANCE-REPORT.md ← From P4+P7 YAML
  165. ├── {PROJECT}-ATTACK-PATH-VALIDATION.md ← From P6 YAML
  166. ├── P1-PROJECT-UNDERSTANDING.md ← Published phase reports
  167. ├── P2-DFD-ANALYSIS.md
  168. ├── P3-TRUST-BOUNDARY.md
  169. ├── P4-SECURITY-DESIGN-REVIEW.md
  170. ├── P5-STRIDE-THREATS.md
  171. ├── P6-RISK-VALIDATION.md
  172. ├── EVALUATION-REPORT.md ← DEBUG ONLY
  173. └── .phase_working/ ← DEBUG ONLY
  174. ├── _sessions_index.yaml ← Multi-session index (optional)
  175. └── {SESSION_ID}/ ← Session isolated directory
  176. ├── _session_meta.yaml ← Session state
  177. ├── data/ ← STRUCTURED DATA
  178. │ ├── P1_project_context.yaml
  179. │ ├── P2_dfd_elements.yaml
  180. │ ├── P3_boundary_context.yaml
  181. │ ├── P4_security_gaps.yaml
  182. │ ├── P5_threat_inventory.yaml
  183. │ ├── P5_knowledge_base_queries.yaml ← KB transparency
  184. │ ├── P6_validated_risks.yaml
  185. │ ├── P7_mitigation_plan.yaml
  186. │ ├── P8_report_manifest.yaml
  187. │ └── P8_coverage_validation.yaml ← Coverage metrics
  188. ├── reports/ ← WORKING REPORTS
  189. │ └── (phase reports during execution)
  190. └── data/P8R_manifest.yaml ← P8R manifest (--detailed only)
  191. ```
  192. ### Naming Convention
  193. - **PROJECT**: Uppercase, max 30 chars, format: `^[A-Z][A-Z0-9-]{0,29}$`
  194. - **Example**: `OPEN-WEBUI`, `MY-PROJECT`, `STRIDE-DEMO`
  195. ### Session ID Format
  196. - **SESSION_ID**: `{PROJECT_NAME}_{YYYYMMDD_HHMMSS}`
  197. - **Example**: `OPEN-WEBUI_20260130_143022`
  198. ### Session Metadata
  199. ```yaml
  200. # .phase_working/{SESSION_ID}/_session_meta.yaml
  201. schema_version: "3.2.0 (20260512a)"
  202. session_id: "OPEN-WEBUI_20260130_143022" # {PROJECT}_{YYYYMMDD_HHMMSS}
  203. project_name: "OPEN-WEBUI"
  204. project_path: "/path/to/project"
  205. started_at: "ISO8601 timestamp"
  206. language: "en"
  207. skill_version: "3.2.0 (20260512a)"
  208. phases:
  209. P1:
  210. status: "completed"
  211. started_at: "2026-01-30T10:00:00Z"
  212. completed_at: "2026-01-30T10:30:00Z"
  213. data_file: "data/P1_project_context.yaml"
  214. report_file: "reports/P1-PROJECT-UNDERSTANDING.md"
  215. P2:
  216. status: "in_progress"
  217. # ...
  218. ```
  219. ---
  220. ## §3 Core Data Model
  221. > See @assets/contracts/data-model.yaml for complete schema definitions.
  222. ### Entity Types
  223. | Entity | ID Format | Phase | Description |
  224. |--------|-----------|-------|-------------|
  225. | Module | M-{Seq:03d} | P1 | Code modules/components |
  226. | Finding | F-P{N}-{Seq:03d} | P1-P3 | Security observations (factual) |
  227. | Gap | GAP-{Seq:03d} | P4 | Security control deficiencies |
  228. | Threat | T-{STRIDE}-{Element}-{Seq} | P5 | STRIDE threats |
  229. | ValidatedRisk | VR-{Seq:03d} | P6 | Verified risks |
  230. | Mitigation | MIT-{Seq:03d} | P7 | Remediation measures |
  231. | POC | POC-{Seq:03d} | P6 | Proof of concept |
  232. | AttackPath | AP-{Seq:03d} | P6 | Attack vectors (single path) |
  233. | AttackChain | AC-{Seq:03d} | P6 | Multi-step attack sequences |
  234. | TestCase | TC-{Seq:03d} | P8 | Penetration test cases |
  235. | DetailedRiskRpt | (uses VR-{Seq:03d}) | P8R | Per-VR analysis report |
  236. ### Finding vs Gap Semantic Boundary
  237. - **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"
  238. - **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)"
  239. **Transition Rule**: Findings from P1-P3 feed into P4 analysis. P4 evaluates findings against 16 security domains and produces Gaps where controls are deficient.
  240. ### DFD Element IDs
  241. | Element Type | Prefix | Format | Example |
  242. |--------------|--------|--------|---------|
  243. | External Interactor | EI | EI-{NNN} | EI-001 |
  244. | Process | P | P-{NNN} | P-001 |
  245. | Data Store | DS | DS-{NNN} | DS-001 |
  246. | Data Flow | DF | DF-{NNN} | DF-001 |
  247. | Trust Boundary | TB | TB-{NNN} | TB-001 |
  248. ### Count Conservation (P5→P6 Threat Accounting)
  249. ```
  250. P5.threat_count = P6.verified + P6.theoretical + P6.pending + P6.excluded
  251. ```
  252. All threats from P5 must be accounted for in P6 (no threat loss).
  253. **Semantic Distinction**:
  254. - **Count Conservation**: P5→P6 threat accounting (threats flow from P5 to P6 dispositions)
  255. - **Element Coverage Verification**: P2→P5 element coverage (every DFD element has STRIDE analysis)
  256. ---
  257. ## §4 Security Knowledge Architecture
  258. > See @knowledge/ for complete reference materials (~11 MB, 113 files).
  259. ### Three Knowledge Sets
  260. 1. **Security Control Set** (What to do)
  261. - 16 Security Domains (AUTHN, AUTHZ, INPUT, etc.)
  262. - Control Sets (18 files, 107 controls)
  263. - OWASP References (74 items)
  264. - Compliance Frameworks (14 frameworks)
  265. 2. **Threat Pattern Set** (What to know)
  266. - CWE Weaknesses (974)
  267. - CAPEC Attack Patterns (615)
  268. - ATT&CK Techniques (835)
  269. - CVE/KEV Vulnerabilities (323K+)
  270. 3. **Verification Set** (How to test)
  271. - WSTG Tests (121)
  272. - MASTG Tests (206)
  273. - ASVS Requirements (345)
  274. ### Security Principles (11)
  275. | Code | Principle | Definition |
  276. |------|-----------|------------|
  277. | DID | Defense in Depth | Multiple independent security controls |
  278. | LP | Least Privilege | Minimum permissions required |
  279. | ZT | Zero Trust | Never trust, always verify |
  280. | FS | Fail Secure | Default to secure state on error |
  281. | SOD | Separation of Duties | Critical ops require multiple parties |
  282. | SBD | Secure by Default | Default config is secure |
  283. | CM | Complete Mediation | Every access verified |
  284. | EOM | Economy of Mechanism | Simple, auditable mechanisms |
  285. | OD | Open Design | Security not dependent on secrecy |
  286. | IV | Input Validation | All input validated |
  287. | LA | Least Agency | Limit AI agent autonomy |
  288. ### STRIDE Categories
  289. | STRIDE | Name | CWEs | CAPEC |
  290. |--------|------|------|-------|
  291. | S | Spoofing | CWE-287, 290, 307 | CAPEC-151, 194, 600 |
  292. | T | Tampering | CWE-20, 77, 78, 89 | CAPEC-66, 88, 248 |
  293. | R | Repudiation | CWE-117, 223, 778 | CAPEC-93 |
  294. | I | Information Disclosure | CWE-200, 209, 311 | CAPEC-116, 157 |
  295. | D | Denial of Service | CWE-400, 770, 918 | CAPEC-125, 227 |
  296. | E | Elevation of Privilege | CWE-269, 284, 862 | CAPEC-122, 233 |
  297. ---
  298. ## §5 Knowledge Base Queries
  299. ### kb Wrapper Usage
  300. ```bash
  301. # Resolve skill path (works in Claude Code, Codex CLI, and manual testing)
  302. SKILL_PATH=${SKILL_PATH:-${CLAUDE_SKILL_DIR:-$(bash skill_path.sh)}}
  303. # STRIDE queries
  304. ${SKILL_PATH:-$CLAUDE_SKILL_DIR}/kb --stride spoofing
  305. ${SKILL_PATH:-$CLAUDE_SKILL_DIR}/kb --stride-controls S
  306. # CWE queries
  307. ${SKILL_PATH:-$CLAUDE_SKILL_DIR}/kb --cwe CWE-89
  308. ${SKILL_PATH:-$CLAUDE_SKILL_DIR}/kb --full-chain CWE-89
  309. # Attack patterns
  310. ${SKILL_PATH:-$CLAUDE_SKILL_DIR}/kb --capec CAPEC-89
  311. ${SKILL_PATH:-$CLAUDE_SKILL_DIR}/kb --attack-technique T1078
  312. # Verification tests
  313. ${SKILL_PATH:-$CLAUDE_SKILL_DIR}/kb --stride-tests S
  314. ${SKILL_PATH:-$CLAUDE_SKILL_DIR}/kb --wstg-category ATHN
  315. # LLM/AI extensions
  316. ${SKILL_PATH:-$CLAUDE_SKILL_DIR}/kb --all-llm
  317. ${SKILL_PATH:-$CLAUDE_SKILL_DIR}/kb --ai-component
  318. ```
  319. ---
  320. ## §6 Language Adaptation
  321. Output language follows context language unless `--lang=xx` specified.
  322. | Context | File Names | Content |
  323. |---------|------------|---------|
  324. | Chinese | P1-项目理解.md | 中文 |
  325. | English | P1-PROJECT-UNDERSTANDING.md | English |
  326. Supported: en, zh, ja, ko, es, fr, de, pt, ru
  327. ---
  328. ## §7 Progressive Context Loading
  329. This skill uses progressive disclosure:
  330. 1. **Always Loaded**: This file (SKILL.md) - ~5.5K tokens
  331. 2. **Session Start**: @WORKFLOW.md - ~4.8K tokens
  332. 3. **Per Phase**: @phases/P{N}-*.md - ~4K-10K tokens each (varies by phase)
  333. Total per-phase context: ~12K-18K tokens per phase (vs 30K monolithic)
  334. **Loading Pattern**:
  335. ```
  336. Session Start:
  337. 1. Load SKILL.md (global rules)
  338. 2. Load WORKFLOW.md (orchestration)
  339. 3. Create 8 phase todos
  340. Per Phase:
  341. 1. Read @phases/P{N}-*.md
  342. 2. Execute phase instructions
  343. 3. Write to .phase_working/{SESSION_ID}/reports/P{N}-*.md
  344. 4. Run: python ${SKILL_PATH:-$CLAUDE_SKILL_DIR}/scripts/phase_data.py --phase-end --phase N --root .
  345. Post-P8 (Optional):
  346. 1. If --detailed flag OR user confirms: Load @phases/P8R-DETAILED-REPORT.md
  347. 2. Generate per-VR detailed analysis reports
  348. 3. Write to Risk_Assessment_Report/detailed/VR-{NNN}-{slug}.md
  349. ```
  350. ---
  351. ## §8 Reference Files
  352. | Path | Purpose |
  353. |------|---------|
  354. | @WORKFLOW.md | Orchestration contracts, phase gates |
  355. | @phases/P{1-8}-*.md | Phase-specific instructions |
  356. | @assets/contracts/data-model.yaml | Entity schemas |
  357. | @knowledge/security-design.yaml | 16 security domains |
  358. | @knowledge/security-principles.yaml | 11 security principles |
  359. | @knowledge/sast-rules.yaml | SAST tool configs and STRIDE mappings |
  360. | @scripts/module_discovery.py | P1 three-layer module discovery |
  361. | @scripts/phase_data.py | Phase validation and extraction |
  362. | @scripts/unified_kb_query.py | Knowledge base queries |
  363. | @scripts/report_generator.py | MD→HTML batch converter |
  364. | @phases/P8R-DETAILED-REPORT.md | Optional per-VR detailed reports |
  365. | @docs/REPORT-DESIGN.md | v3.0.3+ report enhancement design |
  366. | @skill_path.sh | SKILL_PATH resolution helper |
  367. ---
  368. ## §9 Quick Start
  369. ```bash
  370. # 1. Start new session (default mode - 11 deliverable files)
  371. /threat-model @my-project
  372. # 2. With debug mode (all internal files published)
  373. /threat-model @my-project --debug
  374. # 3. Session execution:
  375. # - Claude loads SKILL.md + WORKFLOW.md automatically
  376. # - For each phase N (1-8): Read → Execute → Write → Validate
  377. # - Generate final reports in Risk_Assessment_Report/
  378. ```
  379. ### Output Summary
  380. | Mode | Files Published | Use Case |
  381. |------|-----------------|----------|
  382. | Default | 11 (4 required + 7 phase reports) | Production delivery |
  383. | `--detailed` | 11 + per-VR detailed reports | Comprehensive assessment |
  384. | `--debug` | 11 + YAML data + evaluation | Development, audit |
  385. ---
  386. ## §10 Core Execution Constraints (Invariants)
  387. > **PRINCIPLE**: The quality of threat modeling depends on execution rigor. The following constraints are INVIOLABLE.
  388. ### Three Absolute Prohibitions
  389. | Constraint | Description | Violation Consequence |
  390. |------------|-------------|----------------------|
  391. | ❌ NO MOCK DATA | All analysis must be based on real code evidence | Analysis results invalid |
  392. | ❌ NO SIMPLIFIED IMPLEMENTATIONS | Each phase must be fully executed | Coverage requirements not met |
  393. | ❌ NO BYPASSING PROBLEMS | Must diagnose root cause when blocked | Data chain broken |
  394. ### Phase Execution Invariant
  395. ```
  396. ∀ Phase N ∈ [1..8]:
  397. - Input: P{N-1}_*.yaml (except P1)
  398. - Output: P{N}_*.yaml (PRIMARY) + P{N}-*.md (SECONDARY)
  399. - Gate: phase_data.py --phase-end must return exit 0
  400. - Transition: Only proceed to N+1 after gate passes
  401. ```
  402. > **Execution Protocol Details**: See WORKFLOW.md §2 Phase Execution Protocol
  403. ---
  404. ## §11 Phase Isolation Constraints
  405. > **INVARIANT**: Each Phase is an independent execution unit. FSM state transitions MUST follow strict sequential order.
  406. ### Forbidden State Transitions
  407. | Illegal Transition | Reason |
  408. |-------------------|--------|
  409. | Pn → Pn+2 (skip) | Violates FSM order invariant (S1) |
  410. | Pn → Pn+1 (unvalidated) | Violates data contract completeness (S2) |
  411. | Parallel Phase execution | Data dependencies cannot be satisfied |
  412. > **Complete FSM Specification**: See WORKFLOW.md §1
  413. > **Formal Properties**: See docs/SKILL-ARCHITECTURE-DESIGN.md §0.2
  414. ---
  415. **End of SKILL.md** (~540 lines, ~5.5K tokens)
README.md · README · 409 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. <!-- Threat Modeling Skill | Version 3.2.0 (20260512a) | https://github.com/fr33d3m0n/threat-modeling | License: BSD-3-Clause -->
  2. # Threat Modeling Skill v3.2.0
  3. AI-native automated software risk analysis skill. LLM-driven, Code-First approach for comprehensive security risk assessment, threat modeling, security analysis, security audit, and penetration testing.
  4. ## What's New in v3.2.0
  5. - **Tool-assisted analysis**: Integrated Luoshu (14 MCP), Ghidra (18 MCP), CodeQL (65 MCP), Joern (15 CWE queries) for deep code and binary analysis
  6. - **Complex system support**: DFD auto-generation, CFG/DFG analysis, N-hop call chain tracing, semantic code search
  7. - **Binary reverse engineering**: Ghidra decompilation, radare2 recon, call graphs and cross-references
  8. - **Automated vulnerability detection**: Joern CWE queries for C/C++, CodeQL security suites
  9. - **Attack chain verification**: Luoshu call chains + Ghidra decompilation + Joern taint analysis
  10. - **Explicit phase validation**: Replaced hook-based validation with portable `--phase-end` calls
  11. - **Tool capabilities matrix**: New `knowledge/tool-capabilities.yaml` for runtime tool discovery
  12. - 3 new reference documents in `references/` for on-demand tool guidance
  13. - agentskills.io multi-agent platform compatibility (Claude Code, Codex CLI, IDE extensions)
  14. See [CHANGELOG.md](CHANGELOG.md) for full version history.
  15. ## What's New in v3.0.2
  16. - Major system architecture refactoring, improved security analysis depth and path coverage
  17. - Backported SM2 state machine from next-gen AI-Native penetration testing system named "Cobweb" for problem-solving in depth
  18. - Added multi-version task history and precise structured phase outputs for CI/CD integration
  19. - Optimized context engineering and data disclosure, ~35% token reduction
  20. See [CHANGELOG.md](CHANGELOG.md) for full version history.
  21. ## Installation
  22. ### Option 1: Global Installation (Recommended)
  23. ```bash
  24. # Clone to global skills directory
  25. git clone https://github.com/fr33d3m0n/threat-modeling.git \
  26. ~/.claude/skills/threat-modeling
  27. ```
  28. ### Option 2: Project-Local Installation
  29. ```bash
  30. # Clone to project's .claude/skills directory
  31. mkdir -p .claude/skills
  32. git clone https://github.com/fr33d3m0n/threat-modeling.git \
  33. .claude/skills/threat-modeling
  34. ```
  35. ### Requirements
  36. - Claude Code CLI
  37. - Python 3.10+
  38. - SQLite3 (for knowledge base queries)
  39. ## Quick Start
  40. 1. **Start Claude Code** in your target project directory:
  41. ```bash
  42. cd /path/to/your/project
  43. claude
  44. ```
  45. 2. **Invoke the skill** with a simple prompt:
  46. ```
  47. /threat-modeling Perform a complete threat model analysis on @.
  48. ```
  49. 3. **Follow the 8-phase workflow** - Claude will guide you through each phase.
  50. ## Usage Modes
  51. The skill supports **6 flexible application modes** beyond the standard 8-phase workflow:
  52. ### Mode 1: Complete Workflow (Standard)
  53. Full 8-phase threat modeling for codebases.
  54. ```
  55. /threat-modeling Perform a complete threat model analysis on @/path/to/project
  56. Project context:
  57. - This is an e-commerce platform backend API service
  58. - Built with Django REST Framework
  59. - User data includes PII and payment information
  60. Focus areas: Authentication mechanisms, payment flow, API security
  61. ```
  62. ### Mode 2: Knowledge Base Consultation
  63. Use as security consulting resource without executing complete workflow.
  64. ```
  65. Query complete information for CWE-89 (SQL Injection),
  66. including attack patterns, testing methods, and mitigations
  67. ```
  68. **Response includes**: CWE overview, related CAPEC patterns, WSTG testing steps, ASVS requirements, mitigation examples.
  69. ### Mode 3: Deep Vulnerability Analysis
  70. In-depth analysis of specific vulnerabilities or code snippets.
  71. ```
  72. Analyze SSRF risk in this code, construct attack path and design POC
  73. [Code snippet]
  74. ```
  75. **Response includes**: Vulnerability mechanism, attack path, POC design, CWE/CAPEC/ATT&CK mapping.
  76. ### Mode 4: Security Test Generation
  77. Generate test cases based on security standards.
  78. ```
  79. Generate WSTG-based security test cases for this API endpoint
  80. ```
  81. **Response includes**: Authentication, authorization, input validation, session management test cases with payloads.
  82. ### Mode 5: Forward Integration (Design Phase)
  83. Pre-emptive threat modeling during design without waiting for code.
  84. ```
  85. Conduct STRIDE threat analysis based on this API specification
  86. [OpenAPI specification]
  87. ```
  88. **Response includes**: DFD from API endpoints, trust boundaries, STRIDE enumeration, design recommendations.
  89. ### Mode 6: Backward Integration (Penetration Testing)
  90. Attack path and POC design support for pentesting.
  91. ```
  92. I found JWT signature verification bypass in the target system,
  93. help construct complete attack chain
  94. ```
  95. **Response includes**: Vulnerability confirmation, attack chain, POC payload, ATT&CK mapping, report template.
  96. ## Mode Selection Guide
  97. | Mode | Input | Output | When to Use |
  98. |------|-------|--------|-------------|
  99. | **Complete Workflow** | Codebase | Full threat report | Development / Pre-release |
  100. | **KB Consultation** | Question | Knowledge response | Any stage |
  101. | **Vulnerability Analysis** | Code / Description | Attack path + POC | Code review / Pentest |
  102. | **Test Generation** | Target description | Test checklist | Testing phase |
  103. | **Forward Integration** | Design docs | Design-phase analysis | Design phase |
  104. | **Backward Integration** | Found vulnerability | Attack chain + Plan | Penetration testing |
  105. ## Command Line Flags
  106. | Flag | Description |
  107. |------|-------------|
  108. | `--debug` | Publish internal YAML data files and evaluation reports |
  109. | `--lang=xx` | Set output language (en, zh, ja, ko, es, fr, de, pt, ru) |
  110. **Examples**:
  111. ```bash
  112. /threat-model @my-project # Default mode
  113. /threat-model @my-project --debug # With internal data
  114. /threat-model @my-project --lang=zh --debug # Chinese output with debug
  115. ```
  116. ## Advanced Scenarios (Extended Prompts)
  117. Beyond the standard 8-phase workflow, use these extended prompts for deeper security analysis:
  118. ### Scenario 1: Complete Interface & Data Flow Discovery
  119. Comprehensive discovery and risk analysis of all system interfaces.
  120. ```
  121. /threat-modeling @/path/to/project
  122. Perform complete interface and data flow discovery analysis:
  123. 1. Comprehensive discovery of all system interfaces:
  124. - User interaction interfaces (Web UI, CLI, Mobile)
  125. - External APIs (REST, GraphQL, gRPC, WebSocket)
  126. - System interfaces (File system, Database, Message queue)
  127. - Internal services (Microservice calls, RPC, Event bus)
  128. 2. Build complete data flow diagram:
  129. - Annotate all data entry and exit points
  130. - Identify sensitive data flow paths
  131. - Mark trust boundary crossing points
  132. 3. Risk analysis for each interface:
  133. - Input validation risks
  134. - Authentication/authorization risks
  135. - Data leakage risks
  136. - Injection attack risks
  137. Output format: Complete interface inventory sorted by risk level, with CWE mapping and CVSS scores
  138. ```
  139. ### Scenario 2: Attack Tree, POC Generation & Pentest Plan
  140. Deep attack chain analysis with exploit POC generation and penetration testing plan.
  141. ```
  142. /threat-modeling @/path/to/project --debug
  143. Based on discovered security issues, perform deep attack analysis:
  144. 1. Attack tree construction:
  145. - Build attack tree for each high-risk threat
  146. - Analyze attack prerequisites and dependencies
  147. - Calculate attack success probability and impact scope
  148. 2. Attack chain analysis:
  149. - Identify multi-step attack paths (Initial Access → Execution → Persistence → Exfiltration)
  150. - Map to MITRE ATT&CK tactics and techniques
  151. - Mark critical pivot points in attack chain
  152. 3. Exploit POC generation:
  153. - Generate POC code for each exploitable vulnerability
  154. - Include payload construction, trigger conditions, expected results
  155. - Provide safe testing methods (avoid destructive operations)
  156. 4. Penetration testing plan:
  157. | Issue ID | Vulnerability | Test Case | Test Steps | POC | Recommended Tools |
  158. |----------|---------------|-----------|------------|-----|-------------------|
  159. Output: Complete penetration testing plan document, ready for security testing execution
  160. ```
  161. ### Scenario 3: Docker Test Environment & Automated Verification
  162. Set up isolated test environment and execute penetration testing plan.
  163. ```
  164. /threat-modeling @/path/to/project
  165. Set up test environment and execute penetration test verification:
  166. 1. Environment analysis:
  167. - Parse project's docker-compose.yml / Dockerfile
  168. - Identify required service dependencies (database, cache, message queue)
  169. - Analyze default configuration and environment variables
  170. 2. Docker test environment construction:
  171. - Generate isolated test environment docker-compose.test.yml
  172. - Configure network isolation and port mapping
  173. - Prepare test data and initialization scripts
  174. - Integrate security testing tool containers (OWASP ZAP, Nuclei, SQLMap)
  175. 3. Automated test execution:
  176. - Execute generated penetration testing plan
  177. - Collect test results and evidence screenshots
  178. - Verify vulnerability exploitability
  179. 4. Test report:
  180. - Vulnerability confirmation status (Confirmed / Not Exploitable / False Positive)
  181. - Actual risk assessment adjustment
  182. - Reproduction steps and evidence chain
  183. Output: Test environment config files + Automated test scripts + Test results report
  184. ```
  185. ### Scenario 4: Attack Chain Visualization & POC Optimization
  186. Comprehensive attack chain analysis with visualization and optimized exploitation.
  187. ```
  188. /threat-modeling @/path/to/project --debug
  189. Complete attack chain analysis and visualization:
  190. 1. Attack graph construction:
  191. - Build complete system attack graph
  192. - Nodes: Assets, vulnerabilities, attack techniques
  193. - Edges: Attack paths, prerequisites, success probability
  194. 2. Critical path analysis:
  195. - Identify shortest attack path (from entry to core assets)
  196. - Identify highest success rate path
  197. - Identify attack chain with maximum impact scope
  198. 3. POC optimization combination:
  199. - Tool chain optimization (Recon → Exploit → Post-Exploit)
  200. - Automated attack script generation
  201. - One-click vulnerability verification workflow
  202. 4. Visualization output:
  203. - Mermaid format attack tree diagram
  204. - Attack path heatmap
  205. - Risk-impact matrix diagram
  206. - ATT&CK Navigator mapping
  207. Output format:
  208. - Attack graph Markdown (with Mermaid diagrams)
  209. - Optimized POC toolkit
  210. - Risk visualization dashboard data
  211. ```
  212. ### Quick Reference: Extended Prompts
  213. | Scenario | Focus | Key Output |
  214. |----------|-------|------------|
  215. | **Interface Discovery** | All interfaces + Data flows | Risk-ranked interface inventory |
  216. | **Attack Tree & POC** | Attack chains + Exploits | Pentest plan with POC code |
  217. | **Docker Test Env** | Isolated testing | Test environment + Auto scripts |
  218. | **Attack Visualization** | Visual analysis | Attack graphs + Heatmaps |
  219. ## Output Structure
  220. ```
  221. {PROJECT_ROOT}/
  222. ├── Risk_Assessment_Report/ # Final reports (P8)
  223. │ ├── {PROJECT}-RISK-ASSESSMENT-REPORT.md
  224. │ ├── {PROJECT}-RISK-INVENTORY.md
  225. │ ├── {PROJECT}-PENETRATION-TEST-PLAN.md
  226. │ └── ...
  227. └── .phase_working/{SESSION_ID}/ # Working data
  228. ├── data/ # YAML phase data
  229. │ ├── P1_project_context.yaml
  230. │ ├── P2_dfd_elements.yaml
  231. │ └── ...
  232. └── reports/ # Markdown reports
  233. ├── P1-PROJECT-UNDERSTANDING.md
  234. └── ...
  235. ```
  236. ## Script Commands
  237. ### Knowledge Base Queries
  238. ```bash
  239. # STRIDE threat patterns
  240. python scripts/unified_kb_query.py --stride spoofing
  241. # Security controls
  242. python scripts/unified_kb_query.py --control AUTHN
  243. # CWE information with full chain
  244. python scripts/unified_kb_query.py --cwe CWE-89 --full-chain
  245. # CAPEC attack patterns
  246. python scripts/unified_kb_query.py --capec CAPEC-66 --attack-chain
  247. # AI/LLM specific threats
  248. python scripts/unified_kb_query.py --all-llm
  249. ```
  250. ### Module Discovery
  251. ```bash
  252. python scripts/module_discovery.py /path/to/project --p1-discovery
  253. ```
  254. ### Phase Data Management
  255. ```bash
  256. # Query previous phase data
  257. python scripts/phase_data.py --query --phase 1 --root /path/to/project
  258. # Validate phase output
  259. python scripts/phase_data.py --validate --phase 2 --root /path/to/project
  260. # Initialize new session
  261. python scripts/phase_data.py --init --project "PROJECT-NAME" --path /path/to/project
  262. ```
  263. ## 8-Phase Workflow
  264. ```
  265. P1 → P2 → P3 → P4 → P5 → P6 → P7 → P8
  266. │ │ │ │ │ │ │ └── Report Generation
  267. │ │ │ │ │ │ └── Mitigation Planning
  268. │ │ │ │ │ └── Risk Validation (POC, attack paths)
  269. │ │ │ │ └── STRIDE Threat Analysis (threat matrix)
  270. │ │ │ └── Security Design Review (16 domains)
  271. │ │ └── Trust Boundary Evaluation
  272. │ └── Call Flow & DFD Analysis (data flows, call flows)
  273. └── Project Understanding (modules, entry points)
  274. ```
  275. ## Knowledge Base
  276. | Category | Coverage |
  277. |----------|----------|
  278. | Security Controls | 16 domains, 107 controls |
  279. | Threat Patterns | CWE/CAPEC/ATT&CK (1,900+ patterns) |
  280. | AI/LLM Threats | 350+ threats |
  281. | Compliance | OWASP ASVS, WSTG, MASTG |
  282. | SQLite Index | ~8 MB searchable |
  283. ## Project Types Supported
  284. | Type | Example Technologies | Special Focus |
  285. |------|---------------------|---------------|
  286. | Web API | Django, FastAPI, Express | Authentication, API Security |
  287. | Microservices | K8s, Istio, Kafka | Service Mesh, Zero Trust |
  288. | AI/LLM Application | Claude API, RAG, Vector DB | Prompt Injection, Model Security |
  289. | Mobile Backend | JWT, OAuth, Firebase | Token Security, Data Privacy |
  290. | Legacy System | Monolith, SOAP | Technical Debt, Migration Risks |
  291. ## License
  292. BSD-3-Clause
  293. ## Repository
  294. https://github.com/fr33d3m0n/threat-modeling

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.