Loading learning content...
In 2014, Sony Pictures Entertainment suffered one of the most devastating corporate cyber attacks in history. Attackers exfiltrated over 100 terabytes of data—including unreleased films, employee personal data, executive emails, and salary information. The attack paralyzed operations for weeks and caused over $100 million in damages.
What's remarkable isn't that attackers found a way in—it's that many of the attack vectors were entirely foreseeable. Email phishing, weak network segmentation, unencrypted sensitive files, and inadequate access controls were all exploited. A systematic threat modeling exercise would have surfaced these risks months before the breach.
Threat modeling is the practice of anticipating attacks before they happen. It forces you to think like an adversary: What assets are valuable? How might someone try to steal or destroy them? What weaknesses could they exploit? This proactive analysis is far cheaper than reactive incident response.
This page teaches you to systematically identify, analyze, and prioritize threats—giving you the attacker's perspective so you can defend against it.
By the end of this page, you will understand what threat modeling is and why it's essential, learn the STRIDE methodology for categorizing threats, be able to create data flow diagrams and attack trees, and know how to integrate threat modeling into your development process.
Threat modeling is a structured approach to identifying security threats, vulnerabilities, and the mitigations needed to protect a system. It's performed during design—before code is written—but can be applied to existing systems as well.
The core questions of threat modeling:
What are we building? — Understand the system's architecture, components, data flows, and trust boundaries.
What can go wrong? — Systematically identify potential threats and attack scenarios.
What are we going to do about it? — Define mitigations, accept risks, or redesign to eliminate threats.
Did we do a good enough job? — Validate the model, test mitigations, and iterate.
Threat modeling isn't about achieving perfect security—it's about making informed decisions about which risks to address and which to accept.
Threat modeling isn't just for security specialists. Every engineer involved in system design should understand how to identify threats. You don't need deep security expertise—you need a systematic approach to thinking adversarially about your own systems.
When to perform threat modeling:
Threat modeling is not a one-time activity—it's a continuous practice that evolves with your system.
While many threat modeling methodologies exist, they generally follow a common process. Here's a practical workflow you can apply to any system:
Step 1: Decompose the System
Before identifying threats, you must understand what you're protecting. Create a clear picture of:
Step 2: Create a Data Flow Diagram (DFD)
A Data Flow Diagram visualizes how data moves through your system. It uses standard symbols:
┌──────────────────────────────────────────────────────────────────┐
│ DFD Symbol Legend │
├──────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────┐ │
│ │ Process │ — A process that transforms data │
│ └─────────┘ │
│ │
│ ═══════════ — Data store (database, cache, file system) │
│ │
│ ⬤ External — External entity (user, external service) │
│ │
│ ──────────→ — Data flow (direction shows data movement) │
│ │
│ - - - - - - — Trust boundary (crossing = potential threat) │
│ │
└──────────────────────────────────────────────────────────────────┘
Example DFD for an e-commerce checkout:
┌───────────────────────────────────────┐
│ Internal Network │
⬤ Customer │ │
│ │ ┌─────────────┐ ┌─────────────┐ │
│ HTTPS │ │ API │──→│ Order │ │
▼ │ │ Gateway │ │ Service │ │
- - - - - - - - - - - - -│- - - - - - - - - - - - - - - - - - - -│
Trust Boundary │ └──────┬──────┘ └──────┬──────┘ │
│ │ │ │
│ ▼ ▼ │
│ ════════════ ════════════ │
│ Auth DB Order DB │
│ ════════════ ════════════ │
│ │ │ │
│ └────────┬─────────┘ │
│ │ │
│ ▼ │
- - - - - - - - - - - - -│- - - - - - - - - - - - - - - - - - - -│
Trust Boundary │ ⬤ Payment │
│ Gateway │
└───────────────────────────────────────┘
Each trust boundary crossing is a potential attack surface. Each data flow represents potential data exposure or manipulation.
Your first DFD doesn't need to capture every detail. Start with major components and data flows. Iterate as you identify threats that require deeper decomposition of specific areas.
STRIDE is a threat classification framework developed at Microsoft that provides a structured way to identify threats. Each letter represents a category of threat:
For each component and data flow in your DFD, systematically ask: 'How might an attacker achieve each STRIDE threat here?'
| Threat | Definition | Example | Typical Mitigations |
|---|---|---|---|
| Spoofing | Impersonating a user or system | Attacker uses stolen credentials to access account | Strong authentication, MFA, mutual TLS |
| Tampering | Unauthorized modification | Man-in-the-middle modifies transaction amount | Integrity checks, signing, encryption in transit |
| Repudiation | Denying an action occurred | User claims they never made a purchase | Audit logging, digital signatures, timestamps |
| Information Disclosure | Data exposure | SQL injection reveals customer data | Encryption, access control, input validation |
| Denial of Service | Disrupting availability | Attacker floods API with requests | Rate limiting, DDoS protection, auto-scaling |
| Elevation of Privilege | Gaining unauthorized access | User exploits bug to gain admin rights | Least privilege, input validation, sandboxing |
Applying STRIDE to components:
Different components are susceptible to different STRIDE categories:
| Component Type | Primary STRIDE Concerns |
|---|---|
| External entities | Spoofing |
| Processes | Spoofing, Tampering, Repudiation, Information Disclosure, DoS, EoP |
| Data stores | Tampering, Information Disclosure, DoS |
| Data flows | Tampering, Information Disclosure, DoS |
Example STRIDE analysis for a user authentication flow:
Component: Login API Endpoint
S - Spoofing: Attacker sends credentials stolen from another site
→ Mitigation: Rate limiting, breach password checking, MFA
T - Tampering: Request modified in transit to change username
→ Mitigation: HTTPS (TLS) for all communication
R - Repudiation: User claims they never logged in
→ Mitigation: Audit log with timestamp, IP, user agent
I - Information Disclosure: Error messages reveal valid usernames
→ Mitigation: Generic 'invalid credentials' message
D - Denial of Service: Attacker floods login endpoint
→ Mitigation: Rate limiting per IP, CAPTCHA after failures
E - Elevation of Privilege: SQL injection grants admin access
→ Mitigation: Parameterized queries, input validation
The 'STRIDE per element' approach applies STRIDE to each element in your DFD systematically. For each process, data store, and data flow, work through all six threat categories. This ensures comprehensive coverage.
Attack trees are a complementary technique that models the steps an attacker might take to achieve a goal. The root of the tree is the attacker's objective, and branches represent different ways to achieve it.
Attack trees help identify:
Structure of an attack tree:
┌─────────────────────────────┐
│ GOAL: Steal User Data │ (Root: attacker objective)
└──────────────┬──────────────┘
│
┌─────────────────────┼─────────────────────┐
│ │ │
┌───────▼───────┐ ┌───────▼───────┐ ┌───────▼───────┐
│ Exploit API │ │ Compromise │ │ Social │
│ Vulnerability │ │ Database │ │ Engineering │
└───────┬───────┘ └───────┬───────┘ └───────┬───────┘
│ │ │
┌──────┴──────┐ ┌──────┴──────┐ ┌──────┴──────┐
│ │ │ │ │ │
┌──▼──┐ ┌──▼──┐ ┌──▼──┐ ┌──▼──┐ ┌──▼──┐ ┌──▼──┐
│SQL │ │Auth │ │Creds│ │Unenc│ │Phish│ │Bribe│
│Inj │ │Byps │ │Theft│ │rpted│ │Admin│ │Emply│
└─────┘ └─────┘ └─────┘ └─────┘ └─────┘ └─────┘
Reading the tree:
In the example above, 'Steal User Data' can be achieved through API exploitation OR database compromise OR social engineering. Each of those has further sub-goals.
Annotating attack trees:
To prioritize mitigations, annotate nodes with attributes:
Example with annotations:
┌─────────────────────────────────────────────────────────┐
│ SQL Injection │
├─────────────────────────────────────────────────────────┤
│ Likelihood: High (common vulnerability) │
│ Difficulty: Easy (automated tools available) │
│ Impact: Critical (full database access) │
│ Detectability: Medium (can be logged if monitored) │
│ PRIORITY: CRITICAL - Mitigate immediately │
└─────────────────────────────────────────────────────────┘
vs.
┌─────────────────────────────────────────────────────────┐
│ Bribe Employee │
├─────────────────────────────────────────────────────────┤
│ Likelihood: Low (requires finding willing employee) │
│ Difficulty: Hard (risk of exposure, uncertain outcome) │
│ Impact: Varies (depends on employee access) │
│ Detectability: Low (insider threat harder to detect) │
│ PRIORITY: Medium - Monitor, background checks │
└─────────────────────────────────────────────────────────┘
This analysis helps prioritize: fix SQL injection first, even though bribery is harder to detect.
Look for nodes that appear on multiple attack paths. These are high-value mitigation targets—securing them blocks multiple attack vectors simultaneously. For example, if 'stolen credentials' enables several attack branches, investing in MFA provides broad protection.
Threat modeling typically identifies more risks than you can address immediately. Prioritization ensures you focus on the most critical threats first.
The DREAD Model:
DREAD is a risk assessment model that scores threats across five dimensions:
Total DREAD score = sum of all dimensions (5-50). Higher scores = higher priority.
| Threat | D | R | E | A | D | Total | Priority |
|---|---|---|---|---|---|---|---|
| SQL Injection in search | 10 | 10 | 8 | 10 | 8 | 46 | Critical |
| CSRF on profile update | 5 | 8 | 6 | 8 | 6 | 33 | High |
| Verbose error messages | 3 | 10 | 10 | 10 | 10 | 43 | High |
| Missing rate limiting | 4 | 10 | 10 | 6 | 8 | 38 | High |
| Weak password policy | 6 | 5 | 4 | 8 | 8 | 31 | Medium |
Addressing threats — the four strategies:
For each identified threat, you have four options:
Mitigate — Implement controls to reduce likelihood or impact
Transfer — Shift risk to another party
Accept — Acknowledge the risk and proceed without mitigation
Avoid — Eliminate the threat by removing the feature or component
Most threats are mitigated. Acceptance should be rare and documented. Avoidance is the most secure but may conflict with business requirements.
When accepting a risk, document: the threat, why mitigation isn't feasible, who approved the acceptance, what conditions would trigger revisiting the decision, and any compensating controls in place. Undocumented risk acceptance is just undiscovered vulnerability.
Threat modeling is a collaborative activity. Here's how to run an effective threat modeling session:
Preparation (before the session):
Tips for effective sessions:
Frame threats as evil user stories: 'As a malicious actor, I want to [action] so that I can [achieve goal].' This format makes threats concrete and actionable. Example: 'As a malicious actor, I want to enumerate valid usernames so that I can target phishing attacks.'
A threat model is a living document that should be maintained alongside the system it describes. Good documentation enables future teams to understand security decisions and update the model as the system evolves.
Essential threat model components:
Example threat table format:
| ID | Component | Threat | STRIDE | Description | DREAD | Status | Mitigation |
|---|---|---|---|---|---|---|---|
| T001 | Login API | Credential Stuffing | S | Attacker uses breached credentials | 42 | Mitigated | Rate limiting + MFA |
| T002 | User DB | SQL Injection | T,I | Malicious input in search | 46 | Mitigated | Parameterized queries |
| T003 | Order API | Missing Auth | EoP | Endpoint lacks authentication | 38 | Open | Add JWT validation |
| T004 | Logs | PII Logging | I | Passwords logged in debug mode | 35 | Mitigated | Log sanitization |
| T005 | API Gateway | DoS | D | No rate limiting | 33 | Accepted | Compensating: CDN |
Storing threat models:
Treat threat models as code artifacts:
Consider making threat models part of your definition of done for new features. No design is complete until threats are identified and mitigated. This embeds security into your development process rather than treating it as an afterthought.
While threat modeling can be done with whiteboards and spreadsheets, specialized tools can improve efficiency and consistency:
Microsoft Threat Modeling Tool:
Free tool that uses DFD-based approach with automated STRIDE analysis. Generates threat reports based on diagram elements. Good for beginners and Microsoft-centric environments.
OWASP Threat Dragon:
Open-source, web-based threat modeling tool. Supports STRIDE, generates reports, integrates with version control. Cross-platform and free.
IriusRisk:
Commercial platform that automates threat modeling based on architecture patterns. Integrates with CI/CD for continuous threat assessment. Best for enterprises with mature security programs.
Threagile:
Open-source, code-based threat modeling. Define architecture in YAML, generate threat analysis programmatically. Fits DevOps workflows well.
| Tool | Type | Cost | Best For |
|---|---|---|---|
| Microsoft Threat Modeling Tool | Desktop app | Free | Windows environments, beginners |
| OWASP Threat Dragon | Web-based | Free | Cross-platform, open-source teams |
| IriusRisk | Commercial SaaS | $$$$ | Enterprise, compliance-heavy |
| Threagile | Code-based | Free | DevOps, infrastructure-as-code teams |
| Draw.io + Spreadsheet | Manual | Free | Small teams, ad-hoc modeling |
Threat modeling in CI/CD:
Advanced teams integrate threat modeling into their pipelines:
This doesn't replace human judgment but ensures threat modeling isn't forgotten as systems evolve.
The tool matters less than the practice. A team doing threat modeling with sticky notes on a whiteboard is better off than a team with expensive tools that never uses them. Start simple, add tooling as you mature.
We've covered the systematic practice of identifying and addressing threats before they become incidents. Let's consolidate the key takeaways:
What's next:
Now that we can identify and prioritize threats, we face a practical challenge: security often conflicts with usability. The next page addresses the critical tension between Security vs. Usability—how to design systems that are both secure and user-friendly, without sacrificing either.
You now understand threat modeling—the systematic practice of anticipating attacks and designing mitigations before writing code. This proactive approach is fundamental to building secure systems. Next, we'll explore how to balance security with usability.