Threat Modeling
Finding the flaws while they're still drawings
Threat modeling is structured pre-mortem thinking: what are we building, what could go wrong, and what must we do about it — using STRIDE per component and DREAD to prioritize.
What you will learn
- Draw a data-flow diagram and enumerate trust boundaries
- Apply STRIDE to each component and DREAD to prioritize
- Turn findings into concrete controls before code ships
What is this?
Threat modeling is the practice of systematically asking 'what could go wrong?' about a design. The classic walk: model the system (data-flow diagram, assets, trust boundaries), enumerate threats (STRIDE per element), prioritize (DREAD or likelihood/impact), and design mitigations. Done early, it catches architecture-level flaws that no code review will ever find.
Why do you need it?
- The most expensive security bugs are architectural — authentication confusion, insecure trust boundaries — and only visible on the drawing.
- Prevent-by-design beats detect-after-deploy by orders of magnitude.
- A threat model is shareable documentation: reviewers, auditors and attackers all read the same map.
- STRIDE gives names to what might otherwise be a vague 'this feels unsafe'.
Mental model
An architect walking a blueprint for break-in points
Threat modeling a software design
You find the ladder leading to the skylight while it's still a drawing, cheap. Same for software: threat modeling looks at a data-flow diagram and asks where the wrong people can get in before a single server is built.
How it works
- 1. Build a data-flow diagram (DFD): entities, processes, data stores, trust boundaries.
- 2. Enumerate per component with STRIDE: Spoofing, Tampering, Repudiation, Info disclosure, Denial of service, Elevation of privilege.
- 3. Prioritize with DREAD or likelihood x impact scoring.
- 4. Assign mitigations and owners, and track them like bugs.
- 5. Re-run the model when the architecture changes — modeling is a practice, not a one-shot report.
A small DFD with trust boundaries and STRIDE annotations.
In production
- A payments team models the transfer flow; STRIDE flags 'spoof another user's transfer' → they add object-level authZ and CSRF tokens.
- An SRE team models the observability pipeline; they find 'repudiation: no audit trail of who deleted the alert' → they add signed audit logs.
- A multi-tenant SaaS models tenant boundaries and finds elevation-of-privilege via shared service accounts → they tighten RBAC per tenant.
Best practices
- Model early and incrementally; a DFD per sprint-sized feature beats a giant retrospective document.
- Include a 'who is the attacker and what do they profit from?' assumption section — it keeps priority honest.
- Score threats (DREAD or risk matrix) and only fix the top decile; polish every detail helps no one.
- Record mitigations in the SAME issue tracker as bugs so they're owned and reviewed.
Common mistakes
- Modeling the happy-path only; attackers don't walk the happy path.
- A wall of DFDs with no prioritized actions — modeling without decisions is theater.
- Treating every element as equally trusted and missing the trust-boundary questions.
- One-and-done: the model goes stale the day the architecture changes.
Debugging tips
- When a finding 'feels important but vague', force it through STRIDE to name the risk ('it's spoofing, specifically the session token').
- Trace one user-A request through the whole DFD — trust boundaries you crossed are where controls and flaws both live.
- Compare the DFD against the real deployed topology; drift means the model missed a new boundary.
Security considerations
- Threat modeling is only as good as the assumptions; document who can do what at each step.
- Prioritization must consider business impact and attacker economics, not just exploitability.
Interview checkpoint
Hands-on lab
- Draw a data-flow diagram with explicit trust boundaries for a small toy app
- Apply STRIDE to every element and surface at least one threat per letter
- Score the top threats with likelihood x impact and choose mitigations
STRIDE a Toy App and Rank the Threats
30 min · intermediate
Quick quiz
In STRIDE, which letter covers an attacker guessing another user's session token?
Threat modeling is most valuable after a system has been in production for years.