Back to list
rjmurillo

threat-modeling

by rjmurillo

Multi-agent system for software development

5🍴 0📅 Jan 24, 2026

SKILL.md


name: threat-modeling description: Structured security analysis using OWASP Four-Question Framework and STRIDE methodology. Generates threat matrices with risk ratings, mitigations, and prioritization. Use for attack surface analysis, security architecture review, or when asking what can go wrong. license: MIT metadata: version: 1.0.0 model: claude-sonnet-4-5

Threat Modeling

Systematic identification, documentation, and mitigation of security threats.

Triggers

PhraseContext
threat modelStarting or updating a threat model
attack surface analysisIdentifying exposure points
security architecture reviewReviewing design for vulnerabilities
STRIDE analysisApplying STRIDE methodology
what can go wrongBrainstorming security concerns

Quick Reference

InputOutputDestination
Architecture diagram or descriptionThreat matrix with STRIDE categories.agents/security/threat-models/
Component listTrust boundary analysis.agents/security/threat-models/
Data flow descriptionData flow diagram threats.agents/security/threat-models/
Prior threat modelUpdated model with delta analysis.agents/security/threat-models/

Process Overview

                         OWASP Four-Question Framework
                         =============================

          Q1: What are we        Q2: What can         Q3: What do we      Q4: Did we do
          working on?            go wrong?            do about it?        a good job?
               |                      |                    |                   |
               v                      v                    v                   v
        +-----------+          +------------+        +-----------+       +----------+
        | Phase 1   |          | Phase 2    |        | Phase 3   |       | Phase 4  |
        | Scope &   |  ----->  | Threat     | -----> | Mitigation| ----> | Validate |
        | Decompose |          | Identify   |        | Strategy  |       | Model    |
        +-----------+          +------------+        +-----------+       +----------+
              |                      |                    |                   |
              v                      v                    v                   v
        Trust Boundaries       STRIDE Matrix         Prioritized         Threat Model
        Data Flows             Kill Chains           Mitigations         Document
        Assets                 Attack Trees          Risk Ratings

Phase 1: Scope and Decompose

OWASP Q1: What are we working on?

1.1 Define Scope

Determine what you are threat modeling:

Scope LevelExamplesTypical Depth
SprintSingle feature, API endpoint1-2 hours
ComponentAuth module, payment serviceHalf day
SystemEntire application1-2 days
EnterpriseMultiple systemsMulti-day workshop

Document scope in the threat model header:

## Scope

- **Subject**: [Feature/Component/System name]
- **Boundaries**: [What is IN scope and OUT of scope]
- **Stakeholders**: [Who requested, who will review]
- **Date**: [When analysis performed]
- **Version**: [Model version for tracking changes]

1.2 Create Architecture Model

Choose appropriate diagram type:

Diagram TypeBest ForTools
Data Flow Diagram (DFD)Most threat modelsMermaid, draw.io
Component DiagramService boundariesMermaid, PlantUML
Sequence DiagramAuth/data flowsMermaid
Deployment DiagramInfrastructure threatsMermaid

Required DFD Elements:

+----------+     HTTPS      +----------+     SQL       +----------+
| External | -------------> |  Process | ------------> |  Data    |
|  Entity  |                |          |               |  Store   |
+----------+                +----------+               +----------+
     |                           |
     |     Trust Boundary        |
     +---------------------------+
  • External Entities: Users, third-party systems (outside your control)
  • Processes: Code that transforms data (your application)
  • Data Stores: Databases, files, caches (where data persists)
  • Data Flows: Arrows showing data movement (labeled with protocol)
  • Trust Boundaries: Dashed lines showing privilege changes

1.3 Identify Assets

List what attackers want:

Asset CategoryExamples
DataPII, credentials, financial, health
ComputeCPU cycles, storage, network bandwidth
AccessAdmin privileges, API keys, tokens
ReputationBrand trust, user confidence
AvailabilityService uptime, response time

1.4 Map Trust Boundaries

Identify where privilege levels change:

  • Network boundaries (internet to internal)
  • Process boundaries (user to kernel)
  • Authentication boundaries (anonymous to authenticated)
  • Authorization boundaries (user to admin)

Phase 2: Threat Identification

OWASP Q2: What can go wrong?

2.1 Apply STRIDE per Element

For each element in your diagram, apply STRIDE:

CategoryDefinitionApplies ToExample Questions
SpoofingPretending to be someone elseExternal entities, data flowsCan an attacker impersonate a user?
TamperingModifying data or codeProcesses, data stores, data flowsCan data be modified in transit/at rest?
RepudiationDenying an actionProcessesCan users deny performing actions?
Info DisclosureExposing informationData stores, data flowsCan sensitive data leak?
Denial of ServiceMaking service unavailableProcesses, data storesCan resources be exhausted?
Elevation of PrivilegeGaining unauthorized accessProcessesCan users escalate privileges?

STRIDE Applicability Matrix:

Element TypeSTRIDE
External EntityX
ProcessXXXXXX
Data StoreXXX
Data FlowXXX

2.2 Build Threat Matrix

Use the generate script to create a structured matrix:

python .claude/skills/threat-modeling/scripts/generate_threat_matrix.py \
    --scope "Authentication Service" \
    --output .agents/security/threat-models/auth-threats.md

Manual Format:

## Threat Matrix

| ID | Element | STRIDE | Threat | Likelihood | Impact | Risk |
|----|---------|--------|--------|------------|--------|------|
| T001 | Login API | S | Credential stuffing | High | High | Critical |
| T002 | Session Store | T | Session fixation | Medium | High | High |
| T003 | Audit Log | R | Log tampering | Low | Medium | Medium |

2.3 Apply Attack Trees (Optional)

For complex threats, decompose with attack trees:

              [Steal User Data]
                    |
        +-----------+-----------+
        |                       |
   [SQL Injection]      [Compromised API Key]
        |                       |
   +----+----+             +----+----+
   |         |             |         |
[Error]  [Blind]      [Phishing]  [Git Leak]

2.4 Apply Kill Chains (Optional)

Map attacker progression for sophisticated threats:

PhaseAttacker ActionDetection Opportunity
ReconPort scanningNetwork monitoring
WeaponizeCraft exploitThreat intelligence
DeliverSend phishing emailEmail filtering
ExploitExecute payloadEndpoint detection
InstallPersist accessFile integrity monitoring
CommandEstablish C2Network anomaly detection
ActionExfiltrate dataDLP, egress monitoring

Phase 3: Mitigation Strategy

OWASP Q3: What are we going to do about it?

3.1 Risk Rating

Calculate risk for prioritization:

Risk = Likelihood x Impact

Likelihood Scale:
  High (3)   = Exploitable with public tools, no auth required
  Medium (2) = Requires some skill or access
  Low (1)    = Requires significant effort or insider access

Impact Scale:
  High (3)   = Data breach, system compromise, regulatory violation
  Medium (2) = Limited data exposure, service degradation
  Low (1)    = Minor inconvenience, no sensitive data

Risk Matrix:

Impact: LowImpact: MediumImpact: High
High LikelihoodMediumHighCritical
Medium LikelihoodLowMediumHigh
Low LikelihoodLowLowMedium

3.2 Select Mitigation Strategy

StrategyWhen to UseExample
MitigateRisk can be reduced to acceptable levelAdd input validation
AcceptCost of mitigation exceeds riskLow-impact, unlikely threat
TransferSomeone else can manage risk betterCyber insurance, third-party service
EliminateRemove the vulnerable componentDrop unused feature

3.3 Document Mitigations

For each threat, document:

### T001: Credential Stuffing on Login API

**Risk**: Critical (High Likelihood x High Impact)

**Mitigations**:

1. **Implement rate limiting** (Mitigate)
   - Max 5 attempts per IP per minute
   - Progressive delays after failures
   - Status: Planned for Sprint 23

2. **Add CAPTCHA after failures** (Mitigate)
   - Trigger after 3 failed attempts
   - Status: In progress

3. **Enable MFA** (Mitigate)
   - TOTP or WebAuthn
   - Status: Blocked on product decision

**Residual Risk**: Medium (after mitigations applied)

3.4 Generate Mitigation Roadmap

python .claude/skills/threat-modeling/scripts/generate_mitigation_roadmap.py \
    --input .agents/security/threat-models/auth-threats.md \
    --output .agents/security/threat-models/auth-roadmap.md

Phase 4: Validation

OWASP Q4: Did we do a good job?

4.1 Model Validation

Run the validation script:

python .claude/skills/threat-modeling/scripts/validate_threat_model.py \
    .agents/security/threat-models/auth-threats.md

Validation Checks:

  • All components have at least one threat identified
  • All trust boundaries are crossed by at least one data flow
  • All STRIDE categories considered for applicable elements
  • All Critical/High risks have mitigations planned
  • No orphaned threats (threats without parent component)

4.2 Peer Review

Request review from:

  • Security team member
  • Architect familiar with the system
  • Developer implementing mitigations

4.3 Schedule Updates

Threat models are living documents. Update when:

  • New features added
  • Architecture changes
  • Security incident occurs
  • During regular security reviews (quarterly recommended)

Scripts

ScriptPurposeUsage
generate_threat_matrix.pyCreate structured threat matrixpython scripts/generate_threat_matrix.py --scope "Name" --output path.md
generate_mitigation_roadmap.pyCreate prioritized roadmappython scripts/generate_mitigation_roadmap.py --input threats.md --output roadmap.md
validate_threat_model.pyValidate model completenesspython scripts/validate_threat_model.py <model.md>

Exit Codes

CodeMeaning
0Success / Validation passed
1General failure
10Validation failed (missing required elements)

Templates

Threat Model Document

Use the template at: templates/threat-model-template.md

Threat Entry

### T{NNN}: {Threat Title}

**Element**: {Component name from DFD}
**STRIDE**: {S/T/R/I/D/E}
**Description**: {What the threat is}

**Attack Scenario**:
1. Attacker does X
2. System responds with Y
3. Attacker achieves Z

**Likelihood**: {High/Medium/Low} - {Justification}
**Impact**: {High/Medium/Low} - {Justification}
**Risk**: {Critical/High/Medium/Low}

**Mitigations**:
- [ ] {Mitigation 1} - {Status}
- [ ] {Mitigation 2} - {Status}

**Residual Risk**: {After mitigations}
**References**: {CVEs, OWASP links, etc.}

Integration with Agent System

AgentRelationship
securityInvoke for detailed vulnerability analysis
architectReview threat model during design
analystResearch specific attack patterns
qaInclude threat scenarios in test strategy

Memory Integration

Query Forgetful memory for prior threat models:

mcp__forgetful__execute_forgetful_tool("query_memory", {
    "query": "threat model authentication",
    "query_context": "Finding prior security analysis"
})

Store threat model summaries:

mcp__forgetful__execute_forgetful_tool("create_memory", {
    "title": "Auth Service Threat Model Summary",
    "content": "Key threats: credential stuffing, session hijacking...",
    "context": "Security analysis Q1 2026",
    "keywords": ["threat-model", "authentication", "STRIDE"],
    "tags": ["security"],
    "importance": 8,
    "project_ids": [1]
})

Anti-Patterns

AvoidWhyInstead
Threat model once and forgetSecurity landscape evolvesSchedule regular updates
Skip trust boundary analysisMiss privilege escalation pathsAlways map boundaries first
Generic threats onlyNot actionableBe specific to your system
No risk ratingsCannot prioritizeRate every threat
Mitigations without ownersNever implementedAssign owners and deadlines
Copy-paste from templatesMiss system-specific threatsUse templates as starting points

References


Verification

Success Criteria

CriterionVerification
All components have threatsValidation script check
All STRIDE categories consideredValidation script check
All Critical/High risks have mitigationsValidation script check
Risk ratings consistentManual review
Peer review completedStakeholder sign-off

Verification Command

python .claude/skills/threat-modeling/scripts/validate_threat_model.py <model.md>

Exit code 0 indicates a valid, complete threat model.


Extension Points

ExtensionHow to Add
Custom STRIDE questionsAdd to references/stride-methodology.md
New risk rating methodologyAdd to references/risk-rating-guide.md
Additional threat categoriesExtend STRIDE sections in template
Custom validation rulesModify validate_threat_model.py
Integration with SAST toolsAdd script in scripts/

SkillRelationship
security-detectionTriggers threat model review on sensitive file changes
codeql-scanValidates code against identified threats
adr-reviewSecurity agent reviews architecture decisions

Score

Total Score

60/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

1ヶ月以内に更新

+10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

0/5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

+5

Reviews

💬

Reviews coming soon