Threat Modeling Guide
Systematic approaches for identifying, analyzing, and mitigating security threats.
Table of Contents
Threat Modeling Process
Workflow: Conduct Threat Model
- Define the scope and objectives:
- System boundaries
- Assets to protect
- Trust levels
- Create data flow diagram:
- External entities
- Processes
- Data stores
- Data flows
- Trust boundaries
- Identify threats using STRIDE:
- Apply STRIDE to each DFD element
- Document threat scenarios
- Analyze and prioritize risks:
- Score using DREAD
- Rank by severity
- Define mitigations:
- Map controls to threats
- Identify gaps
- Validate and iterate:
- Review with team
- Update as system evolves
- Document in threat model report
- Validation: All DFD elements analyzed; threats documented; mitigations mapped; residual risks accepted
Threat Model Template
THREAT MODEL REPORT
System: [System Name]
Version: [Version]
Date: [Date]
Author: [Name]
1. SYSTEM OVERVIEW
- Purpose: [Description]
- Users: [User types]
- Data: [Data classification]
2. SCOPE
- In Scope: [Components included]
- Out of Scope: [Components excluded]
- Assumptions: [Security assumptions]
3. DATA FLOW DIAGRAM
[DFD image or ASCII representation]
4. THREATS IDENTIFIED
| ID | Element | STRIDE | Threat | DREAD | Mitigation |
|----|---------|--------|--------|-------|------------|
5. RESIDUAL RISKS
[Accepted risks with justification]
6. RECOMMENDATIONS
[Prioritized security improvements]
STRIDE Framework
Categorization model for identifying threats.
STRIDE Categories
| Category |
Description |
Violated Property |
| Spoofing |
Pretending to be someone/something else |
Authentication |
| Tampering |
Modifying data or code |
Integrity |
| Repudiation |
Denying actions occurred |
Non-repudiation |
| Information Disclosure |
Exposing data to unauthorized parties |
Confidentiality |
| Denial of Service |
Making system unavailable |
Availability |
| Elevation of Privilege |
Gaining unauthorized access |
Authorization |
STRIDE per Element
| DFD Element |
Applicable Threats |
| External Entity |
S, R |
| Process |
S, T, R, I, D, E |
| Data Store |
T, R, I, D |
| Data Flow |
T, I, D |
STRIDE Analysis Template
STRIDE ANALYSIS
Element: User Authentication Service
Type: Process
┌─────────────────────────────────────────────────────────────────┐
│ SPOOFING │
├─────────────────────────────────────────────────────────────────┤
│ Threat: Attacker uses stolen credentials to impersonate user │
│ Attack Vector: Phishing, credential stuffing, session hijack │
│ Likelihood: High │
│ Impact: High - Full account access │
│ Mitigation: MFA, session binding, anomaly detection │
└─────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ TAMPERING │
├─────────────────────────────────────────────────────────────────┤
│ Threat: Attacker modifies authentication request in transit │
│ Attack Vector: Man-in-the-middle, request manipulation │
│ Likelihood: Medium │
│ Impact: High - Bypass authentication │
│ Mitigation: TLS 1.3, request signing, HSTS │
└─────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ REPUDIATION │
├─────────────────────────────────────────────────────────────────┤
│ Threat: User denies performing privileged action │
│ Attack Vector: Claim account was compromised │
│ Likelihood: Medium │
│ Impact: Medium - Dispute resolution difficulty │
│ Mitigation: Comprehensive audit logging, log integrity │
└─────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ INFORMATION DISCLOSURE │
├─────────────────────────────────────────────────────────────────┤
│ Threat: Password hashes exposed via SQL injection │
│ Attack Vector: SQLi, backup exposure, error messages │
│ Likelihood: Medium │
│ Impact: Critical - Mass credential compromise │
│ Mitigation: Parameterized queries, encryption, error handling │
└─────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ DENIAL OF SERVICE │
├─────────────────────────────────────────────────────────────────┤
│ Threat: Brute force attacks overwhelm authentication service │
│ Attack Vector: Credential stuffing, distributed attacks │
│ Likelihood: High │
│ Impact: High - Users cannot authenticate │
│ Mitigation: Rate limiting, CAPTCHA, account lockout │
└─────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ ELEVATION OF PRIVILEGE │
├─────────────────────────────────────────────────────────────────┤
│ Threat: Regular user gains admin privileges │
│ Attack Vector: JWT manipulation, IDOR, role confusion │
│ Likelihood: Medium │
│ Impact: Critical - Full system compromise │
│ Mitigation: Server-side authorization, signed tokens, RBAC │
└─────────────────────────────────────────────────────────────────┘
Threat Mitigation Matrix
| STRIDE Category |
Standard Mitigations |
| Spoofing |
Authentication (passwords, MFA, certificates) |
| Tampering |
Integrity controls (signing, hashing, checksums) |
| Repudiation |
Audit logging, digital signatures, timestamps |
| Information Disclosure |
Encryption, access controls, data masking |
| Denial of Service |
Rate limiting, redundancy, filtering |
| Elevation of Privilege |
Authorization, least privilege, input validation |
Attack Trees
Visual representation of attack paths to a specific goal.
Attack Tree Structure
ATTACK TREE: Compromise User Account
┌─────────────────────┐
│ GOAL: Access User │
│ Account │
└──────────┬──────────┘
│
┌───────────────────┼───────────────────┐
│ │ │
┌──────┴──────┐ ┌──────┴──────┐ ┌──────┴──────┐
│ Obtain │ │ Bypass │ │ Exploit │
│ Credentials │ │ Auth │ │ Session │
│ [OR] │ │ [OR] │ │ [OR] │
└──────┬──────┘ └──────┬──────┘ └──────┬──────┘
│ │ │
┌─────┼─────┐ ┌─────┼─────┐ ┌─────┼─────┐
│ │ │ │ │ │ │ │ │
┌─┴─┐ ┌─┴─┐ ┌─┴─┐ ┌─┴─┐ ┌─┴─┐ ┌─┴─┐ ┌─┴─┐ ┌─┴─┐ ┌─┴─┐
│Phi│ │Crd│ │Key│ │SQL│ │JWT│ │Pwd│ │XSS│ │Fix│ │Sid│
│sh │ │Stf│ │Log│ │ i │ │Frg│ │Rst│ │ │ │tn │ │Hj │
└───┘ └───┘ └───┘ └───┘ └───┘ └───┘ └───┘ └───┘ └───┘
Legend:
- Phi: Phishing
- CrdStf: Credential Stuffing
- KeyLog: Keylogger
- SQLi: SQL Injection
- JWTFrg: JWT Forgery
- PwdRst: Password Reset Flaw
- XSS: Cross-Site Scripting
- Fixtn: Session Fixation
- SidHj: Session Hijacking
Attack Tree Analysis
| Attack Path |
Difficulty |
Detection |
Priority |
| Phishing → Credential theft |
Low |
Medium |
High |
| SQL Injection → Auth bypass |
Medium |
High |
Critical |
| XSS → Session steal |
Medium |
Medium |
High |
| JWT forgery → Privilege escalation |
High |
Low |
Critical |
Calculating Attack Probability
def calculate_attack_probability(attack_tree_node):
"""
Calculate cumulative probability of attack success.
For OR nodes: P = 1 - (1-P1)(1-P2)...(1-Pn)
For AND nodes: P = P1 * P2 * ... * Pn
"""
if node.is_leaf:
return node.probability
child_probs = [calculate_attack_probability(c) for c in node.children]
if node.operator == 'OR':
# At least one path succeeds
prob_all_fail = 1
for p in child_probs:
prob_all_fail *= (1 - p)
return 1 - prob_all_fail
elif node.operator == 'AND':
# All paths must succeed
prob_all_succeed = 1
for p in child_probs:
prob_all_succeed *= p
return prob_all_succeed
DREAD Risk Scoring
Quantitative risk assessment for prioritizing threats.
DREAD Components
| Factor |
Description |
Scale |
| Damage |
How bad is the impact? |
1-10 |
| Reproducibility |
How easy to reproduce? |
1-10 |
| Exploitability |
How easy to exploit? |
1-10 |
| Affected Users |
How many users impacted? |
1-10 |
| Discoverability |
How easy to find? |
1-10 |
DREAD Scoring Guide
Damage Potential:
| Score |
Description |
| 10 |
Complete system compromise, data destruction |
| 7-9 |
Large data breach, significant financial loss |
| 4-6 |
Partial data exposure, service degradation |
| 1-3 |
Minor information disclosure, low impact |
Reproducibility:
| Score |
Description |
| 10 |
Always reproducible, automated |
| 7-9 |
Reproducible most of the time |
| 4-6 |
Reproducible with some effort |
| 1-3 |
Difficult to reproduce, timing dependent |
Exploitability:
| Score |
Description |
| 10 |
No skills required, exploit exists |
| 7-9 |
Basic skills, tools available |
| 4-6 |
Moderate skills required |
| 1-3 |
Advanced skills, custom exploit needed |
Affected Users:
| Score |
Description |
| 10 |
All users |
| 7-9 |
Large subset of users |
| 4-6 |
Some users |
| 1-3 |
Few or individual users |
Discoverability:
| Score |
Description |
| 10 |
Publicly documented, obvious |
| 7-9 |
Easy to find via scanning |
| 4-6 |
Requires investigation |
| 1-3 |
Obscure, requires insider knowledge |
DREAD Calculation
def calculate_dread_score(damage, reproducibility, exploitability,
affected_users, discoverability):
"""
Calculate DREAD risk score.
Returns: Float between 1-10
Risk Levels:
8-10: Critical
6-7.9: High
4-5.9: Medium
1-3.9: Low
"""
score = (damage + reproducibility + exploitability +
affected_users + discoverability) / 5
return round(score, 1)
def get_risk_level(dread_score):
if dread_score >= 8:
return 'Critical'
elif dread_score >= 6:
return 'High'
elif dread_score >= 4:
return 'Medium'
else:
return 'Low'
DREAD Assessment Example
THREAT: SQL Injection in Login Form
| Factor | Score | Justification |
|--------|-------|---------------|
| Damage | 9 | Full database access, credential theft |
| Reproducibility | 9 | Consistent, automated tools exist |
| Exploitability | 8 | Well-documented attack, easy tools |
| Affected Users | 10 | All users with accounts |
| Discoverability | 7 | Scanners detect easily |
DREAD Score: (9+9+8+10+7)/5 = 8.6
Risk Level: CRITICAL
Priority: Immediate remediation required
Data Flow Diagrams
Visual representation of system data movement for security analysis.
DFD Elements
| Symbol |
Element |
Security Considerations |
| Rectangle |
External Entity |
Trust boundary crossing |
| Circle/Oval |
Process |
All STRIDE threats apply |
| Parallel Lines |
Data Store |
Tampering, disclosure, DoS |
| Arrow |
Data Flow |
Tampering, disclosure, DoS |
| Dashed Line |
Trust Boundary |
Authentication required |
DFD Levels
| Level |
Description |
Use Case |
| Level 0 (Context) |
Single process, external entities |
Executive overview |
| Level 1 |
Major processes expanded |
Architecture review |
| Level 2 |
Detailed subprocesses |
Detailed threat modeling |
Example: E-Commerce DFD
LEVEL 0: CONTEXT DIAGRAM
┌──────────────────┐
│ │
┌────────────┐ │ E-Commerce │ ┌────────────┐
│ │ Orders │ System │ Payment │ │
│ Customer │──────────▶│ │──────────▶│ Payment │
│ │◀──────────│ │◀──────────│ Gateway │
└────────────┘ Status │ │ Result └────────────┘
│ │
└──────────────────┘
│
│ Fulfillment
▼
┌────────────────┐
│ Warehouse │
│ System │
└────────────────┘
LEVEL 1: EXPANDED VIEW
┌─────────────────────────────────────────────────────────────────────┐
│ TRUST BOUNDARY │
│ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - │
│ │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ │ │ Web │ │ Order │ │ Payment │ │
│ │ CDN │──────▶│ Server │──────▶│ Service │──────▶│ Service │ │
│ │ │ │ │ │ │ │ │ │
│ └─────────┘ └────┬────┘ └────┬────┘ └────┬────┘ │
│ │ │ │ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ╔═══════════╗ ╔═══════════╗ ╔═══════════╗ │
│ ║ Session ║ ║ Orders ║ ║ Payment ║ │
│ ║ Store ║ ║ DB ║ ║ DB ║ │
│ ╚═══════════╝ ╚═══════════╝ ╚═══════════╝ │
│ │
└─────────────────────────────────────────────────────────────────────┘
│
│ Crosses Trust Boundary
▼
┌───────────┐
│ Payment │
│ Gateway │
│ (External)│
└───────────┘
Trust Boundary Analysis
| Boundary Crossing |
Authentication |
Authorization |
Encryption |
| Customer → Web Server |
Session cookie |
- |
TLS 1.3 |
| Web Server → Order Service |
mTLS |
Service account |
Internal TLS |
| Order Service → DB |
Connection pool |
DB user roles |
TLS |
| Payment Service → Gateway |
API key + HMAC |
IP whitelist |
TLS 1.3 |
Common Attack Patterns
OWASP Top 10 Mapping
| Rank |
Vulnerability |
STRIDE |
Common Attack |
| A01 |
Broken Access Control |
E |
IDOR, privilege escalation |
| A02 |
Cryptographic Failures |
I |
Weak encryption, exposed keys |
| A03 |
Injection |
T, E |
SQLi, XSS, command injection |
| A04 |
Insecure Design |
All |
Logic flaws, missing controls |
| A05 |
Security Misconfiguration |
I, E |
Default creds, verbose errors |
| A06 |
Vulnerable Components |
All |
Outdated libraries, CVEs |
| A07 |
Authentication Failures |
S, E |
Credential stuffing, weak passwords |
| A08 |
Software/Data Integrity |
T |
Unsigned updates, CI/CD attacks |
| A09 |
Logging Failures |
R |
Missing logs, log injection |
| A10 |
SSRF |
I, T |
Internal service access |
Attack Pattern Catalog
ATTACK PATTERN: SQL Injection (A03)
Threat: T (Tampering), E (Elevation of Privilege)
Attack Vector:
1. Identify input fields that construct SQL queries
2. Test for injection: ' OR '1'='1' --
3. Extract data: UNION SELECT password FROM users
4. Escalate: Execute stored procedures, write files
Detection:
- WAF rules for SQL patterns
- Prepared statement verification
- Database query logging
Mitigation:
- Parameterized queries (primary)
- Input validation (secondary)
- Least privilege database accounts
- Web application firewall
Test Cases:
- Single quote injection: '
- Boolean-based: ' OR 1=1 --
- Time-based: '; WAITFOR DELAY '0:0:5' --
- UNION-based: ' UNION SELECT NULL, username, password FROM users --
Threat Intelligence Integration
| Source |
Purpose |
Update Frequency |
| CVE/NVD |
Known vulnerabilities |
Daily |
| MITRE ATT&CK |
Attack techniques |
Quarterly |
| OWASP |
Web application threats |
Annual |
| Industry ISACs |
Sector-specific threats |
Real-time |
1---2name: 1731-threat-modeling-guide-6962830a3description: Threat Modeling Guide4---5# Threat Modeling Guide67Systematic approaches for identifying, analyzing, and mitigating security threats.89---1011## Table of Contents1213- [Threat Modeling Process](#threat-modeling-process)14- [STRIDE Framework](#stride-framework)15- [Attack Trees](#attack-trees)16- [DREAD Risk Scoring](#dread-risk-scoring)17- [Data Flow Diagrams](#data-flow-diagrams)18- [Common Attack Patterns](#common-attack-patterns)1920---2122## Threat Modeling Process2324### Workflow: Conduct Threat Model25261. Define the scope and objectives:27 - System boundaries28 - Assets to protect29 - Trust levels302. Create data flow diagram:31 - External entities32 - Processes33 - Data stores34 - Data flows35 - Trust boundaries363. Identify threats using STRIDE:37 - Apply STRIDE to each DFD element38 - Document threat scenarios394. Analyze and prioritize risks:40 - Score using DREAD41 - Rank by severity425. Define mitigations:43 - Map controls to threats44 - Identify gaps456. Validate and iterate:46 - Review with team47 - Update as system evolves487. Document in threat model report498. **Validation:** All DFD elements analyzed; threats documented; mitigations mapped; residual risks accepted5051### Threat Model Template5253```54THREAT MODEL REPORT5556System: [System Name]57Version: [Version]58Date: [Date]59Author: [Name]60611. SYSTEM OVERVIEW62 - Purpose: [Description]63 - Users: [User types]64 - Data: [Data classification]65662. SCOPE67 - In Scope: [Components included]68 - Out of Scope: [Components excluded]69 - Assumptions: [Security assumptions]70713. DATA FLOW DIAGRAM72 [DFD image or ASCII representation]73744. THREATS IDENTIFIED75 | ID | Element | STRIDE | Threat | DREAD | Mitigation |76 |----|---------|--------|--------|-------|------------|77785. RESIDUAL RISKS79 [Accepted risks with justification]80816. RECOMMENDATIONS82 [Prioritized security improvements]83```8485---8687## STRIDE Framework8889Categorization model for identifying threats.9091### STRIDE Categories9293| Category | Description | Violated Property |94|----------|-------------|-------------------|95| **S**poofing | Pretending to be someone/something else | Authentication |96| **T**ampering | Modifying data or code | Integrity |97| **R**epudiation | Denying actions occurred | Non-repudiation |98| **I**nformation Disclosure | Exposing data to unauthorized parties | Confidentiality |99| **D**enial of Service | Making system unavailable | Availability |100| **E**levation of Privilege | Gaining unauthorized access | Authorization |101102### STRIDE per Element103104| DFD Element | Applicable Threats |105|-------------|-------------------|106| External Entity | S, R |107| Process | S, T, R, I, D, E |108| Data Store | T, R, I, D |109| Data Flow | T, I, D |110111### STRIDE Analysis Template112113```114STRIDE ANALYSIS115116Element: User Authentication Service117Type: Process118119┌─────────────────────────────────────────────────────────────────┐120│ SPOOFING │121├─────────────────────────────────────────────────────────────────┤122│ Threat: Attacker uses stolen credentials to impersonate user │123│ Attack Vector: Phishing, credential stuffing, session hijack │124│ Likelihood: High │125│ Impact: High - Full account access │126│ Mitigation: MFA, session binding, anomaly detection │127└─────────────────────────────────────────────────────────────────┘128129┌─────────────────────────────────────────────────────────────────┐130│ TAMPERING │131├─────────────────────────────────────────────────────────────────┤132│ Threat: Attacker modifies authentication request in transit │133│ Attack Vector: Man-in-the-middle, request manipulation │134│ Likelihood: Medium │135│ Impact: High - Bypass authentication │136│ Mitigation: TLS 1.3, request signing, HSTS │137└─────────────────────────────────────────────────────────────────┘138139┌─────────────────────────────────────────────────────────────────┐140│ REPUDIATION │141├─────────────────────────────────────────────────────────────────┤142│ Threat: User denies performing privileged action │143│ Attack Vector: Claim account was compromised │144│ Likelihood: Medium │145│ Impact: Medium - Dispute resolution difficulty │146│ Mitigation: Comprehensive audit logging, log integrity │147└─────────────────────────────────────────────────────────────────┘148149┌─────────────────────────────────────────────────────────────────┐150│ INFORMATION DISCLOSURE │151├─────────────────────────────────────────────────────────────────┤152│ Threat: Password hashes exposed via SQL injection │153│ Attack Vector: SQLi, backup exposure, error messages │154│ Likelihood: Medium │155│ Impact: Critical - Mass credential compromise │156│ Mitigation: Parameterized queries, encryption, error handling │157└─────────────────────────────────────────────────────────────────┘158159┌─────────────────────────────────────────────────────────────────┐160│ DENIAL OF SERVICE │161├─────────────────────────────────────────────────────────────────┤162│ Threat: Brute force attacks overwhelm authentication service │163│ Attack Vector: Credential stuffing, distributed attacks │164│ Likelihood: High │165│ Impact: High - Users cannot authenticate │166│ Mitigation: Rate limiting, CAPTCHA, account lockout │167└─────────────────────────────────────────────────────────────────┘168169┌─────────────────────────────────────────────────────────────────┐170│ ELEVATION OF PRIVILEGE │171├─────────────────────────────────────────────────────────────────┤172│ Threat: Regular user gains admin privileges │173│ Attack Vector: JWT manipulation, IDOR, role confusion │174│ Likelihood: Medium │175│ Impact: Critical - Full system compromise │176│ Mitigation: Server-side authorization, signed tokens, RBAC │177└─────────────────────────────────────────────────────────────────┘178```179180### Threat Mitigation Matrix181182| STRIDE Category | Standard Mitigations |183|-----------------|---------------------|184| Spoofing | Authentication (passwords, MFA, certificates) |185| Tampering | Integrity controls (signing, hashing, checksums) |186| Repudiation | Audit logging, digital signatures, timestamps |187| Information Disclosure | Encryption, access controls, data masking |188| Denial of Service | Rate limiting, redundancy, filtering |189| Elevation of Privilege | Authorization, least privilege, input validation |190191---192193## Attack Trees194195Visual representation of attack paths to a specific goal.196197### Attack Tree Structure198199```200ATTACK TREE: Compromise User Account201202 ┌─────────────────────┐203 │ GOAL: Access User │204 │ Account │205 └──────────┬──────────┘206 │207 ┌───────────────────┼───────────────────┐208 │ │ │209 ┌──────┴──────┐ ┌──────┴──────┐ ┌──────┴──────┐210 │ Obtain │ │ Bypass │ │ Exploit │211 │ Credentials │ │ Auth │ │ Session │212 │ [OR] │ │ [OR] │ │ [OR] │213 └──────┬──────┘ └──────┬──────┘ └──────┬──────┘214 │ │ │215 ┌─────┼─────┐ ┌─────┼─────┐ ┌─────┼─────┐216 │ │ │ │ │ │ │ │ │217 ┌─┴─┐ ┌─┴─┐ ┌─┴─┐ ┌─┴─┐ ┌─┴─┐ ┌─┴─┐ ┌─┴─┐ ┌─┴─┐ ┌─┴─┐218 │Phi│ │Crd│ │Key│ │SQL│ │JWT│ │Pwd│ │XSS│ │Fix│ │Sid│219 │sh │ │Stf│ │Log│ │ i │ │Frg│ │Rst│ │ │ │tn │ │Hj │220 └───┘ └───┘ └───┘ └───┘ └───┘ └───┘ └───┘ └───┘ └───┘221222Legend:223- Phi: Phishing224- CrdStf: Credential Stuffing225- KeyLog: Keylogger226- SQLi: SQL Injection227- JWTFrg: JWT Forgery228- PwdRst: Password Reset Flaw229- XSS: Cross-Site Scripting230- Fixtn: Session Fixation231- SidHj: Session Hijacking232```233234### Attack Tree Analysis235236| Attack Path | Difficulty | Detection | Priority |237|-------------|------------|-----------|----------|238| Phishing → Credential theft | Low | Medium | High |239| SQL Injection → Auth bypass | Medium | High | Critical |240| XSS → Session steal | Medium | Medium | High |241| JWT forgery → Privilege escalation | High | Low | Critical |242243### Calculating Attack Probability244245```python246def calculate_attack_probability(attack_tree_node):247 """248 Calculate cumulative probability of attack success.249250 For OR nodes: P = 1 - (1-P1)(1-P2)...(1-Pn)251 For AND nodes: P = P1 * P2 * ... * Pn252 """253 if node.is_leaf:254 return node.probability255256 child_probs = [calculate_attack_probability(c) for c in node.children]257258 if node.operator == 'OR':259 # At least one path succeeds260 prob_all_fail = 1261 for p in child_probs:262 prob_all_fail *= (1 - p)263 return 1 - prob_all_fail264265 elif node.operator == 'AND':266 # All paths must succeed267 prob_all_succeed = 1268 for p in child_probs:269 prob_all_succeed *= p270 return prob_all_succeed271```272273---274275## DREAD Risk Scoring276277Quantitative risk assessment for prioritizing threats.278279### DREAD Components280281| Factor | Description | Scale |282|--------|-------------|-------|283| **D**amage | How bad is the impact? | 1-10 |284| **R**eproducibility | How easy to reproduce? | 1-10 |285| **E**xploitability | How easy to exploit? | 1-10 |286| **A**ffected Users | How many users impacted? | 1-10 |287| **D**iscoverability | How easy to find? | 1-10 |288289### DREAD Scoring Guide290291**Damage Potential:**292| Score | Description |293|-------|-------------|294| 10 | Complete system compromise, data destruction |295| 7-9 | Large data breach, significant financial loss |296| 4-6 | Partial data exposure, service degradation |297| 1-3 | Minor information disclosure, low impact |298299**Reproducibility:**300| Score | Description |301|-------|-------------|302| 10 | Always reproducible, automated |303| 7-9 | Reproducible most of the time |304| 4-6 | Reproducible with some effort |305| 1-3 | Difficult to reproduce, timing dependent |306307**Exploitability:**308| Score | Description |309|-------|-------------|310| 10 | No skills required, exploit exists |311| 7-9 | Basic skills, tools available |312| 4-6 | Moderate skills required |313| 1-3 | Advanced skills, custom exploit needed |314315**Affected Users:**316| Score | Description |317|-------|-------------|318| 10 | All users |319| 7-9 | Large subset of users |320| 4-6 | Some users |321| 1-3 | Few or individual users |322323**Discoverability:**324| Score | Description |325|-------|-------------|326| 10 | Publicly documented, obvious |327| 7-9 | Easy to find via scanning |328| 4-6 | Requires investigation |329| 1-3 | Obscure, requires insider knowledge |330331### DREAD Calculation332333```python334def calculate_dread_score(damage, reproducibility, exploitability,335 affected_users, discoverability):336 """337 Calculate DREAD risk score.338339 Returns: Float between 1-10340 Risk Levels:341 8-10: Critical342 6-7.9: High343 4-5.9: Medium344 1-3.9: Low345 """346 score = (damage + reproducibility + exploitability +347 affected_users + discoverability) / 5348 return round(score, 1)349350def get_risk_level(dread_score):351 if dread_score >= 8:352 return 'Critical'353 elif dread_score >= 6:354 return 'High'355 elif dread_score >= 4:356 return 'Medium'357 else:358 return 'Low'359```360361### DREAD Assessment Example362363```364THREAT: SQL Injection in Login Form365366| Factor | Score | Justification |367|--------|-------|---------------|368| Damage | 9 | Full database access, credential theft |369| Reproducibility | 9 | Consistent, automated tools exist |370| Exploitability | 8 | Well-documented attack, easy tools |371| Affected Users | 10 | All users with accounts |372| Discoverability | 7 | Scanners detect easily |373374DREAD Score: (9+9+8+10+7)/5 = 8.6375Risk Level: CRITICAL376Priority: Immediate remediation required377```378379---380381## Data Flow Diagrams382383Visual representation of system data movement for security analysis.384385### DFD Elements386387| Symbol | Element | Security Considerations |388|--------|---------|------------------------|389| Rectangle | External Entity | Trust boundary crossing |390| Circle/Oval | Process | All STRIDE threats apply |391| Parallel Lines | Data Store | Tampering, disclosure, DoS |392| Arrow | Data Flow | Tampering, disclosure, DoS |393| Dashed Line | Trust Boundary | Authentication required |394395### DFD Levels396397| Level | Description | Use Case |398|-------|-------------|----------|399| Level 0 (Context) | Single process, external entities | Executive overview |400| Level 1 | Major processes expanded | Architecture review |401| Level 2 | Detailed subprocesses | Detailed threat modeling |402403### Example: E-Commerce DFD404405```406LEVEL 0: CONTEXT DIAGRAM407408 ┌──────────────────┐409 │ │410 ┌────────────┐ │ E-Commerce │ ┌────────────┐411 │ │ Orders │ System │ Payment │ │412 │ Customer │──────────▶│ │──────────▶│ Payment │413 │ │◀──────────│ │◀──────────│ Gateway │414 └────────────┘ Status │ │ Result └────────────┘415 │ │416 └──────────────────┘417 │418 │ Fulfillment419 ▼420 ┌────────────────┐421 │ Warehouse │422 │ System │423 └────────────────┘424425426LEVEL 1: EXPANDED VIEW427428┌─────────────────────────────────────────────────────────────────────┐429│ TRUST BOUNDARY │430│ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - │431│ │432│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │433│ │ │ │ Web │ │ Order │ │ Payment │ │434│ │ CDN │──────▶│ Server │──────▶│ Service │──────▶│ Service │ │435│ │ │ │ │ │ │ │ │ │436│ └─────────┘ └────┬────┘ └────┬────┘ └────┬────┘ │437│ │ │ │ │438│ │ │ │ │439│ ▼ ▼ ▼ │440│ ╔═══════════╗ ╔═══════════╗ ╔═══════════╗ │441│ ║ Session ║ ║ Orders ║ ║ Payment ║ │442│ ║ Store ║ ║ DB ║ ║ DB ║ │443│ ╚═══════════╝ ╚═══════════╝ ╚═══════════╝ │444│ │445└─────────────────────────────────────────────────────────────────────┘446 │447 │ Crosses Trust Boundary448 ▼449 ┌───────────┐450 │ Payment │451 │ Gateway │452 │ (External)│453 └───────────┘454```455456### Trust Boundary Analysis457458| Boundary Crossing | Authentication | Authorization | Encryption |459|-------------------|----------------|---------------|------------|460| Customer → Web Server | Session cookie | - | TLS 1.3 |461| Web Server → Order Service | mTLS | Service account | Internal TLS |462| Order Service → DB | Connection pool | DB user roles | TLS |463| Payment Service → Gateway | API key + HMAC | IP whitelist | TLS 1.3 |464465---466467## Common Attack Patterns468469### OWASP Top 10 Mapping470471| Rank | Vulnerability | STRIDE | Common Attack |472|------|---------------|--------|---------------|473| A01 | Broken Access Control | E | IDOR, privilege escalation |474| A02 | Cryptographic Failures | I | Weak encryption, exposed keys |475| A03 | Injection | T, E | SQLi, XSS, command injection |476| A04 | Insecure Design | All | Logic flaws, missing controls |477| A05 | Security Misconfiguration | I, E | Default creds, verbose errors |478| A06 | Vulnerable Components | All | Outdated libraries, CVEs |479| A07 | Authentication Failures | S, E | Credential stuffing, weak passwords |480| A08 | Software/Data Integrity | T | Unsigned updates, CI/CD attacks |481| A09 | Logging Failures | R | Missing logs, log injection |482| A10 | SSRF | I, T | Internal service access |483484### Attack Pattern Catalog485486```487ATTACK PATTERN: SQL Injection (A03)488489Threat: T (Tampering), E (Elevation of Privilege)490491Attack Vector:4921. Identify input fields that construct SQL queries4932. Test for injection: ' OR '1'='1' --4943. Extract data: UNION SELECT password FROM users4954. Escalate: Execute stored procedures, write files496497Detection:498- WAF rules for SQL patterns499- Prepared statement verification500- Database query logging501502Mitigation:503- Parameterized queries (primary)504- Input validation (secondary)505- Least privilege database accounts506- Web application firewall507508Test Cases:509- Single quote injection: '510- Boolean-based: ' OR 1=1 --511- Time-based: '; WAITFOR DELAY '0:0:5' --512- UNION-based: ' UNION SELECT NULL, username, password FROM users --513```514515### Threat Intelligence Integration516517| Source | Purpose | Update Frequency |518|--------|---------|------------------|519| CVE/NVD | Known vulnerabilities | Daily |520| MITRE ATT&CK | Attack techniques | Quarterly |521| OWASP | Web application threats | Annual |522| Industry ISACs | Sector-specific threats | Real-time |