Stage 2 of 8 · about 5–8 hours · beginner · checked 2026-11-26

Scope and data-flow diagrams

Goal. By the end you can scope a model, draw a data-flow diagram (DFD) with trust boundaries at a useful level of detail, and list the entry points and assets it shows.

Why it matters#

Question one, "what are we working on?", is where most models quietly fail. The diagram shows the system as one person remembers it, or it draws every server and cable but never says where data goes, or it is so large that nobody reviews it. A good diagram is a shared picture the team can argue over. Threats tend to follow data, so a picture of data and trust points you at the places to look.

What you will learn#

Scope: draw the box first#

Before you draw anything, write four short things:

  • In scope: the feature, service or change, for example this sprint's work, or the whole platform. The Manifesto advises scoping each round to a manageable portion of the system.
  • Out of scope, and why: "the payment provider's internals: we cannot change them, but we do model how we call them".
  • Assumptions: "the database cannot be reached from the internet". Write them so someone can check them later.
  • What changed: the new integration or feature that made you model now.

A finished small model beats an abandoned large one.

The five building blocks#

Element Classic symbol What it is Examples
External entity Rectangle A person or system outside your control that sends or receives data A member's browser, a payment provider
Process Circle (or rounded box) Code that does something with data Web app, API, background worker, pipeline job
Data store Two parallel lines (or a drum) Where data rests Database, queue, cache, storage bucket, config file
Data flow Arrow Data in motion An HTTPS request, a SQL query, a message, a file upload
Trust boundary Dashed line (or labelled box) Where the level of trust changes Internet to your hosting, user to admin, one customer's data to another's, build system to production

The first four come from classic DFDs. Microsoft's 2006 article adds a fifth, trust boundaries, for threat modelling. Conventions drift: Shostack later wrote down a "DFD 3" style with rounded boxes for processes and labelled boxes for trust boundaries, which is what Mermaid's subgraphs draw below. Pick one style, label every element and be consistent.

Trust boundaries and entry points#

A trust boundary is a border between more trusted and less trusted parts. Whatever crosses it deserves suspicion: who is on the other side, how do we know, and what do we check? Draw a boundary wherever a different person, team, account or privilege level is in control. Typical ones are the internet edge, each cloud account, each customer's tenant, and the line between the build pipeline and production. Treat the client side, such as a browser or a mobile app, as an external entity: an attacker can do whatever they like there.

Entry points are the places an outsider can put data in: public pages and forms, API endpoints, file uploads, webhooks, email, admin consoles, and, for pipelines, pull requests and third-party packages. Older OWASP guidance listed entry points, assets and trust levels as the things to identify when you decompose an application. Mark assets on the diagram too: which stores and flows carry personal, financial or secret data.

Levels of decomposition#

  • Level 0 (context): the whole system as one process, with the external entities around it. It answers "who talks to us?"
  • Level 1: the main processes and data stores inside. This is the workhorse for most models.
  • Level 2: one risky part, zoomed in: sign-in, payments, the deployment pipeline.

Zoom in only where a boundary is crossed or sensitive data moves. Keep each diagram readable on one screen: OWASP suggests a high-level overview next to detailed diagrams of individual components. A sequence diagram helps when one arrow hides a long conversation, such as a login with several redirects.

A small example#

Mermaid, a text-to-diagram language, renders directly in GitHub Markdown, so the diagrams stay in version control and show up in pull requests. Here is a Level 1 DFD of an invented club sign-up site:

Diagram: Visitor; Club admin; Email service; Trust boundary: our hosting account; Web app; Sign-up database

Open the diagram full size

Diagram source (Mermaid)
Mermaid
flowchart LR
    visitor["Visitor"]
    admin["Club admin"]
    mail["Email service"]
    subgraph hosting["Trust boundary: our hosting account"]
        web(["Web app"])
        db[("Sign-up database")]
    end
    visitor -->|"F1 sign-up form, HTTPS"| web
    admin -->|"F2 login and member export, HTTPS"| web
    web -->|"F3 member record, SQL"| db
    web -->|"F4 welcome email, HTTPS API"| mail

Everything inside the box is ours. The visitor, the admin and the email service are outside our control, so F1, F2 and F4 cross a boundary. F3 does not, but you will still ask whether the database accepts connections from anything other than the web app.

Sanity checks#

Microsoft's article offers rules of thumb that still hold:

  1. No magic sources or sinks. Every data store needs something that writes it and something that reads it. Data that goes in and is never read usually means a reader (an admin, a report job) is missing from the diagram.
  2. Data does not teleport. If two elements exchange data, there is an arrow, and it says how.
  3. Label every flow with the data and the protocol: "address and order, HTTPS".
  4. Show identity. How does each external entity prove who it is?
  5. Do not draw a network map. A DFD is about data and trust, not cables and racks.
  6. Check it against reality: the code, the infrastructure definitions or the cloud console, not memory.

Do this#

  1. Scope and draw (60–90 minutes). Pick a small system you know: a to-do app, a blog with comments, a home media server. Write the scope, out-of-scope list and assumptions, then draw Level 0 and Level 1 on paper. A good result has every arrow labelled with data and protocol, and at least two trust boundaries.
  2. Run the sanity checks (20 minutes). Mark each failure on the diagram and fix it.
  3. Redraw in Mermaid (30–45 minutes). Put it in a Markdown file in a repository of your own, or paste it into a Mermaid editor. Note what the text version cannot show as well as paper.
  4. Redraw in Threat Dragon (30–45 minutes). Use the demo site or desktop app. Compare its element types with the five above.
  5. List entry points and assets (30 minutes). For each entry point write who can reach it, what it accepts and how it authenticates. For each asset write where it lives and how sensitive it is.

Resources#

Free first

Paid or needs an account

  • None needed for this stage.

Checkpoint#

You are ready to move on when you can:

Go deeper (optional)#

  • OWASP Threat Modeling Process (Historical) - the older decompose-the-application approach with entry points, assets and trust levels, plus a note on modelling every story instead.
  • Draw one sequence diagram for a sign-in flow in your system, then compare it with the single arrow it replaces on the DFD.

0 / 6 checkpoints ticked

View this page on GitHub