cga22099

Code-First Deep Risk Analysis v2.0

๐Ÿ” Transform source code into actionable security insights with the Code-First Automated Threat Modeling Toolkit for deep risk analysis.

cga22099 6 1 Updated 6mo ago

Resources

12
GitHub

Install

npx skillscat add cga22099/skill-threat-modeling

Install via the SkillsCat registry.

SKILL.md

name: threat-modeling
description: |
Code-first automated threat modeling toolkit. STRICT 8-PHASE WORKFLOW - DO NOT MODIFY.

MANDATORY: Create exactly 8 TodoWrite items with these EXACT names:

  • Phase 1: Project Understanding (้กน็›ฎ็†่งฃ)
  • Phase 2: Call Flow & DFD Analysis (ๆ•ฐๆฎๆตๅˆ†ๆž)
  • Phase 3: Trust Boundary Evaluation (ไฟกไปป่พน็•Œ)
  • Phase 4: Security Design Review (ๅฎ‰ๅ…จ่ฎพ่ฎก่ฏ„ๅฎก)
  • Phase 5: STRIDE Threat Analysis (STRIDEๅˆ†ๆž)
  • Phase 6: Risk Validation (้ฃŽ้™ฉ้ชŒ่ฏ) โ† NOT mitigation!
  • Phase 7: Mitigation Planning (็ผ“่งฃๆŽชๆ–ฝ) โ† AFTER validation!
  • Phase 8: Report Generation (ๆŠฅๅ‘Š็”Ÿๆˆ) โ† Output to Risk_Assessment_Report/

MANDATORY OUTPUT (Phase 8):

  • Directory: {PROJECT_ROOT}/Risk_Assessment_Report/
  • Main report: {PROJECT}-RISK-ASSESSMENT-REPORT.md (PROJECT=UPPERCASE)
  • Required: 4 reports + 6 phase docs (P1-P6)
  • โŒ FORBIDDEN: THREAT-MODEL-REPORT.md or reports in project root

Use when: threat model, STRIDE, DFD, security assessment, ๅจ่ƒๅปบๆจก, ๅฎ‰ๅ…จ่ฏ„ไผฐ.

Code-First Deep Risk Analysis v2.0

Code-first automated deep threat modeling with comprehensive security chain analysis.

Execution Mode

Full Assessment Only - All 8 phases executed sequentially with maximum depth.

Phase 1 โ”€โ”€โ–บ Phase 2 โ”€โ”€โ–บ Phase 3 โ”€โ”€โ–บ Phase 4 โ”€โ”€โ–บ Phase 5 โ”€โ”€โ–บ Phase 6 โ”€โ”€โ–บ Phase 7 โ”€โ”€โ–บ Phase 8
Project     Call Flow    Trust      Security    STRIDE      Risk        Mitigation   Report
Understanding  DFD      Boundaries   Design     Analysis   Validation

Strict Workflow Rules:

  1. Phases execute strictly in order (1โ†’2โ†’3โ†’4โ†’5โ†’6โ†’7โ†’8)
  2. Each phase output passes to next phase as input
  3. Summary and reflection after each phase before proceeding
  4. No skipping, reordering, or parallel execution of phases
  5. Multi-risk analysis within phases can use parallel sub-agents

Phase Todo Creation โ€” CRITICAL REQUIREMENT

โš ๏ธ STOP AND READ: Before ANY analysis, you MUST create EXACTLY 8 todo items.
DO NOT proceed until you have created all 8 phases as separate todo items.
DO NOT modify phase names or descriptions. Copy EXACTLY as shown below.

MANDATORY TodoWrite Call (copy exactly, do not modify):

[
  {"content": "Phase 1: Project Understanding", "status": "pending", "activeForm": "ๅˆ†ๆž้กน็›ฎๆžถๆž„ๅ’ŒๆŠ€ๆœฏๆ ˆ"},
  {"content": "Phase 2: Call Flow & DFD Analysis", "status": "pending", "activeForm": "ๆž„ๅปบๆ•ฐๆฎๆตๅ›พ"},
  {"content": "Phase 3: Trust Boundary Evaluation", "status": "pending", "activeForm": "่ฏ†ๅˆซไฟกไปป่พน็•Œ"},
  {"content": "Phase 4: Security Design Review", "status": "pending", "activeForm": "่ฏ„ไผฐๅฎ‰ๅ…จ่ฎพ่ฎก"},
  {"content": "Phase 5: STRIDE Threat Analysis", "status": "pending", "activeForm": "ๆ‰ง่กŒSTRIDEๅˆ†ๆž"},
  {"content": "Phase 6: Risk Validation", "status": "pending", "activeForm": "้ชŒ่ฏ้ฃŽ้™ฉๅ’Œๆ”ปๅ‡ป่ทฏๅพ„"},
  {"content": "Phase 7: Mitigation Planning", "status": "pending", "activeForm": "ๅˆถๅฎš็ผ“่งฃๆŽชๆ–ฝ"},
  {"content": "Phase 8: Report Generation", "status": "pending", "activeForm": "็”Ÿๆˆๅจ่ƒๅปบๆจกๆŠฅๅ‘Š"}
]

VIOLATIONS (will cause incorrect analysis):

  • โŒ Creating fewer than 8 phases
  • โŒ Combining phases (e.g., "Phase 2-7: Complete analysis")
  • โŒ Renaming phases (e.g., "Phase 6: ็ผ“่งฃๆŽชๆ–ฝ" instead of "Phase 6: Risk Validation")
  • โŒ Skipping Phase 6 (Risk Validation) or Phase 7 (Mitigation Planning)
  • โŒ Starting analysis before creating all 8 todo items

CORRECT execution order:

  1. Phase 6 = Risk Validation (้ชŒ่ฏ้ฃŽ้™ฉๅ’Œๆ”ปๅ‡ป่ทฏๅพ„) โ€” NOT mitigation
  2. Phase 7 = Mitigation Planning (ๅˆถๅฎš็ผ“่งฃๆŽชๆ–ฝ) โ€” comes AFTER validation
  3. Phase 8 = Report Generation (็”ŸๆˆๆŠฅๅ‘Š) โ€” final phase, MUST exist

Report Output Convention

Output Directory Structure

{PROJECT_ROOT}/
โ””โ”€โ”€ Risk_Assessment_Report/              โ† ๆœ€็ปˆๆŠฅๅ‘Š่พ“ๅ‡บ็›ฎๅฝ•
    โ”‚
    โ”‚  โ”Œโ”€ ๅฟ…้œ€ๆŠฅๅ‘Š (4ไปฝ) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”œโ”€โ”€ {PROJECT}-RISK-ASSESSMENT-REPORT.md    โ† ้ฃŽ้™ฉ่ฏ„ไผฐๆŠฅๅ‘Š (ไธปๆŠฅๅ‘Š)
    โ”œโ”€โ”€ {PROJECT}-RISK-INVENTORY.md            โ† ้ฃŽ้™ฉๆธ…ๅ•
    โ”œโ”€โ”€ {PROJECT}-MITIGATION-MEASURES.md       โ† ็ผ“่งฃๆŽชๆ–ฝ
    โ”œโ”€โ”€ {PROJECT}-PENETRATION-TEST-PLAN.md     โ† ๆธ—้€ๆต‹่ฏ•ๆ–นๆกˆ โœจ NEW
    โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
    โ”‚
    โ”‚  โ”Œโ”€ ้˜ถๆฎต่ฟ‡็จ‹ๆ–‡ๆกฃ (ไปŽ.phase_workingๅคๅˆถ๏ผŒไฟ็•™่‹ฑๆ–‡ๅ) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”œโ”€โ”€ P1-PROJECT-UNDERSTANDING.md            โ† Phase 1 ้กน็›ฎ็†่งฃ
    โ”œโ”€โ”€ P2-DFD-ANALYSIS.md                     โ† Phase 2 DFDๅˆ†ๆž
    โ”œโ”€โ”€ P3-TRUST-BOUNDARY.md                   โ† Phase 3 ไฟกไปป่พน็•Œ
    โ”œโ”€โ”€ P4-SECURITY-DESIGN-REVIEW.md           โ† Phase 4 ๅฎ‰ๅ…จ่ฎพ่ฎก่ฏ„ไผฐ
    โ”œโ”€โ”€ P5-STRIDE-THREATS.md                   โ† Phase 5 STRIDEๅจ่ƒๅˆ†ๆž
    โ”œโ”€โ”€ P6-RISK-VALIDATION.md                  โ† Phase 6 ้ฃŽ้™ฉ้ชŒ่ฏ
    โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
    โ”‚
    โ””โ”€โ”€ .phase_working/                        โ† ้˜ถๆฎตไบง็‰ฉๅทฅไฝœ็›ฎๅฝ• (้š่—)
        โ”œโ”€โ”€ _session_meta.yaml                 โ† ไผš่ฏๅ…ƒๆ•ฐๆฎ
        โ”œโ”€โ”€ P1-PROJECT-UNDERSTANDING.md        โ† Phase 1 ๅทฅไฝœๆ–‡ๆกฃ
        โ”œโ”€โ”€ P2-DFD-ANALYSIS.md                 โ† Phase 2 ๅทฅไฝœๆ–‡ๆกฃ
        โ”œโ”€โ”€ P3-TRUST-BOUNDARY.md               โ† Phase 3 ๅทฅไฝœๆ–‡ๆกฃ
        โ”œโ”€โ”€ P4-SECURITY-DESIGN-REVIEW.md       โ† Phase 4 ๅทฅไฝœๆ–‡ๆกฃ
        โ”œโ”€โ”€ P5-STRIDE-THREATS.md               โ† Phase 5 ๅทฅไฝœๆ–‡ๆกฃ
        โ”œโ”€โ”€ P6-RISK-VALIDATION.md              โ† Phase 6 ๅทฅไฝœๆ–‡ๆกฃ
        โ””โ”€โ”€ P7-MITIGATION-PLAN.md              โ† Phase 7 ๅทฅไฝœๆ–‡ๆกฃ

File Naming Convention

Format: {PROJECT}-{REPORT_TYPE}.md

  • PROJECT: ไปŽ้กน็›ฎๅๆๅ–๏ผŒ่ฝฌๅคงๅ†™๏ผŒๆœ€ๅคš30ๅญ—็ฌฆ
    • ๆ ผๅผ: ^[A-Z][A-Z0-9-]{0,29}$
    • ็คบไพ‹: OPEN-WEBUI, MY-PROJECT, STRIDE-DEMO
  • REPORT_TYPE: ๆ ‡ๅ‡†ๆŠฅๅ‘Š็ฑปๅž‹ (ๅคงๅ†™)
ๆŠฅๅ‘Š็ฑปๅž‹ ๅฟ…้œ€ๆกไปถ ๆ–‡ไปถๅ็คบไพ‹
้ฃŽ้™ฉ่ฏ„ไผฐๆŠฅๅ‘Š (ไธปๆŠฅๅ‘Š) โœ… ๅง‹็ปˆ OPEN-WEBUI-RISK-ASSESSMENT-REPORT.md
้ฃŽ้™ฉๆธ…ๅ• โœ… ๅง‹็ปˆ OPEN-WEBUI-RISK-INVENTORY.md
็ผ“่งฃๆŽชๆ–ฝ โœ… ๅง‹็ปˆ OPEN-WEBUI-MITIGATION-MEASURES.md
ๆธ—้€ๆต‹่ฏ•ๆ–นๆกˆ โœ… ๅง‹็ปˆ OPEN-WEBUI-PENETRATION-TEST-PLAN.md
ๆžถๆž„ๅˆ†ๆž โšช ๅฏ้€‰ OPEN-WEBUI-ARCHITECTURE-ANALYSIS.md
DFDๅ›พ โšช ๅฏ้€‰ OPEN-WEBUI-DFD-DIAGRAM.md
ๅˆ่ง„ๆ˜ ๅฐ„ โšช ๅฏ้€‰ OPEN-WEBUI-COMPLIANCE-MAPPING.md
ๆ”ปๅ‡ป่ทฏๅพ„ โšช ๅฏ้€‰ OPEN-WEBUI-ATTACK-PATHS.md
ๆ‰ง่กŒๆ‘˜่ฆ โšช ๅฏ้€‰ OPEN-WEBUI-EXECUTIVE-SUMMARY.md

ๅ›พไพ‹: โœ… ๅฟ…้œ€ | โšช ๅฏ้€‰

Phase Output Persistence

ๆฏ้˜ถๆฎตๅฎŒๆˆๆ—ถ:

  1. ๅฐ†้˜ถๆฎต่พ“ๅ‡บๅ†™ๅ…ฅ .phase_working/P{N}-*.md
  2. ๆ›ดๆ–ฐ _session_meta.yaml ็š„ phases_completed

ไผš่ฏๅ…ƒๆ•ฐๆฎ (_session_meta.yaml):

session_id: "20260103-120000"
project_name: "OPEN-WEBUI"
project_path: "/path/to/project"
started_at: "2026-01-03T12:00:00+08:00"
phases_completed: [1, 2, 3]  # ๅทฒๅฎŒๆˆ็š„้˜ถๆฎต
current_phase: 4
skill_version: "2.1.0"

Session Recovery

ๆ–ฐไผš่ฏๅฏๅŠจๆ—ถๆฃ€ๆŸฅ .phase_working/:

  • ๅญ˜ๅœจไธ” project_name ๅŒน้… โ†’ ๆ็คบ: "็ปง็ปญไธŠๆฌกไผš่ฏ" ๆˆ– "่ฆ†็›–้‡ๆ–ฐๅผ€ๅง‹"
  • ๅญ˜ๅœจไฝ† project_name ไธๅŒ โ†’ ๆธ…็ฉบ็›ฎๅฝ•๏ผŒๅผ€ๅง‹ๆ–ฐไผš่ฏ
  • ไธๅญ˜ๅœจ โ†’ ๅˆ›ๅปบ็›ฎๅฝ•๏ผŒๅผ€ๅง‹ๆ–ฐไผš่ฏ

่ฏฆ็ป†่ง„่Œƒ: ่ง WORKFLOW.md Phase 8 ้ƒจๅˆ†
็คบไพ‹: ่ง EXAMPLES.md

Language Adaptation Rules

ๅŽŸๅˆ™: ่พ“ๅ‡บ่ฏญ่จ€่ทŸ้šไธŠไธ‹ๆ–‡่ฏญ่จ€๏ผŒ้™ค้žๆ˜พๅผๆŒ‡ๅฎšใ€‚

่ฏญ่จ€ๆฃ€ๆต‹้€ป่พ‘

็”จๆˆทๆŒ‡ไปค่ฏญ่จ€ โ†’ ่พ“ๅ‡บ่ฏญ่จ€
โ”œโ”€โ”€ ไธญๆ–‡ๆŒ‡ไปค/ไธŠไธ‹ๆ–‡ โ†’ ไธญๆ–‡ๆ–‡ไปถๅ + ไธญๆ–‡ๅ†…ๅฎน
โ”œโ”€โ”€ ่‹ฑๆ–‡ๆŒ‡ไปค/ไธŠไธ‹ๆ–‡ โ†’ ่‹ฑๆ–‡ๆ–‡ไปถๅ + ่‹ฑๆ–‡ๅ†…ๅฎน
โ”œโ”€โ”€ ๅ…ถไป–่ฏญ่จ€ โ†’ ่ทŸ้š่ฏฅ่ฏญ่จ€
โ””โ”€โ”€ --lang=xx ๆ˜พๅผๆŒ‡ๅฎš โ†’ ่ฆ†็›–่‡ชๅŠจๆฃ€ๆต‹

ๅฝฑๅ“่Œƒๅ›ด

ๅ…ƒ็ด  ่ฏญ่จ€่‡ช้€‚ๅบ” ็คบไพ‹ (ไธญๆ–‡ไธŠไธ‹ๆ–‡) ็คบไพ‹ (่‹ฑๆ–‡ไธŠไธ‹ๆ–‡)
ๆŠฅๅ‘Šๆ–‡ไปถๅ โœ… ้กน็›ฎ-้ฃŽ้™ฉ่ฏ„ไผฐๆŠฅๅ‘Š.md PROJECT-RISK-ASSESSMENT-REPORT.md
้˜ถๆฎตไบง็‰ฉๆ–‡ไปถๅ โœ… P1-้กน็›ฎ็†่งฃ.md P1-PROJECT-UNDERSTANDING.md
ๆŠฅๅ‘Šๅ†…ๅฎน โœ… ไธญๆ–‡ๆญฃๆ–‡ English content
็›ฎๅฝ•ๅ โœ… ้ฃŽ้™ฉ่ฏ„ไผฐๆŠฅๅ‘Š/ Risk_Assessment_Report/
ๆจกๆฟๅ ไฝ็ฌฆ โŒ ไฟๆŒ่‹ฑๆ–‡ (ๅ†…้ƒจไฝฟ็”จ) ไฟๆŒ่‹ฑๆ–‡

ๆ˜พๅผ่ฏญ่จ€ๆŒ‡ๅฎš

# ๅผบๅˆถ่‹ฑๆ–‡่พ“ๅ‡บ (ๅณไฝฟไธŠไธ‹ๆ–‡ๆ˜ฏไธญๆ–‡)
--lang=en

# ๅผบๅˆถไธญๆ–‡่พ“ๅ‡บ (ๅณไฝฟไธŠไธ‹ๆ–‡ๆ˜ฏ่‹ฑๆ–‡)
--lang=zh

# ๆ”ฏๆŒ็š„่ฏญ่จ€ไปฃ็ : en, zh, ja, ko, es, fr, de, pt, ru

ๅฎž็Žฐๆ–นๅผ

  • ๆจกๆฟ: ไฟๆŒๅ•ไธ€่‹ฑๆ–‡ๆจกๆฟ (assets/templates/*.template.md)
  • ่ฝฌๆข: LLM ๆ นๆฎไธŠไธ‹ๆ–‡่ฏญ่จ€ๅฎžๆ—ถ็ฟป่ฏ‘่พ“ๅ‡บ
  • ๆ–‡ไปถๅๆ˜ ๅฐ„: ่งไธ‹่กจ

ๆ–‡ไปถๅ่ฏญ่จ€ๆ˜ ๅฐ„่กจ

English (Default) ไธญๆ–‡ Franรงais Espaรฑol
RISK-ASSESSMENT-REPORT ้ฃŽ้™ฉ่ฏ„ไผฐๆŠฅๅ‘Š RAPPORT-EVALUATION-RISQUES INFORME-EVALUACION-RIESGOS
RISK-INVENTORY ้ฃŽ้™ฉๆธ…ๅ• INVENTAIRE-RISQUES INVENTARIO-RIESGOS
MITIGATION-MEASURES ็ผ“่งฃๆŽชๆ–ฝ MESURES-ATTENUATION MEDIDAS-MITIGACION
PENETRATION-TEST-PLAN ๆธ—้€ๆต‹่ฏ•ๆ–นๆกˆ PLAN-TEST-PENETRATION PLAN-PRUEBA-PENETRACION
P1-PROJECT-UNDERSTANDING P1-้กน็›ฎ็†่งฃ P1-COMPREHENSION-PROJET P1-COMPRENSION-PROYECTO
P2-DFD-ANALYSIS P2-ๆ•ฐๆฎๆตๅˆ†ๆž P2-ANALYSE-DFD P2-ANALISIS-DFD
P3-TRUST-BOUNDARY P3-ไฟกไปป่พน็•Œ P3-LIMITE-CONFIANCE P3-LIMITE-CONFIANZA
P4-SECURITY-DESIGN-REVIEW P4-ๅฎ‰ๅ…จ่ฎพ่ฎก่ฏ„ๅฎก P4-REVUE-CONCEPTION-SECURITE P4-REVISION-DISENO-SEGURIDAD
P5-STRIDE-THREATS P5-STRIDEๅจ่ƒๅˆ†ๆž P5-MENACES-STRIDE P5-AMENAZAS-STRIDE
P6-RISK-VALIDATION P6-้ฃŽ้™ฉ้ชŒ่ฏ P6-VALIDATION-RISQUES P6-VALIDACION-RIESGOS
Risk_Assessment_Report/ ้ฃŽ้™ฉ่ฏ„ไผฐๆŠฅๅ‘Š/ Rapport_Evaluation_Risques/ Informe_Evaluacion_Riesgos/

ๆณจๆ„: ๆŠ€ๆœฏๆœฏ่ฏญ (STRIDE, DFD, CWE, CAPEC, ATT&CK) ไฟๆŒ่‹ฑๆ–‡ไธ็ฟป่ฏ‘ใ€‚

Skill Path Resolution

Issue: Scripts use relative paths scripts/unified_kb_query.py, but Claude may work in project root.

Solution: Resolve Skill installation path before executing scripts.

Path Detection Algorithm

Priority Order:
1. $SKILL_PATH environment variable (explicit override)
2. Script self-location (when running from skill directory)
3. Project-local paths (multi-platform):
   - .claude/skills/{threat-modeling|skill-threat-modeling}/
   - .agents/skills/{name}/     (Portable/XDG standard)
   - .qwen/agents/{name}/       (Qwen Code)
   - .codex/skills/{name}/      (OpenAI Codex)
   - .github/skills/{name}/     (GitHub Copilot)
   - .goose/skills/{name}/      (Goose)
4. Global paths (multi-platform):
   - ~/.claude/skills/{name}/
   - ~/.config/agents/skills/{name}/   (XDG Portable)
   - ~/.qwen/agents/{name}/
   - ~/.codex/skills/{name}/
   - ~/.config/goose/skills/{name}/

Supported Directory Names: threat-modeling, skill-threat-modeling (both work)

Claude Invocation Pattern

Step 1: Detect and cache SKILL_PATH at session start:

# Use the skill_path.sh helper (recommended - supports all platforms)
SKILL_PATH=$(bash skill_path.sh)

# Or set environment variable explicitly
export SKILL_PATH=/path/to/skill-threat-modeling

Step 2: Execute scripts using detected path:

# Standard invocation pattern
python "$SKILL_PATH/scripts/unified_kb_query.py" --stride spoofing

# Or cd to skill directory
cd "$SKILL_PATH" && python scripts/unified_kb_query.py --stride spoofing

Shortcut 1: kb wrapper (Recommended)

Skill includes kb wrapper script for invocation from any directory:

# Use absolute path to invoke kb wrapper
$SKILL_PATH/kb --stride spoofing
$SKILL_PATH/kb --full-chain CWE-89
$SKILL_PATH/kb --all-llm

# Or add to PATH
export PATH="$SKILL_PATH:$PATH"
kb --stride spoofing

Shortcut 2: skill_path.sh

Get skill path for other operations:

# Get skill path
SKILL_PATH=$(bash skill_path.sh)

# One-liner invocation
python "$(bash skill_path.sh)/scripts/unified_kb_query.py" --stride spoofing

Development Mode

Use source path directly during development:

# Development path (non-installed mode)
cd /path/to/threat-modeling
python scripts/unified_kb_query.py --stride spoofing

Script Invocation Convention

All python scripts/unified_kb_query.py ... examples in this document assume:

  1. cd $SKILL_PATH has been executed, or
  2. Use $SKILL_PATH/kb ... as replacement

Claude should detect SKILL_PATH at session start and use kb wrapper or cd mode.


Security Knowledge Architecture

Three Knowledge Sets

The security knowledge system consists of three complementary sets:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                              Security Knowledge Architecture                                   โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                                                โ”‚
โ”‚                       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                           โ”‚
โ”‚                       โ”‚         Security Principles               โ”‚                           โ”‚
โ”‚                       โ”‚    (Foundation - Guides All Phases)       โ”‚                           โ”‚
โ”‚                       โ”‚  DID โ”‚ LP โ”‚ ZT โ”‚ FS โ”‚ SOD โ”‚ SBD โ”‚ CM โ”‚ EOM โ”‚ OD โ”‚ IV โ”‚ LA            โ”‚
โ”‚                       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                           โ”‚
โ”‚                                           โ”‚                                                    โ”‚
โ”‚                 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                         โ”‚
โ”‚                 โ”‚                                                    โ”‚                         โ”‚
โ”‚                 โ–ผ                                                    โ–ผ                         โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”        โ”‚
โ”‚  โ”‚      Security Control Set          โ”‚      โ”‚      Threat Pattern Set             โ”‚        โ”‚
โ”‚  โ”‚      (What to do & How to do)      โ”‚      โ”‚      (What to know & Validate)      โ”‚        โ”‚
โ”‚  โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค      โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค        โ”‚
โ”‚  โ”‚  Security Domains (16)              โ”‚      โ”‚  CWE Weakness Types (974)           โ”‚        โ”‚
โ”‚  โ”‚      โ”‚                              โ”‚      โ”‚      โ”‚                              โ”‚        โ”‚
โ”‚  โ”‚      โ–ผ                              โ”‚      โ”‚      โ–ผ                              โ”‚        โ”‚
โ”‚  โ”‚  Control Sets (18 files, 107)       โ”‚      โ”‚  CAPEC Attack Patterns (615)        โ”‚        โ”‚
โ”‚  โ”‚      โ”‚                              โ”‚      โ”‚      โ”‚                              โ”‚        โ”‚
โ”‚  โ”‚      โ–ผ                              โ”‚      โ”‚      โ–ผ                              โ”‚        โ”‚
โ”‚  โ”‚  OWASP References (74)              โ”‚      โ”‚  ATT&CK Techniques (835)            โ”‚        โ”‚
โ”‚  โ”‚      โ”‚                              โ”‚      โ”‚      โ”‚                              โ”‚        โ”‚
โ”‚  โ”‚      โ–ผ                              โ”‚      โ”‚      โ–ผ                              โ”‚        โ”‚
โ”‚  โ”‚  Compliance Frameworks (14)         โ”‚      โ”‚  CVE/KEV Vulnerabilities (323K+)    โ”‚        โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ”‚
โ”‚                 โ”‚                                             โ”‚                               โ”‚
โ”‚                 โ”‚      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”        โ”‚                               โ”‚
โ”‚                 โ”‚      โ”‚    Verification Set         โ”‚        โ”‚                               โ”‚
โ”‚                 โ”‚      โ”‚  (How to verify & test)     โ”‚        โ”‚                               โ”‚
โ”‚                 โ””โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚                             โ”‚โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                               โ”‚
โ”‚                        โ”‚  WSTG Tests (121)           โ”‚                                        โ”‚
โ”‚                        โ”‚  MASTG Tests (206)          โ”‚                                        โ”‚
โ”‚                        โ”‚  ASVS Requirements (345)    โ”‚                                        โ”‚
โ”‚                        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                                        โ”‚
โ”‚                                     โ”‚                                                          โ”‚
โ”‚                                     โ–ผ                                                          โ”‚
โ”‚                        Used in: Phase 6 / Phase 7 / Phase 8                                   โ”‚
โ”‚                                                                                                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Security Principles (11)

Core security principles that guide all security design decisions across all 8 phases.

Code Principle Definition
DID Defense in Depth Multiple independent security controls; single point failure doesn't compromise system
LP Least Privilege Grant only minimum permissions required to complete task
ZT Zero Trust Never trust, always verify; assume network is compromised
FS Fail Secure Default to most secure state on error
SOD Separation of Duties Critical operations require multiple parties; prevent single-person abuse
SBD Secure by Default Default configuration is secure; user must actively reduce security
CM Complete Mediation Every access must be verified; no bypass paths
EOM Economy of Mechanism Security mechanisms should be simple and auditable; complexity is security's enemy
OD Open Design Security doesn't depend on algorithm or design secrecy
IV Input Validation All input must be validated before processing; default deny
LA Least Agency Limit AI agent autonomy, tool access, and decision scope to minimum required

Phase References:

  • Phase 1: DID, LP, ZT, LA (architecture assessment, agent scope)
  • Phase 2: CM, IV, ZT (data flow security)
  • Phase 3: ZT, SOD, LP, LA (trust boundaries, agent boundaries)
  • Phase 4: All 11 principles (security function completeness)

Detailed definitions in assets/knowledge/security-principles.yaml

Security Control Set

Defines "what to do" and "how to do it" from a defensive perspective.

Security Domains โ”€โ”€โ–ถ Control Sets โ”€โ”€โ–ถ OWASP References โ”€โ”€โ–ถ Compliance Frameworks
       โ”‚                  โ”‚                  โ”‚                      โ”‚
   security-         control-set-       reference-set-          YAML + SQLite
   design.yaml         *.md               *.md              (compliance tables)

Security Domains (16 total):

Seq Code Name STRIDE Description
01 AUTHN Authentication & Session S Identity verification and session lifecycle
02 AUTHZ Authorization & Access Control E Access permission enforcement
03 INPUT Input Validation T External input validation and sanitization
04 OUTPUT Output Encoding T,I Context-aware output encoding
05 CLIENT Client-Side Security S,T,I Browser and client-side security
06 CRYPTO Cryptography & Transport I Data encryption in transit and at rest
07 LOG Logging & Monitoring R Security event logging and audit
08 ERROR Error Handling I Secure error handling and information control
09 API API & Service Security S,T,I,D,E API endpoint and service communication security
10 DATA Data Protection I Sensitive data and credential protection
ext-11 INFRA Infrastructure Security - Container and orchestration security
ext-12 SUPPLY Supply Chain Security - Dependency and pipeline security
ext-13 AI AI/LLM Security - LLM-specific threats (OWASP LLM Top 10)
ext-14 MOBILE Mobile Security - Mobile app security
ext-15 CLOUD Cloud Security - Cloud-native security controls
ext-16 AGENT Agentic Security S,T,R,I,D,E AI Agent security (OWASP Agentic Top 10)

Threat Pattern Set

Defines "what to know" and "what to validate" from an offensive perspective.

CWE Weaknesses โ”€โ”€โ–ถ CAPEC Patterns โ”€โ”€โ–ถ ATT&CK Techniques โ”€โ”€โ–ถ CVE/KEV Vulnerabilities
       โ”‚                 โ”‚                   โ”‚                       โ”‚
   SQLite:cwe       SQLite:capec      SQLite:attack_*         SQLite:cve + API
   (974 entries)    (615 entries)     (835 entries)           (323K+ entries)

STRIDE to CWE Mapping:

STRIDE Primary CWEs Attack Patterns
S (Spoofing) CWE-287, 290, 307 CAPEC-151, 194, 600
T (Tampering) CWE-20, 77, 78, 89 CAPEC-66, 88, 248
R (Repudiation) CWE-117, 223, 778 CAPEC-93
I (Information Disclosure) CWE-200, 209, 311 CAPEC-116, 157
D (Denial of Service) CWE-400, 770, 918 CAPEC-125, 227
E (Elevation of Privilege) CWE-269, 284, 862 CAPEC-122, 233

Verification Set (Cross-Cutting)

Bridges Security Control Set and Threat Pattern Set, providing test procedures for Phase 6/7/8.

Component Tests/Requirements Usage
WSTG (Web Security Testing Guide) 121 tests Phase 6: Risk validation
MASTG (Mobile App Security Testing Guide) 206 tests Phase 6: Mobile risk validation
ASVS (Application Security Verification Standard) 345 requirements Phase 7-8: Mitigation & compliance

STRIDE to Verification Mapping:

STRIDE Verification Categories Test Count
S (Spoofing) WSTG-ATHN/IDNT/SESS, MASTG-AUTH, ASVS-V6/V7/V9/V10 240
T (Tampering) WSTG-INPV/CONF/CLNT, MASTG-PLATFORM/RESILIENCE, ASVS-V1/V2/V3 402
R (Repudiation) WSTG-BUSL, ASVS-V7/V16 46
I (Information Disclosure) WSTG-INFO/ERRH/CRYP, MASTG-STORAGE/NETWORK, ASVS-V11/V12/V14 442
D (Denial of Service) WSTG-BUSL/APIT, MASTG-RESILIENCE 49
E (Elevation of Privilege) WSTG-AUTHZ, MASTG-PLATFORM, ASVS-V8 90
Total All verification tests mapped to STRIDE 1,269

8-Phase Workflow Overview

Phase Name Type Knowledge Sets Used Key Output
1 Project Understanding Exploratory Security Principles findings_1: project_context
2 Call Flow & DFD Constructive Principles + security-design.yaml findings_2: dfd_elements
3 Trust Boundaries Evaluative Principles + security-design.yaml findings_3: boundary_context
4 Security Design Evaluative Control Sets + References findings_4: security_gaps
5 STRIDE Analysis Enumerative CWE โ†’ CAPEC (Threat Pattern Set) findings_5: threat_inventory
6 Risk Validation Verification Threat Pattern Set + Verification Set validated_risks
7 Mitigation Prescriptive Control Sets + CWE Mitigations + ASVS mitigation_plan
8 Report Comprehensive All outputs + Compliance + ASVS RISK-ASSESSMENT-REPORT.md

Core Data Model (ๆ ธๅฟƒๆ•ฐๆฎๆจกๅž‹) โš ๏ธ CRITICAL

Design Principle: ไปŽๆ•ฐๆฎๆตๅŠจๅ’Œ่ฝฌๆข็š„ๆœฌ่ดจๅ‡บๅ‘๏ผŒๅฎšไน‰ๆธ…ๆ™ฐ็š„ๅฎžไฝ“ใ€ๅ…ณ็ณปๅ’Œ่ฝฌๆข่ง„ๅˆ™

Entity Definitions (ๅฎžไฝ“ๅฎšไน‰)

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      Core Entity Model                           โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                  โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚  โ”‚  Finding (ๅ‘็Žฐ)                                          โ”‚   โ”‚
โ”‚  โ”‚  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                                       โ”‚   โ”‚
โ”‚  โ”‚  ๆฅๆบ: Phase 1-4                                         โ”‚   โ”‚
โ”‚  โ”‚  ID: F-P{N}-{Seq}  ไพ‹: F-P1-001, F-P4-003               โ”‚   โ”‚
โ”‚  โ”‚  ๆ€ง่ดจ: ๅฎ‰ๅ…จ็›ธๅ…ณ็š„่ง‚ๅฏŸใ€็ผบ้™ทใ€้ฃŽ้™ฉ็‚น                         โ”‚   โ”‚
โ”‚  โ”‚  ๆ•ฐ้‡: ้€šๅธธ 10-30 ไธช                                      โ”‚   โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ”‚                              โ”‚                                   โ”‚
โ”‚                              โ–ผ (่พ“ๅ…ฅ Phase 5)                   โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚  โ”‚  Threat (ๅจ่ƒ)                                           โ”‚   โ”‚
โ”‚  โ”‚  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                                       โ”‚   โ”‚
โ”‚  โ”‚  ๆฅๆบ: Phase 5 STRIDE ๅˆ†ๆž                               โ”‚   โ”‚
โ”‚  โ”‚  ID: T-{STRIDE}-{ElementID}-{Seq}  ไพ‹: T-T-P13-002       โ”‚   โ”‚
โ”‚  โ”‚  ๆ€ง่ดจ: ้’ˆๅฏน DFD ๅ…ƒ็ด ็š„ๆฝœๅœจๆ”ปๅ‡ปๅ‘้‡                         โ”‚   โ”‚
โ”‚  โ”‚  ๆ•ฐ้‡: ้€šๅธธ 50-200 ไธช (ๆฏๅ…ƒ็ด ๅคšไธช)                         โ”‚   โ”‚
โ”‚  โ”‚  ็Šถๆ€: identified (ๅทฒ่ฏ†ๅˆซ)                                โ”‚   โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ”‚                              โ”‚                                   โ”‚
โ”‚                              โ–ผ (้ชŒ่ฏ Phase 6)                   โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚  โ”‚  ValidatedRisk (้ชŒ่ฏ้ฃŽ้™ฉ)                                โ”‚   โ”‚
โ”‚  โ”‚  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                                       โ”‚   โ”‚
โ”‚  โ”‚  ๆฅๆบ: Phase 6 ้ฃŽ้™ฉ้ชŒ่ฏ                                   โ”‚   โ”‚
โ”‚  โ”‚  ID: VR-{Seq}  ไพ‹: VR-001                                โ”‚   โ”‚
โ”‚  โ”‚  ๆ€ง่ดจ: ็ป่ฟ‡้ชŒ่ฏ็š„ใ€ๅฏๅˆฉ็”จ็š„้ฃŽ้™ฉ                            โ”‚   โ”‚
โ”‚  โ”‚  ๆ•ฐ้‡: ้€šๅธธ 5-30 ไธช (ๅจ่ƒๅˆๅนถ/่ฟ‡ๆปคๅŽ)                      โ”‚   โ”‚
โ”‚  โ”‚  โš ๏ธ ๅฟ…ๅกซ: threat_refs[] ่ฟฝๆบฏๅˆฐๅŽŸๅง‹ๅจ่ƒ                   โ”‚   โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ”‚                              โ”‚                                   โ”‚
โ”‚                              โ–ผ (็ผ“่งฃ Phase 7)                   โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚  โ”‚  Mitigation (็ผ“่งฃๆŽชๆ–ฝ)                                   โ”‚   โ”‚
โ”‚  โ”‚  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                                       โ”‚   โ”‚
โ”‚  โ”‚  ๆฅๆบ: Phase 7 ็ผ“่งฃ่ง„ๅˆ’                                   โ”‚   โ”‚
โ”‚  โ”‚  ID: M-{Seq}  ไพ‹: M-001                                  โ”‚   โ”‚
โ”‚  โ”‚  ๆ€ง่ดจ: ้’ˆๅฏน้ชŒ่ฏ้ฃŽ้™ฉ็š„ไฟฎๅคๆ–นๆกˆ                              โ”‚   โ”‚
โ”‚  โ”‚  ๆ•ฐ้‡: ้€šๅธธ 5-20 ไธช (ๅฏไธ€ๅฏนๅคš)                            โ”‚   โ”‚
โ”‚  โ”‚  ๅŒ…ๅซ: risk_refs[] ่ฟฝๆบฏๅˆฐ้ชŒ่ฏ้ฃŽ้™ฉ                         โ”‚   โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ”‚                                                                  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Entity Relationships (ๅฎžไฝ“ๅ…ณ็ณป)

DFD Element              1:N                 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
(P01, DS01, DF01...)    โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚  Threat  โ”‚
                                             โ”‚ (T-xxx)  โ”‚
                                             โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜
                                                  โ”‚
                                                  โ”‚ N:1 (ๅˆๅนถ)
                                                  โ–ผ
                                        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
Finding โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚ ValidatedRisk   โ”‚
(F-xxx)   ๅˆๅนถ                           โ”‚   (VR-xxx)      โ”‚
                                        โ”‚                 โ”‚
                                        โ”‚ threat_refs:    โ”‚
                                        โ”‚ [T-T-P13-001,   โ”‚
                                        โ”‚  T-T-P13-002,   โ”‚
                                        โ”‚  T-E-P13-001]   โ”‚
                                        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                                 โ”‚
                                                 โ”‚ N:1 (่ฆ†็›–)
                                                 โ–ผ
                                        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                                        โ”‚   Mitigation    โ”‚
                                        โ”‚    (M-xxx)      โ”‚
                                        โ”‚                 โ”‚
                                        โ”‚ risk_refs:      โ”‚
                                        โ”‚ [VR-001,        โ”‚
                                        โ”‚  VR-002]        โ”‚
                                        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

ๅ…ณ้”ฎๅ…ณ็ณป:
โ€ข Threat N:1 ValidatedRisk (ๅคšๅจ่ƒๅˆๅนถไธบไธ€ไธช้ฃŽ้™ฉ)
โ€ข ValidatedRisk N:1 Mitigation (ๅคš้ฃŽ้™ฉๅฏ่ขซๅŒไธ€ๆŽชๆ–ฝ่ฆ†็›–)
โ€ข ๆ‰€ๆœ‰ๅ…ณ็ณป้€š่ฟ‡ *_refs[] ๆ˜พๅผ่ฟฝๆบฏ

Unified ID Convention (็ปŸไธ€ID่ง„่Œƒ)

ๅฎžไฝ“็ฑปๅž‹ ID ๆ ผๅผ ็คบไพ‹ ้˜ถๆฎต
Finding F-P{N}-{Seq:03d} F-P1-001 P1-P4
Threat T-{STRIDE}-{Element}-{Seq} T-T-P13-002 P5
ValidatedRisk VR-{Seq:03d} VR-001 P6
Mitigation M-{Seq:03d} M-001 P7
POC POC-{Seq:03d} POC-001 P6
AttackPath AP-{Seq:03d} AP-001 P6
AttackChain AC-{Seq:03d} AC-001 P6

โŒ ็ฆๆญข็š„ ID ๆ ผๅผ (ไธๅ†ไฝฟ็”จ):

  • RISK-{Seq} โ†’ ๆ”น็”จ VR-{Seq}
  • T-E-RCE-001 โ†’ ๆ”น็”จ T-E-P13-001 (ไฟ็•™ ElementID)
  • SD-{Seq} โ†’ ๆ”น็”จ F-P4-{Seq}

Count Conservation Rules (ๆ•ฐ้‡ๅฎˆๆ’่ง„ๅˆ™) โš ๏ธ CRITICAL

# ๅจ่ƒๅค„็†ๅฎˆๆ’ๅ…ฌๅผ
count_conservation:
  p5_output: "threat_inventory.total = T"  # ไพ‹: 120
  p6_processing:
    verified: V      # ้ชŒ่ฏ็กฎ่ฎค็š„ๅจ่ƒๆ•ฐ
    theoretical: Th  # ็†่ฎบๅฏ่กŒ็š„ๅจ่ƒๆ•ฐ
    pending: P       # ๅพ…้ชŒ่ฏ็š„ๅจ่ƒๆ•ฐ
    excluded: E      # ๆŽ’้™ค็š„ๅจ่ƒๆ•ฐ (ๆœ‰็†็”ฑ)

  conservation_formula: "V + Th + P + E = T"

  traceability_rule: |
    FOR each threat T in p5_output:
      T MUST appear in exactly one VR.threat_refs[]
      OR T.status = 'excluded' with documented reason

  report_consistency:
    RISK-INVENTORY.count = "len(VR where status != 'excluded')"
    MAIN-REPORT.risk_count = "RISK-INVENTORY.count"

# ้ชŒ่ฏๆฃ€ๆŸฅ็‚น
checkpoints:
  cp1_p5_to_p6: "P6.input_count = P5.threat_inventory.summary.total"
  cp2_p6_output: "sum(verified, theoretical, pending, excluded) = input_count"
  cp3_report_gen: "RISK-INVENTORY.count = P6.final_risk_count"

ValidatedRisk Structure (้ชŒ่ฏ้ฃŽ้™ฉๆ•ฐๆฎ็ป“ๆž„)

ValidatedRisk:
  # === ๆ ‡่ฏ† ===
  id:
    format: "VR-{Seq:03d}"
    example: "VR-001"

  # === ่ฟฝๆบฏ (MANDATORY!) ===
  threat_refs:
    type: array[Threat.id]
    description: "ๆญค้ฃŽ้™ฉๆฅๆบ็š„ๆ‰€ๆœ‰ๅจ่ƒ ID"
    example: ["T-T-P13-001", "T-T-P13-002", "T-E-P13-001"]
    requirement: "MANDATORY - ๅฟ…้กปๅˆ—ๅ‡บๆ‰€ๆœ‰ๆบๅจ่ƒ"

  finding_refs:
    type: array[Finding.id]
    description: "ๆญค้ฃŽ้™ฉๆฅๆบ็š„ P1-P4 ๅ‘็Žฐ"
    example: ["F-P4-003"]
    requirement: "OPTIONAL - ๅฆ‚ๆœ‰ๅ…ณ่”ๅ‘็Žฐ"

  # === ้ฃŽ้™ฉ่ฏ„ไผฐ ===
  severity:
    cvss_score: float  # 0.0-10.0
    priority: "P0|P1|P2|P3"
    stride_types: ["T", "E"]  # ๅฏๅŒ…ๅซๅคšไธช STRIDE ็ฑปๅž‹

  # === ้ชŒ่ฏ็Šถๆ€ ===
  validation:
    status: "verified|theoretical|pending|excluded"
    poc_available: boolean
    poc_id: "POC-{Seq}"  # ๅฆ‚ๆœ‰ POC

่ฏฆ็ป†่ฎพ่ฎก: ่ง tmp_data/DATA-ARCHITECTURE-DESIGN.md

Phase Data Flow

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                              Phase Data Flow Architecture                                            โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                                                      โ”‚
โ”‚  Phase 1          Phase 2          Phase 3          Phase 4          Phase 5                        โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”          โ”Œโ”€โ”€โ”€โ”€โ”€โ”          โ”Œโ”€โ”€โ”€โ”€โ”€โ”          โ”Œโ”€โ”€โ”€โ”€โ”€โ”          โ”Œโ”€โ”€โ”€โ”€โ”€โ”                        โ”‚
โ”‚  โ”‚ P1  โ”‚โ”€findings1โ”€โ–ถโ”‚ P2  โ”‚โ”€findings2โ”€โ–ถโ”‚ P3  โ”‚โ”€findings3โ”€โ–ถโ”‚ P4  โ”‚โ”€findings4โ”€โ–ถโ”‚ P5  โ”‚                        โ”‚
โ”‚  โ””โ”€โ”€โ”ฌโ”€โ”€โ”˜          โ””โ”€โ”€โ”ฌโ”€โ”€โ”˜          โ””โ”€โ”€โ”ฌโ”€โ”€โ”˜          โ””โ”€โ”€โ”ฌโ”€โ”€โ”˜          โ””โ”€โ”€โ”ฌโ”€โ”€โ”˜                        โ”‚
โ”‚     โ”‚                โ–ผ                โ–ผ                โ”‚                โ”‚                           โ”‚
โ”‚     โ”‚           security-        security-             โ”‚                โ”‚                           โ”‚
โ”‚     โ”‚           design.yaml      design.yaml           โ”‚                โ”‚                           โ”‚
โ”‚     โ”‚                                                  โ–ผ                โ–ผ                           โ”‚
โ”‚     โ”‚                                          control-set-*.md    CWE โ†’ CAPEC                     โ”‚
โ”‚     โ”‚                                          reference-set-*.md                                   โ”‚
โ”‚     โ–ผ                                                                   โ”‚                           โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”        โ”‚
โ”‚  โ”‚                              Phase 6: Risk Validation                                  โ”‚        โ”‚
โ”‚  โ”‚  INPUT: findings_1 + findings_2 + findings_3 + findings_4 + findings_5                โ”‚        โ”‚
โ”‚  โ”‚         (ALL issues consolidated and deduplicated)                                     โ”‚        โ”‚
โ”‚  โ”‚  KNOWLEDGE: CAPEC โ†’ ATT&CK โ†’ CVE/KEV + WSTG + MASTG                                   โ”‚        โ”‚
โ”‚  โ”‚  OUTPUT: validated_risks                                                              โ”‚        โ”‚
โ”‚  โ”‚    โ”œโ”€โ”€ risk_summary (counts, categorization)                                          โ”‚        โ”‚
โ”‚  โ”‚    โ”œโ”€โ”€ risk_details (per-item: location, analysis, root cause, test cases)           โ”‚        โ”‚
โ”‚  โ”‚    โ””โ”€โ”€ attack_paths (chains, step-by-step with commands/POC)                          โ”‚        โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ”‚
โ”‚                                             โ”‚                                                       โ”‚
โ”‚                                             โ–ผ                                                       โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”        โ”‚
โ”‚  โ”‚                              Phase 7: Mitigation Planning                              โ”‚        โ”‚
โ”‚  โ”‚  INPUT: validated_risks (complete Phase 6 output)                                     โ”‚        โ”‚
โ”‚  โ”‚  KNOWLEDGE: Control Sets + OWASP References + CWE Mitigations + ASVS                  โ”‚        โ”‚
โ”‚  โ”‚  OUTPUT: mitigation_plan (per-risk: immediate, short-term, long-term)                 โ”‚        โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ”‚
โ”‚                                             โ”‚                                                       โ”‚
โ”‚                                             โ–ผ                                                       โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”        โ”‚
โ”‚  โ”‚                              Phase 8: Report Generation                                โ”‚        โ”‚
โ”‚  โ”‚  INPUT: ALL phase outputs (findings_1 โ†’ mitigation_plan)                              โ”‚        โ”‚
โ”‚  โ”‚  KNOWLEDGE: Compliance Frameworks + ASVS                                              โ”‚        โ”‚
โ”‚  โ”‚  CRITICAL: Must include COMPLETE Phase 6 and Phase 7 outputs (no omission)           โ”‚        โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ”‚
โ”‚                                                                                                      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Phase Context Protocol

Core Principle: Each phase must explicitly declare Input Context and Output Context for cross-phase data continuity.

Phase Context Name Key Fields
P1โ†’P2 project_context project_type, modules[], integrations[], security_design{}
P2โ†’P3 dfd_elements elements[{id,type,name}], flows[{id,source,target,data}], dfd_diagram
P3โ†’P4 boundary_context boundaries[], interfaces[], data_nodes[], cross_boundary_flows[]
P4โ†’P5 security_gaps gaps[{domain,severity,description}], design_matrix{}
P5โ†’P6 threat_inventory threats[{id,element_id,stride,cwe,priority}]
P6โ†’P7 validated_risks risk_summary{}, risk_details[], attack_paths[]
P7โ†’P8 mitigation_plan mitigations[{risk_id,measures,implementation}], roadmap{}

Element ID Naming Convention

DFD Element ID Format (Phase 2 generates, subsequent phases must reference):

Element Type Prefix Format Example
External Interactor EI EI{NN} EI01, EI02
Process P P{NN} P01, P02, P03
Data Store DS DS{NN} DS01, DS02
Data Flow DF DF{NN} DF01, DF02
Trust Boundary TB TB{NN} TB01, TB02

Threat ID Format (Phase 5 generates):

T-{STRIDE}-{ElementID}-{Seq}
  • STRIDE: S/T/R/I/D/E (single letter)
  • ElementID: From P2 element ID
  • Seq: Three-digit sequence (001-999)
  • Example: T-S-P01-001 (First Spoofing threat for Process 01)

Phase Details

Phase 1: Project Understanding

1.1 Core Analysis Goal

Goal: Comprehensively understand project architecture, functional modules, tech stack, and security design decisions.
This is an exploratory task where LLM needs to understand overall project structure through code reading.

1.2 Input Context

Input: Project path/codebase

1.3 Knowledge Reference

Security Principles: assets/knowledge/security-principles.yaml

  • Evaluate if project embodies core security principles (DID, LP, ZT)
  • Identify obvious security design flaws

1.4 Script Support

# Get project structure with type detection
python $SKILL_PATH/scripts/list_files.py <path> --categorize --detect-type --pretty

1.5 Output Context

โ†’ P2: project_context {project_type, modules[], integrations[], security_design{}}

Required Output:

## Project Summary
- Project Type: [Web/API/Microservice/AI-LLM/Hybrid]
- Primary Language: [Language]
- Framework: [Frameworks]

## Functional Description
- Core Functions: [...]
- User Roles: [...]

## Major Modules
| Module | Responsibility | Location |
|--------|---------------|----------|

## Key Security Design
- Authentication: [...]
- Data Storage: [...]
- External Integrations: [...]

Scenario Confirmation (based on Phase 1 analysis):

Scenario Type Trigger Condition Enable Extension
Standard Web/API No AI/No Cloud-Native Standard STRIDE flow
AI/LLM Application Model calls/RAG/Prompt processing detected --all-llm, --ai-component
Cloud-Native App AWS/Azure/GCP/K8s detected --cloud {provider}
Microservices Multi-service/Docker/K8s Cross-service threat analysis
Hybrid Multiple features Combined extensions

Checkpoint: Summarize and reflect before Phase 2.


Phase 2: Call Flow & DFD

2.1 Core Analysis Goal

Goal: Build Data Flow Diagram (DFD), trace complete data path from entry to storage.
This is a constructive task where LLM needs to understand code call relationships and visualize data flow.

2.2 Input Context

โ† P1: project_context

2.3 Knowledge Reference

Security Principles: assets/knowledge/security-principles.yaml

  • Apply Complete Mediation (CM) to identify access checkpoints
  • Apply Input Validation (IV) to mark validation points

Security Design: assets/knowledge/security-design.yaml

  • Reference 16 security domains to identify security-relevant DFD elements

2.4 Output Context

โ†’ P3: dfd_elements {elements[], flows[], dfd_diagram, dfd_issues[]}

Output Requirements:

  • ASCII DFD diagram (in body)
  • Mermaid DFD source (in appendix)
  • Element inventory table

Checkpoint: Summarize and reflect before Phase 3.


Phase 3: Trust Boundaries

3.1 Core Analysis Goal

Goal: Based on DFD, identify trust boundaries, key interfaces, and data nodes; evaluate security posture.
This is an evaluative task where LLM needs to identify security boundaries and assess cross-boundary risks.

3.2 Input Context

โ† P1/P2: project_context, dfd_elements

3.3 Knowledge Reference

Security Principles: Apply ZT, SOD, LP principles
Security Design: assets/knowledge/security-design.yaml - AUTHN, AUTHZ, API domains

3.4 Output Context

โ†’ P4: boundary_context {boundaries[], interfaces[], data_nodes[], boundary_issues[]}

Checkpoint: Summarize and reflect before Phase 4.


Phase 4: Security Design Assessment

4.1 Core Analysis Goal

Goal: Evaluate project's design maturity across all security domains, identify gaps.
This is an evaluative task requiring LLM to understand code security implementation and compare with best practices.

4.2 Input Context

โ† P1/P2/P3: All cumulative findings

4.3 Knowledge Reference (Progressive Loading)

  1. Load security-design.yaml - Get all 16 domains with core requirements
  2. For each relevant domain, load corresponding control-set-*.md
  3. When specific implementation details needed, load reference-set-*.md

Query Commands:

# Get security domain details
$SKILL_PATH/kb --control authentication
$SKILL_PATH/kb --stride-controls S

4.4 Output Context

โ†’ P5: security_gaps {gaps[], design_matrix{}}

Required Output:

## Security Design Assessment Matrix
| Domain | Current Implementation | Assessment | Gap | Risk Level | KB Reference |
|--------|----------------------|------------|-----|------------|--------------|
| AUTHN | [...] | Yes/No/Partial | [...] | High/Medium/Low | control-set-01 |

Checkpoint: Summarize and reflect before Phase 5.


Phase 5: STRIDE Analysis

5.1 Core Analysis Goal

Goal: Apply STRIDE method to DFD elements, generate complete threat inventory.
This is an enumerative task where LLM systematically identifies potential threats for each element.

5.2 Input Context

โ† P2/P4: dfd_elements, security_gaps

5.3 Knowledge Reference

Threat Pattern Set: CWE โ†’ CAPEC mapping

Query Commands:

$SKILL_PATH/kb --stride spoofing           # STRIDE category details
$SKILL_PATH/kb --full-chain CWE-XXX        # Complete chain: STRIDEโ†’CWEโ†’CAPECโ†’ATT&CK
$SKILL_PATH/kb --all-llm                    # LLM threats (AI components)

5.4 STRIDE per Element Matrix

Element Type Applicable STRIDE
Process S, T, R, I, D, E (all 6)
Data Store T, R, I, D
Data Flow T, I, D
External Entity (as source) S, R

5.5 Output Context

โ†’ P6: threat_inventory {threats[{id, element_id, stride, cwe, priority}]}

Checkpoint: Summarize and reflect before Phase 6.


Phase 6: Risk Validation

๐Ÿ“„ Detailed Workflow: See @VALIDATION.md for complete Phase 6 workflow, consolidation process, and POC templates.

6.1 Core Analysis Goal

Goal: Consolidate ALL findings from P1-P5, perform deep validation, design attack paths and POC.
This is a verification task where LLM thinks from attacker's perspective.

6.2 Input Context

โ† ALL P1-P5: findings_1 + findings_2 + findings_3 + findings_4 + findings_5

CRITICAL: Phase 6 must consolidate ALL previous findings, not just Phase 5 threats.

6.3 Knowledge Reference

Threat Pattern Set: CAPEC โ†’ ATT&CK โ†’ CVE/KEV
Verification Set: WSTG + MASTG (test generation)

Query Commands:

# Attack path analysis
$SKILL_PATH/kb --capec CAPEC-XXX --attack-chain
$SKILL_PATH/kb --attack-technique TXXX
$SKILL_PATH/kb --check-kev CVE-XXXX

# Verification tests
$SKILL_PATH/kb --stride-tests S              # STRIDE category tests
$SKILL_PATH/kb --cwe-tests CWE-89            # CWE-specific tests
$SKILL_PATH/kb --wstg-category ATHN          # WSTG tests by category

6.4 Output Structure (5 Parts)

Schema Reference: assets/schemas/risk-detail.schema.md defines complete risk detail format.
Template Reference: assets/templates/RISK-ASSESSMENT-REPORT.template.md Section 5-6 for output format.

Priority Mapping (from schema):

CVSS ่ฏ„ๅˆ† ไธฅ้‡็จ‹ๅบฆ ไผ˜ๅ…ˆ็บง ่กŒๅŠจ่ฆๆฑ‚
9.0 - 10.0 Critical P0 ็ซ‹ๅณไฟฎๅค
7.0 - 8.9 High P1 ็ดงๆ€ฅๅค„็† (24h)
4.0 - 6.9 Medium P2 ้ซ˜ไผ˜ๅ…ˆ็บง (7d)
0.1 - 3.9 Low P3 ่ฎกๅˆ’ไธญ (30d)

POC Verification Status Types:

็Šถๆ€ๆ ‡่ฏ† ๅซไน‰ ๅˆคๅฎšๆ ‡ๅ‡†
โœ… ๅทฒ้ชŒ่ฏ POC ๆ‰ง่กŒๆˆๅŠŸ ๆˆๅŠŸๅค็Žฐๆ”ปๅ‡ป่กŒไธบๅนถ่Žทๅพ—้ข„ๆœŸ็ป“ๆžœ
โš ๏ธ ้œ€้ชŒ่ฏ ็†่ฎบๅฏ่กŒไฝ†้œ€ๆ‰‹ๅŠจ้ชŒ่ฏ ้œ€่ฆ็‰นๅฎš็Žฏๅขƒๆˆ–ๆƒ้™ๆ‰่ƒฝ้ชŒ่ฏ
๐Ÿ“‹ ็†่ฎบๅฏ่กŒ ๅŸบไบŽไปฃ็ ๅˆ†ๆžๆŽจๅฏผ ไปฃ็ ่ทฏๅพ„ๅญ˜ๅœจไฝ†ๆœชๅฎž้™…ๆต‹่ฏ•
โŒ ๅทฒๆŽ’้™ค ้ชŒ่ฏๅŽ็กฎ่ฎคไธๅฏๅˆฉ็”จ ๅญ˜ๅœจ็ผ“่งฃๆŽชๆ–ฝๆˆ–ๆกไปถไธๆปก่ถณ
validated_risks:
  # Part 1: Risk Summary (้ชŒ่ฏ่ฆ†็›–็ปŸ่ฎก)
  risk_summary:
    total_identified: N
    total_verified: N                           # โœ… ๅทฒ้ชŒ่ฏ
    total_pending: N                            # โš ๏ธ ้œ€้ชŒ่ฏ
    total_theoretical: N                        # ๐Ÿ“‹ ็†่ฎบๅฏ่กŒ
    total_excluded: N                           # โŒ ๅทฒๆŽ’้™ค
    verification_rate: "N%"
    risk_by_severity: {critical: N, high: N, medium: N, low: N}
    risk_by_stride: {S: N, T: N, R: N, I: N, D: N, E: N}

  # Part 2: POC Details (ๆฏไธช Critical/High ๅจ่ƒไธ€ไธชๅฎŒๆ•ดๅ—)
  poc_details:
    - poc_id: "POC-001"                         # Format: POC-{SEQ:03d}
      threat_ref: "T-S-P01-001"                 # ๅ…ณ่”ๅจ่ƒID
      stride_type: "S"                          # STRIDE็ฑปๅž‹
      verification_status: "verified"           # verified|pending|theoretical|excluded
      exploitation_difficulty: "medium"         # low|medium|high
      prerequisites:                            # ๅ‰็ฝฎๆกไปถ
        - "ๆœ‰ๆ•ˆ็š„็”จๆˆทไผš่ฏ"
        - "็Ÿฅ้“็›ฎๆ ‡็”จๆˆทID"
      vulnerability_location:
        file_path: "src/api/auth.py"
        function_name: "verify_token"
        line_number: 45
      vulnerable_code: |                        # ๆผๆดžไปฃ็ ็‰‡ๆฎต
        def verify_token(token):
            # ็ผบๅฐ‘็ญพๅ้ชŒ่ฏ
            return jwt.decode(token, options={"verify_signature": False})
      exploitation_steps:                       # ๅˆฉ็”จๆญฅ้ชค
        - "ๆž„้€ ๆถๆ„JWT Token"
        - "ๅ‘้€่ฏทๆฑ‚ๅˆฐ่ฎค่ฏ็ซฏ็‚น"
        - "็ป•่ฟ‡่บซไปฝ้ชŒ่ฏ"
      poc_code: |                               # POCไปฃ็  (ๅฎŒๆ•ดๅฏๆ‰ง่กŒ)
        import jwt
        # ๆž„้€ ๆถๆ„token
        malicious_token = jwt.encode({"user_id": "admin"}, "any_key", algorithm="HS256")
        # ๅ‘้€่ฏทๆฑ‚...
      expected_result: |                        # ้ข„ๆœŸ็ป“ๆžœ
        {"status": "authenticated", "user": "admin"}
      verification_log: "..."                   # ้ชŒ่ฏๆ—ฅๅฟ—/ๆˆชๅ›พ
      risk_assessment:
        complexity: "medium"
        attack_vector: "network"
        impact_scope: "user_data"
        data_sensitivity: "high"

  # Part 3: Risk Details (per item) - See assets/schemas/risk-detail.schema.md
  risk_details:
    - risk_id: "VR-001"                         # Format: VR-{SEQ:03d}
      original_refs: ["T-S-P01-001", "SD-001"]  # From multiple phases
      priority: "P1"                             # P0/P1/P2/P3
      location: {files: [], elements: [], trust_boundary: ""}
      detailed_analysis: {...}
      root_cause: {...}
      related_cwe: "CWE-XXX"                     # Required field
      related_poc: "POC-001"                     # Link to POC detail
      validation:
        test_cases: []
        poc_available: true
        cvss_score: 8.8
        verification_status: "verified"

  # Part 4: Attack Path Feasibility Matrix (ๅฏ่กŒๆ€ง่ฏ„ๅˆ†)
  attack_path_matrix:
    - path_id: "AP-001"
      path_name: "่ฎค่ฏ็ป•่ฟ‡โ†’ๆ•ฐๆฎๅบ“่ฎฟ้—ฎ"
      entry_point: "API Gateway"
      key_nodes: ["Auth Service"]
      final_target: "ๆ•ฐๆฎๅบ“"
      feasibility_score: 8.5                    # 0.0-10.0
      detection_difficulty: "low"               # low|medium|high
      priority_fix: true

  # Part 5: Attack Chains (ๅฎŒๆ•ดๆ”ปๅ‡ป้“พๅˆ†ๆž)
  attack_chains:
    - chain_id: "AC-001"
      chain_name: "ๆƒ้™ๆๅ‡ๆ”ปๅ‡ป้“พ"
      entry_point: "ๅ…ฌๅ…ฑAPI็ซฏ็‚น"
      target: "็ฎก็†ๅ‘˜ๆƒ้™"
      impact_scope: "ๅฎŒๅ…จ็ณป็ปŸๆŽงๅˆถ"
      difficulty: "medium"
      related_threats: ["T-E-P01-001", "T-S-P02-001"]
      steps:
        - step: 1
          title: "ๅˆๅง‹่ฎฟ้—ฎ"
          source: "ๆ”ปๅ‡ป่€…"
          target: "API็ฝ‘ๅ…ณ"
          action: "ๅ‘้€ๆถๆ„่ฏทๆฑ‚"
          code_location: "api/routes.py:120"
          data_change: "่Žทๅพ—ไผš่ฏtoken"
        - step: 2
          title: "ๆƒ้™ๆๅ‡"
          source: "API็ฝ‘ๅ…ณ"
          target: "่ฎค่ฏๆœๅŠก"
          action: "ๅˆฉ็”จJWTๆผๆดž"
          code_location: "auth/jwt.py:45"
          data_change: "่Žทๅพ—็ฎก็†ๅ‘˜่ง’่‰ฒ"
      # ASCII ๆ”ปๅ‡ป้“พๅ›พ (ๅฟ…้กปๅœจๆŠฅๅ‘Šไธญๅฑ•็คบ)
      attack_flow_diagram: |
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ”‚                     ๆ”ปๅ‡ป้“พ: ๆƒ้™ๆๅ‡ๆ”ปๅ‡ป                         โ”‚
        โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
        โ”‚  Step 1: ๅˆๅง‹่ฎฟ้—ฎ                                               โ”‚
        โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
        โ”‚  โ”‚  ๆ”ปๅ‡ป่€… โ”€โ”€โ†’ API็ฝ‘ๅ…ณ                                       โ”‚   โ”‚
        โ”‚  โ”‚  ๅŠจไฝœ: ๅ‘้€ๆถๆ„่ฏทๆฑ‚                                        โ”‚   โ”‚
        โ”‚  โ”‚  ไปฃ็ ไฝ็ฝฎ: api/routes.py:120                              โ”‚   โ”‚
        โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
        โ”‚                              โ”‚                                   โ”‚
        โ”‚                              โ–ผ                                   โ”‚
        โ”‚  Step 2: ๆƒ้™ๆๅ‡                                               โ”‚
        โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
        โ”‚  โ”‚  API็ฝ‘ๅ…ณ โ”€โ”€โ†’ ่ฎค่ฏๆœๅŠก                                     โ”‚   โ”‚
        โ”‚  โ”‚  ๅŠจไฝœ: ๅˆฉ็”จJWTๆผๆดž่Žทๅพ—็ฎก็†ๅ‘˜่ง’่‰ฒ                           โ”‚   โ”‚
        โ”‚  โ”‚  ไปฃ็ ไฝ็ฝฎ: auth/jwt.py:45                                 โ”‚   โ”‚
        โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
        โ”‚                              โ”‚                                   โ”‚
        โ”‚                              โ–ผ                                   โ”‚
        โ”‚  ็ป“ๆžœ: ่Žทๅพ—็ฎก็†ๅ‘˜ๆƒ้™๏ผŒๅฎŒๅ…จ็ณป็ปŸๆŽงๅˆถ                              โ”‚
        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
      prerequisites:
        - "็ฝ‘็ปœ่ฎฟ้—ฎๆƒ้™"
        - "ๅŸบ็ก€็”จๆˆท่ดฆๆˆท"
      exploitation_commands: |
        # Step 1: ่Žทๅ–ๅˆๅง‹token
        curl -X POST https://target/api/login -d '{"user":"test","pass":"test"}'
        # Step 2: ๆž„้€ ๆๆƒtoken
        python3 jwt_exploit.py --token $TOKEN --role admin
      ioc_indicators:
        - "ๅผ‚ๅธธ็š„JWT token็ป“ๆž„"
        - "็Ÿญๆ—ถ้—ดๅ†…่ง’่‰ฒๅ˜ๆ›ด"
      defense_recommendations:
        - cutpoint: "Step 1"
          recommendation: "ๅฎžๆ–ฝ่ฏทๆฑ‚้€Ÿ็އ้™ๅˆถๅ’Œๅผ‚ๅธธๆฃ€ๆต‹"
        - cutpoint: "Step 2"
          recommendation: "ๅฏ็”จJWT็ญพๅ้ชŒ่ฏ๏ผŒไฝฟ็”จๅผบๅฏ†้’ฅ"

6.5 Output Quality Requirements

CRITICAL: Phase 6 output MUST include:

  1. POC Details: Every Critical/High threat must have a complete POC block with executable code
  2. Attack Chains: At least one detailed attack chain diagram per high-risk attack path
  3. Feasibility Matrix: All attack paths must have feasibility scores (0.0-10.0)
  4. ASCII Diagrams: Attack chains must include ASCII box diagrams in attack_flow_diagram field

Checkpoint: Summarize and reflect before Phase 7.


Phase 7: Mitigation Planning

๐Ÿ“„ Detailed Workflow: See @REPORT.md for complete Phase 7-8 workflow with content aggregation instructions.

7.1 Core Analysis Goal

Goal: Design specific mitigation measures and implementation plans for each validated risk.
This is a prescriptive task requiring LLM to design feasible security controls for the tech stack.

7.2 Input Context

โ† P6: validated_risks (complete Phase 6 output)

7.3 Knowledge Reference

Security Control Set: Control Sets + OWASP References
Threat Pattern Set: CWE Mitigations
Verification Set: ASVS (requirement verification)

Query Commands:

$SKILL_PATH/kb --cwe CWE-XXX --mitigations    # CWE mitigations
$SKILL_PATH/kb --control authentication        # Security controls
$SKILL_PATH/kb --asvs-level L2                 # ASVS requirements
$SKILL_PATH/kb --asvs-chapter V4               # ASVS by chapter

7.4 Output Context

โ†’ P8: mitigation_plan {mitigations[], roadmap{}}

Required Output for Each Risk:

### Mitigation Measures
| Risk ID | CWE | Recommended Measure | Implementation | Priority | Effort |
|---------|-----|---------------------|----------------|----------|--------|
| VR-XXX | CWE-XXX | [Measure] | [Code/Config] | Critical/High/Medium/Low | [Est.] |

Checkpoint: Summarize and reflect before Phase 8.


Phase 8: Comprehensive Report

๐Ÿ“„ Detailed Workflow: See @REPORT.md for complete Phase 8 workflow with mandatory content aggregation rules.
โš ๏ธ CRITICAL: Phase 8 MUST read all phase files and copy content completely โ€” do NOT summarize from memory!

8.1 Core Analysis Goal

Goal: Synthesize all phase outputs into complete threat model report.
This is a comprehensive task where LLM integrates all 7 phases of analysis.

8.2 Input Context

โ† P1-P7: ALL preceding phase outputs

8.3 Knowledge Reference

Compliance Frameworks + ASVS (compliance verification)

$SKILL_PATH/kb --compliance nist-csf
$SKILL_PATH/kb --asvs-level L2 --chapter V1

8.4 โš ๏ธ MANDATORY: Output Directory Setup

ๅœจ็”Ÿๆˆไปปไฝ•ๆŠฅๅ‘Šไน‹ๅ‰๏ผŒๅฟ…้กปๆ‰ง่กŒไปฅไธ‹ๆญฅ้ชค:

  1. ็กฎๅฎš PROJECT ๅ็งฐ: ไปŽ้กน็›ฎๅๆๅ–๏ผŒ่ฝฌๆขไธบๅคงๅ†™

    • ็คบไพ‹: open-webui โ†’ OPEN-WEBUI
    • ๆ ผๅผ: ^[A-Z][A-Z0-9-]{0,29}$
  2. ๅˆ›ๅปบ่พ“ๅ‡บ็›ฎๅฝ•:

    mkdir -p {PROJECT_ROOT}/Risk_Assessment_Report/
  3. ๆ‰€ๆœ‰ๆŠฅๅ‘Šๅฟ…้กป่พ“ๅ‡บๅˆฐๆญค็›ฎๅฝ•:

    • ไธปๆŠฅๅ‘Š: Risk_Assessment_Report/{PROJECT}-RISK-ASSESSMENT-REPORT.md
    • ้ฃŽ้™ฉๆธ…ๅ•: Risk_Assessment_Report/{PROJECT}-RISK-INVENTORY.md
    • ็ผ“่งฃๆŽชๆ–ฝ: Risk_Assessment_Report/{PROJECT}-MITIGATION-MEASURES.md

โš ๏ธ ็ฆๆญข: ็›ดๆŽฅๅœจ้กน็›ฎๆ น็›ฎๅฝ•ๅˆ›ๅปบๆŠฅๅ‘Šๆ–‡ไปถ๏ผ

8.5 Report Structure (9 Sections + Appendix)

CRITICAL: Sections 5, 6, and 8 must include COMPLETE Phase 6 and Phase 7 outputs without omission.

Template Reference: assets/templates/RISK-ASSESSMENT-REPORT.template.md

# {PROJECT}-RISK-ASSESSMENT-REPORT.md

## 1. ๆ‰ง่กŒๆ‘˜่ฆ (Executive Summary)
- ๅจ่ƒ็ปŸ่ฎกใ€STRIDEๅˆ†ๅธƒใ€ๅ…ณ้”ฎๅ‘็Žฐใ€็ซ‹ๅณ่กŒๅŠจๅปบ่ฎฎ

## 2. ็ณป็ปŸๆžถๆž„ๆฆ‚่งˆ (System Architecture)
- ็ป„ไปถๆ‹“ๆ‰‘ASCIIๅ›พใ€ๆ•ฐๆฎๆตๅ›พDFDใ€ไฟกไปป่พน็•Œใ€ๆŠ€ๆœฏๆ ˆ
- (from findings_1, findings_2, findings_3)

## 3. ๅฎ‰ๅ…จๅŠŸ่ƒฝ่ฎพ่ฎก่ฏ„ไผฐ (Security Design Assessment)
- 9ๅฎ‰ๅ…จๅŸŸ่ฏ„ไผฐ็Ÿฉ้˜ตใ€ๅ…ณ้”ฎๅฎ‰ๅ…จๅ‘็Žฐ่ฏฆๆƒ…
- (from findings_4)

## 4. STRIDE ๅจ่ƒๅˆ†ๆž (STRIDE Threat Analysis)
- ๅจ่ƒๆฑ‡ๆ€ป่กจใ€ๆŒ‰STRIDEๅˆ†็ฑป่กจใ€ๅจ่ƒ่ฏฆ็ป†ๅˆ†ๆž
- (from findings_5)

## 5. ้ฃŽ้™ฉ้ชŒ่ฏไธŽPOC่ฎพ่ฎก (Risk Validation & POC) โ† CRITICAL
- POC้ชŒ่ฏๆ–นๆณ•่ฎบใ€้ชŒ่ฏ่ฆ†็›–็ปŸ่ฎกใ€POC้ชŒ่ฏ่ฏฆๆƒ…ใ€POCๆฑ‡ๆ€ป่กจ
- ๆฏไธชCritical/Highๅจ่ƒๅฟ…้กปๆœ‰ๅฎŒๆ•ดPOCไปฃ็ ๅ—
- (from validated_risks.poc_details)

## 6. ๆ”ปๅ‡ป่ทฏๅพ„ๅˆ†ๆž (Attack Path Analysis) โ† CRITICAL
- ๆ”ปๅ‡ป่ทฏๅพ„ๅฏ่กŒๆ€ง็Ÿฉ้˜ตใ€ๆ”ปๅ‡ป้“พ่ฏฆ็ป†ๅˆ†ๆžใ€ๆ”ปๅ‡ป้ข็ƒญๅŠ›ๅ›พใ€ไผ˜ๅ…ˆ็บงๆŽ’ๅบ
- ๆฏๆก้ซ˜ๅฑๆ”ปๅ‡ป่ทฏๅพ„ๅฟ…้กปๆœ‰ASCIIๆ”ปๅ‡ป้“พๅ›พ
- (from validated_risks.attack_chains, validated_risks.attack_path_matrix)

## 7. ๅจ่ƒไผ˜ๅ…ˆ็บง็Ÿฉ้˜ต (Threat Priority Matrix)
- ้ฃŽ้™ฉ่ฏ„ไผฐ็Ÿฉ้˜ตใ€ๅจ่ƒๅˆ†ๅธƒ็Ÿฉ้˜ตใ€ๆ”ปๅ‡ป้ข็ƒญๅŠ›ๅ›พ

## 8. ็ผ“่งฃๆŽชๆ–ฝๅปบ่ฎฎ (Mitigation Recommendations) โ† CRITICAL
- P0/P1/P2ๅˆ†็บงๆŽชๆ–ฝใ€ๅฎžๆ–ฝ่ทฏ็บฟๅ›พใ€้˜ฒๅพก็บตๆทฑๆžถๆž„
- (from mitigation_plan)

## 9. ๅˆ่ง„ๆ€งๆ˜ ๅฐ„ (Compliance Mapping)
- OWASP Top 10ๆ˜ ๅฐ„ใ€OWASP LLM Top 10ๆ˜ ๅฐ„(ๅฆ‚้€‚็”จ)

## ้™„ๅฝ• (Appendices)
- A: DFDๅ…ƒ็ด ๅฎŒๆ•ดๆธ…ๅ•
- B: Mermaid DFDๆบ็ 
- C: ๅจ่ƒๅฎŒๆ•ดๆธ…ๅ•
- D: ็Ÿฅ่ฏ†ๅบ“ๆŸฅ่ฏข่ฎฐๅฝ•
- E: ๅ‚่€ƒ่ต„ๆ–™

8.6 Output Files

่พ“ๅ‡บ็›ฎๅฝ•: {PROJECT_ROOT}/Risk_Assessment_Report/

ๅฟ…้œ€ๆŠฅๅ‘Š (ๅง‹็ปˆ็”Ÿๆˆ):

ๅบๅท ๆŠฅๅ‘Šๆ–‡ไปถ ่ฏดๆ˜Ž
1 {PROJECT}-RISK-ASSESSMENT-REPORT.md ้ฃŽ้™ฉ่ฏ„ไผฐๆŠฅๅ‘Š (ไธปๆŠฅๅ‘Š)
2 {PROJECT}-RISK-INVENTORY.md ้ฃŽ้™ฉๆธ…ๅ•
3 {PROJECT}-MITIGATION-MEASURES.md ็ผ“่งฃๆŽชๆ–ฝ
4 {PROJECT}-PENETRATION-TEST-PLAN.md ๆธ—้€ๆต‹่ฏ•ๆ–นๆกˆ

8.7 โš ๏ธ MANDATORY: Phase Output Publication

ๅœจ็”Ÿๆˆๆ‰€ๆœ‰ๆŠฅๅ‘ŠๅŽ๏ผŒๅฟ…้กปๆ‰ง่กŒ้˜ถๆฎต่ฟ‡็จ‹ๆ–‡ๆกฃๅ‘ๅธƒ:

ๅฐ† .phase_working/ ไธญ็š„้˜ถๆฎตไบง็‰ฉๅคๅˆถๅˆฐ Risk_Assessment_Report/ ็›ฎๅฝ•๏ผŒไฟ็•™่‹ฑๆ–‡ๆ–‡ไปถๅ:

phase_output_publication:
  source_dir: ".phase_working/"
  target_dir: "Risk_Assessment_Report/"
  files:  # ็›ดๆŽฅๅคๅˆถ๏ผŒไฟ็•™ๅŽŸๆ–‡ไปถๅ
    - P1-PROJECT-UNDERSTANDING.md    # Phase 1 ้กน็›ฎ็†่งฃ
    - P2-DFD-ANALYSIS.md             # Phase 2 DFDๅˆ†ๆž
    - P3-TRUST-BOUNDARY.md           # Phase 3 ไฟกไปป่พน็•Œ
    - P4-SECURITY-DESIGN-REVIEW.md   # Phase 4 ๅฎ‰ๅ…จ่ฎพ่ฎก่ฏ„ไผฐ
    - P5-STRIDE-THREATS.md           # Phase 5 STRIDEๅจ่ƒๅˆ†ๆž
    - P6-RISK-VALIDATION.md          # Phase 6 ้ฃŽ้™ฉ้ชŒ่ฏ

ๆ‰ง่กŒๅ‘ฝไปค (็คบไพ‹):

# ๅคๅˆถ้˜ถๆฎต่ฟ‡็จ‹ๆ–‡ๆกฃๅˆฐๆŠฅๅ‘Š็›ฎๅฝ• (ไฟ็•™่‹ฑๆ–‡ๅ)
cp .phase_working/P1-PROJECT-UNDERSTANDING.md Risk_Assessment_Report/
cp .phase_working/P2-DFD-ANALYSIS.md Risk_Assessment_Report/
cp .phase_working/P3-TRUST-BOUNDARY.md Risk_Assessment_Report/
cp .phase_working/P4-SECURITY-DESIGN-REVIEW.md Risk_Assessment_Report/
cp .phase_working/P5-STRIDE-THREATS.md Risk_Assessment_Report/
cp .phase_working/P6-RISK-VALIDATION.md Risk_Assessment_Report/

ไปทๅ€ผ่ฏดๆ˜Ž:

  • ้˜ถๆฎต่ฟ‡็จ‹ๆ–‡ๆกฃ่ฎฐๅฝ•ๅฎŒๆ•ดๅˆ†ๆž่ฟ‡็จ‹
  • ๆ”ฏๆŒๅฎก่ฎก่ฟฝๆบฏๅ’Œ่ดจ้‡้ชŒ่ฏ
  • ไพฟไบŽๅ›ข้˜Ÿ็†่งฃๅจ่ƒๅปบๆจกๆŽจๅฏผ้€ป่พ‘
  • ไฟ็•™่‹ฑๆ–‡ๅ็กฎไฟๅ‘ฝๅ่ง„่Œƒไธ€่‡ดๆ€ง

Scripts Reference

Script Purpose Key Commands
list_files.py Phase 1: File listing --categorize, --detect-type
stride_matrix.py Phase 5: STRIDE matrix --element, --generate-id
unified_kb_query.py Phase 4-8: KB queries See below

unified_kb_query.py - Complete Parameter Reference

STRIDE Queries

--stride {spoofing|tampering|repudiation|information_disclosure|denial_of_service|elevation_of_privilege}
--all-stride                    # All STRIDE categories overview
--element {process|data_store|data_flow|external_interactor}

CWE Queries

--cwe CWE-XXX                   # Query specific CWE
--cwe CWE-XXX --mitigations     # Include detailed mitigations
--full-chain CWE-XXX            # Complete chain: STRIDEโ†’CWEโ†’CAPECโ†’ATT&CK

CAPEC Attack Patterns

--capec CAPEC-XXX               # Query specific CAPEC
--capec CAPEC-XXX --attack-chain  # Include ATT&CK technique mapping

ATT&CK Techniques

--attack-technique TXXX         # Query ATT&CK technique
--attack-mitigation MXXX        # Query ATT&CK mitigation
--attack-search "keyword"       # Search ATT&CK techniques

CVE Queries

--cve CVE-XXXX-XXXXX            # Direct CVE query
--cve-for-cwe CWE-XXX           # CVEs by CWE
--cve-severity {CRITICAL|HIGH|MEDIUM|LOW}
--check-kev CVE-XXXX            # Check Known Exploited Vulnerability

Verification Set Queries (NEW)

--stride-tests {S|T|R|I|D|E}    # Get verification tests for STRIDE category
--cwe-tests CWE-XXX             # Get verification tests for CWE
--asvs-level {L1|L2|L3}         # Get ASVS requirements by level
--asvs-chapter {V1|V2|...}      # Get ASVS requirements by chapter
--wstg-category {ATHN|AUTHZ|...}  # Get WSTG tests by category

Cloud & LLM Extensions

--cloud {aws|azure|gcp|alibaba|tencent}
--category {compute|storage|database|networking|identity|serverless}
--llm LLM01                     # Query OWASP LLM Top 10
--all-llm                       # All OWASP LLM Top 10 threats
--ai-component {llm_inference_service|rag_retrieval|...}

Semantic Search

--semantic-search "query"       # Natural language search
--search-type {cwe|capec|all}

Knowledge Base Layers

Layer Source Content Use Case
L1: Curated YAML + Markdown Security domains, controls, references Phase 2-4
L2: Indexed SQLite (18MB) 974 CWEs, 615 CAPECs, 835 ATT&CK Phase 5-7
L3: Extension SQLite (304MB) 323K+ CVEs Phase 6 CVE lookup
L4: Live NVD/KEV API Real-time CVE/KEV Exploit context
L5: Verification SQLite WSTG, MASTG, ASVS Phase 6-8

Parallel Sub-Agent Pattern

For Phases 5/6/7 with multiple risks:

Main Agent                    Sub-Agents (Parallel)
    โ”‚                         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚โ”€โ”€โ–บ Risk 1 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ Agent 1 โ”€โ”€โ–บ KB Query โ”€โ”€โ–บ Result 1
    โ”‚                         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
    โ”‚                         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚โ”€โ”€โ–บ Risk 2 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ Agent 2 โ”€โ”€โ–บ KB Query โ”€โ”€โ–บ Result 2
    โ”‚                         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
    โ”‚                         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚โ”€โ”€โ–บ Risk N โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ Agent N โ”€โ”€โ–บ KB Query โ”€โ”€โ–บ Result N
    โ”‚                         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
    โ”‚
    โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Aggregate Results โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

Large Project Handling

Scale File Count Module Count Strategy
Small <50 <5 Standard 8-phase analysis
Medium 50-200 5-15 Module-priority (key modules deep)
Large 200-500 15-30 Subsystem split + merge
Very Large >500 >30 Layered analysis + parallel sub-agents

Subsystem Threat ID: T-{STRIDE}-{SubsysID}-{ElementID}-{Seq}


Common Pitfalls

Pitfall Solution
Skipping phases Execute all 8 phases in order
Not using KB queries Use unified_kb_query.py for every risk
Generic mitigations Query CWE-specific mitigations from KB
Missing attack paths Use CAPEC + ATT&CK for verification
No reflection Summarize and reflect after each phase
Parallel phase execution Phases are strictly serial
Incomplete Phase 6 consolidation Must include ALL P1-P5 findings
Phase 8 omissions Must include COMPLETE P6 and P7 outputs

Reference Files

Workflow & Phase Details (load progressively):

  • @WORKFLOW.md - Phase 1-5 detailed workflow
  • @VALIDATION.md - Phase 6 (Risk Validation) complete workflow, consolidation process, POC templates
  • @REPORT.md - Phase 7-8 (Mitigation & Report) with mandatory content aggregation rules
  • EXAMPLES.md - Real-world threat modeling examples

Schemas (format specifications):

  • assets/schemas/risk-detail.schema.md - Risk detail format, priority mapping (P0-P3), required fields
  • assets/schemas/phase-risk-summary.schema.md - Phase output summary format (if exists)

Knowledge Base (query via scriptsโ€”do NOT load directly):

  • assets/knowledge/security_kb.sqlite - Core database
  • assets/knowledge/security_kb_extension.sqlite - CVE extension
  • assets/knowledge/*.yaml - Curated mappings
  • assets/knowledge/security-controls/*.md - Control sets
  • assets/knowledge/security-controls/references/*.md - OWASP references

Categories