Security Playbook
01 · FundamentalsOWASP A06:20258 min read

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.

Threat modeling an online shop with STRIDE
trust boundaryCustomer browserWeb appOrders APIDatabasePayment providerAdmin panel
E · Orders APIThreatCustomer reads another customer's order (IDOR)MitigationCheck ownership on every request
R · Orders APIThreatNo record of who cancelled an orderMitigationAudit log with user and time
Tap a component or a STRIDE letter
Tap a component to see its threats, or a STRIDE letter to see that kind of threat across the whole system.

STRIDE: six questions for every box

LetterThreatProperty it breaksTypical fix
SSpoofingAuthenticationMFA, signed tokens, mutual TLS
TTamperingIntegrityServer-side validation, signatures, checksums
RRepudiationNon-repudiationAudit logs that can't be edited
IInformation disclosureConfidentialityAccess checks, encryption, minimal responses
DDenial of serviceAvailabilityRate limits, quotas, autoscaling
EElevation of privilegeAuthorizationLeast privilege, checks on every request

A 30-minute threat model

  1. Draw it: components, data stores, external services and the data flowing between them.
  2. Mark trust boundaries: internet, internal network, third parties, admin tools.
  3. Walk STRIDE for each boundary-crossing flow and write the threats down.
  4. Rank them: how likely, how bad. Fix the high ones now, ticket the rest.
  5. 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