Threat modeling: finding the holes before you write the code
A structured way to ask what could go wrong in a system before attackers do. Draw the system, mark the trust boundaries, walk through STRIDE, and turn every threat into a mitigation.
In one sentence
Threat modeling is answering four questions: what are we building, what can go wrong, what are we going to do about it, and did we do a good job?
The idea
Most security bugs aren't exotic. They're a missing check that nobody thought about because nobody asked "what if someone sends a different ID?". Threat modeling is the habit of asking those questions at design time, when fixing them costs a whiteboard eraser instead of an incident.
You don't need a security team for it. Draw the boxes, draw the arrows, and mark where data crosses from a place you don't control to one you do. That line is a trust boundary, and almost every threat lives on one.
STRIDE: six questions for every box
| Letter | Threat | Property it breaks | Typical fix |
|---|---|---|---|
| S | Spoofing | Authentication | MFA, signed tokens, mutual TLS |
| T | Tampering | Integrity | Server-side validation, signatures, checksums |
| R | Repudiation | Non-repudiation | Audit logs that can't be edited |
| I | Information disclosure | Confidentiality | Access checks, encryption, minimal responses |
| D | Denial of service | Availability | Rate limits, quotas, autoscaling |
| E | Elevation of privilege | Authorization | Least privilege, checks on every request |
A 30-minute threat model
- Draw it: components, data stores, external services and the data flowing between them.
- Mark trust boundaries: internet, internal network, third parties, admin tools.
- Walk STRIDE for each boundary-crossing flow and write the threats down.
- Rank them: how likely, how bad. Fix the high ones now, ticket the rest.
- Revisit when the design changes: new feature, new integration, new kind of user.
Key takeaways
- 01Threat modeling happens at design time and is cheap; incidents are not.
- 02Draw the system and the trust boundaries: threats cluster where data crosses them.
- 03STRIDE gives you six questions to ask of every component and flow.
- 04Every threat should end as a mitigation, an accepted risk, or a ticket.
Check your understanding
1 of 3
What are the four questions of threat modeling?
Related concepts
Defense in depth
Every control has holes. Line up several independent ones and the holes rarely align: the Swiss cheese model.
6 min read →Least privilege
Assume something will get hacked. Least privilege makes sure that when it does, the attacker gets the keys to one room, not the whole building.
6 min read →AuthN vs AuthZ
Authentication answers *who are you?* Authorization answers *are you allowed to do this, to this thing, right now?* Most breaches of web apps are the second one missing.
6 min read →