Security Foundations
Intermediate 16 min read Security Foundations

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.

threat modelingSTRIDEDREADattack surfacedata flowthreat actors
Before we start

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
Introduction

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.

Motivation

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'.
Think about it

Mental model

Imagine

An architect walking a blueprint for break-in points

Think of

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.

Mechanics

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.

Browser
TLS boundary
API gateway
App services
DB store
Admin UI
Real world

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.
Guidelines

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.
Watch out

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.
When things break

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

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.
Interviews

Interview checkpoint

Practice

Hands-on lab

STRIDE a Toy App and Rank the Threats
30 min · intermediate
In progress
Objectives
  • 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

0/6 steps
0%
sandbox · Linux sandbox
$
Try these commands
Test yourself

Quick quiz

0/2
1

In STRIDE, which letter covers an attacker guessing another user's session token?

2

Threat modeling is most valuable after a system has been in production for years.

Go deeper

Official documentation