How to Draw a Data Flow Diagram for Web Threat Modeling
A security data flow diagram (DFD) shows where data enters a system, how processes handle it, where it is stored or sent, and where trust assumptions change. Separating external actors, processes, data stores, flows, and trust boundaries gives threat analysis a concrete starting map. A DFD does not identify vulnerabilities or prove security; it is a model to validate against the real architecture and update over time.
How to Draw a Data Flow Diagram for Web Threat Modeling
A security data flow diagram (DFD) shows where data enters a system, how processes handle it, where it is stored or sent, and where trust assumptions change. Separating external actors, processes, data stores, flows, and trust boundaries helps the team locate inputs and boundary crossings for threat analysis. A DFD itself does not identify vulnerabilities or prove security.
Five elements
**External entity:** a person, browser, or service outside the modeled scope that sends or receives data. Who controls it and grants its permissions?
**Process:** a component that reads, decides on, transforms, or acts on data. What does it validate, transform, or authorize?
**Data store:** a place where data persists. What is stored, and who can read or write it?
**Data flow:** movement between elements. What data moves, and in which direction?
**Trust boundary:** a point where control, permissions, or trust assumptions change. What identity, input, or authorization must be checked again across it?
A network boundary is not automatically a trust boundary. Service accounts, tenants, or operators can have different authority inside one network. Base boundaries on actual control and assumptions. The text diagram below uses a simple illustrative notation; use your organization’s notation consistently.
Hypothetical example: web checkout
This is an illustrative high-level assumption, not an observation of a real service. The direction and endpoints of each arrow matter.
[1 Customer browser] --order input--> || Internet/app boundary || --> (2 Web/API)
| |
read/write order authorize
v v
[3 Orders DB] || app/provider boundary || --> [4 Payment service]
[4 Payment service] --result--> (2 Web/API)
(2 Web/API) --confirmation--> [1 Customer browser]| Flow | From → to | Data or assumption to check |
|---|---|---|
| F1 | Browser → Web/API | Order and delivery data, session; transport protection assumptions |
| F2 | Web/API ↔ Orders DB | Order/payment state; service identity and read/write rights |
| F3 | Web/API → Payment service | Authorization request and external API credentials |
| F4 | Payment service → Web/API | Result/reference ID; how the result is verified before trust |
| F5 | Web/API → Browser | Confirmation; whether sensitive data is unnecessarily exposed |
The browser and payment provider are assumed to be controlled separately from the application. If the database is managed in a distinct account or administrative domain, show a boundary between the app and store too. Do not place boundaries based only on labels such as “Internet” or “internal network”; check account ownership, service identity, deployment responsibility, and access policy.
A practical modeling and review sequence
**State purpose and scope.** For example: “Review the checkout flow where a signed-in member places an order and the app requests authorization from an external payment provider.” Name what is in and out of scope and which design/deployment view is modeled.
**Find actors and entry/exit points.** Include browsers, external APIs, identity providers, webhooks, admin tools, and inputs/outputs. Inputs can arrive through APIs, files, events, or callbacks, not just forms.
**Separate processing from storage.** The Web/API that validates an order is a process; the database that persists order state is a store. Split components enough to examine threats, but not every class or function. For complex systems, keep a high-level view and detail important components separately.
**Label flow meaning and direction.** Name the data and purpose on each arrow. Annotate protocol, encryption/authentication assumptions, and sensitivity when useful. Draw requests, responses, queues, and webhooks separately when their direction or trust path differs.
**Mark boundaries where controls change.** Show where identity, authorization, operational responsibility, or security assumptions change: Internet/app, app/provider, or services with different rights. Ask what is validated, rejected, or logged at each crossing. A private network or one cloud account is not a reason by itself to trust every component.
**Validate with component owners.** Check that every flow connects to real elements, storage inputs/outputs are present, and arrows point correctly. Compare API contracts, deployment configuration, and service-call behavior. Record unknown connections as assumptions or open questions instead of inventing them.
**Use the DFD as input to threat analysis.** It answers “What are we working on?” Threat identification, risk prioritization, responses, and review follow as separate work. STRIDE can prompt questions about components, flows, and boundaries, but a DFD alone does not find every threat.
Common mistakes
A network-only drawing omits data meaning and validation. Missing external identity/payment providers, webhooks, or admin tools can hide boundaries and inputs. Do not merge a request and response into a directionless arrow; separate their directions. Avoid putting every class and function on one page; use a high-level view and focused details. Confirm the diagram reflects the real system with component owners and update it when the architecture changes.
A DFD is a shared map for reviewing data movement and control assumptions. OWASP’s threat-modeling guidance recommends checking that a DFD or comparable model accurately represents the system.
Sources
OWASP, [Threat Modeling Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Threat_Modeling_Cheat_Sheet.html) — DFD purpose and elements, hierarchical views, and model accuracy review.
Microsoft Learn, [Threat Modeling Tool feature overview](https://learn.microsoft.com/en-us/azure/security/develop/threat-modeling-tool-feature-overview) — examples of processes, external interactors, stores, flows, and trust boundaries.
Microsoft Learn, [Getting Started with the Microsoft Threat Modeling Tool](https://learn.microsoft.com/en-us/azure/security/develop/threat-modeling-tool-getting-started) — a basic user/web server/database/trust-boundary model; last updated 2022-08-25.
OWASP, [Threat Model Library](https://devguide.owasp.org/en/04-design/01-threat-modeling/06-threat-model-library/) — example structure for scope, actors, components, stores, trust zones/boundaries, flows, and assumptions.