Threat Modeling Best Practices

Chapter 2 · Practice 1 of 4

Draw a data flow diagram with the standard elements

From What are we working on: diagrams and trust boundaries

Why it matters

The OWASP cheat sheet calls data flow diagrams (DFDs) the most common way to model a system for threat modeling. A DFD shows what talks to what and where data goes, using a small set of elements:

ElementWhat it isExamples
External entitysomething outside your control that sends or receives datauser, browser, partner API, payment provider
Processcode you run that handles dataAPI server, worker, Lambda, LLM agent loop
Data storewhere data restsPostgres, S3 bucket, Redis, vector index, logs
Data flowdata moving between elements, labeled with what and how"login request, HTTPS", "job payload, SQS"
Trust boundarya line where the level of trust changesinternet to your VPC, your app to a third party

OWASP says these are typically where attacks happen, so a diagram that shows them gives the next step something to work with.

Tips that keep diagrams useful:

  • Label flows with the data and protocol, not just an arrow.
  • Start with a high-level view, and add detailed diagrams only for complex parts, as OWASP suggests.
  • Include the boring parts: logs, backups, admin panels, CI/CD and support tools. Those are often the weak paths.
  • Draw what is built (or will be), not the ideal architecture from a slide.

Example

Code
flowchart LR
  user([Customer browser]) -- "checkout form, HTTPS" --> api[Orders API]
  subgraph vpc [Trust boundary: our VPC]
    api -- "SQL, TLS" --> db[(Orders DB)]
    api -- "job, SQS" --> worker[Invoice worker]
    worker -- "PDF" --> s3[(Invoices bucket)]
  end
  api -- "charge request, HTTPS" --> psp([Payment provider])
  psp -- "webhook, HTTPS" --> api