Threat Modeling and Data Flow
Draw one sensitive action from the person to the data, then turn likely failures at each trust boundary into a control and a check you can see.
Content date: October 15, 2026.
Plain English
A threat model is a short, honest description of the system you plan to run. It lists what is worth protecting (the assets) and how misuse or failure could hurt it. A trust boundary is a point where information crosses into a party or system you should not trust automatically, such as a browser sending a request to your server. OWASP frames the work as four questions: What are we working on? What can go wrong? What will we do about it? Did we do well enough?
Use this when
Do it before you add private records, uploads, payments, remote tool access, or any sensitive workflow, and redo it when the data, the people, an outside service, or the exposure changes.
If you are just starting
Pick one action, such as a parent cancelling a tutoring session. Draw the person, the browser, the server, and the data store. Label what travels between them: who is asking, what they typed, who owns the record, and what comes back. Circle what the caller can change, and mark which part makes the final decision. Write three short failure stories, each with a control, an owner, and a check you can watch happen.
When your project grows
Add background jobs, admin and support tools, logs, backups, and outside providers whenever they carry data or can act on it. Rank failures by how bad the outcome would be and how exposed the feature is, and write down your assumptions. Trace each important control to the code that enforces it and the test that proves it. A diagram, or an AI-written threat list, does not show a control exists. For health or payment data, have a security professional review the model.
Worked example
A tutoring site lets parents cancel sessions. The request says "cancel booking 1042." The caller picks the booking but must not pick its owner. The server works out who is asking, looks up who owns 1042, and only then changes anything. If an attacker edits the number to 1043, which belongs to another family, the check refuses. Hiding the Cancel button would not have stopped that. The fixture uses fixed demo identities, so real login and session checks stay listed as a gap.
Practice
Map and challenge one trust boundary
- Read the worksheet and architecture fixture, then draw one cancellation request and its response.
- Label what the caller can change, which decisions the server makes, what is stored, and what only works locally.
- Write three failure stories, including a booking owned by someone else and a request with no identity. Give each a control and a check.
- Run the supplied checks and note, for each story, whether you saw the control work or it is still a gap.
- Add a proposed email integration to your drawing. Write down who receives what data, what a retry does, and what authority it gets.
Deliverable: A workflow map and a table linking each risk to its control and evidence, with owners and review triggers.
Common mistakes to watch for
- The model leaves out a CSV export, a support dashboard, or an email provider that also receives customer data.
- A form field such as userId or role is treated as proof of identity, so anyone can edit it.
- A risk is written down, but nobody owns it and no test covers it.
- The diagram still describes the old design after the workflow changed.
Prompting
A weak prompt
Make me a comprehensive security diagram and mark every threat as handled.
A better prompt
Map this one workflow, [for example, a parent cancelling a booking], using the real code and configuration. List the actors, assets, data flows, and trust boundaries, including admin tools, logs, and outside services. Separate controls you found in the code from assumptions. For each serious failure story, name the enforcing component, a small check I can run, an owner, and the remaining risk. Do not claim security because a diagram exists.
Without a map, fixes land wherever someone happened to look, and a hidden button gets mistaken for a locked door.
Check before you move on
- You bounded one workflow.
- Actors and assets are named.
- Caller-controlled inputs are marked.
- The server makes each permission decision.
- Each control has a check.
- Missing controls are labeled missing.
You are done when
- A reviewer can follow the data and the permission decisions through the real workflow without asking you what you meant.
- Every serious risk has either a control you observed working or a named person responsible for fixing it.
Questions to think about
Your app hides the Cancel button from non-owners, but someone sends the request directly. Where must the permission check happen?
On the server, where the change is made, using the verified identity and the stored owner. Anyone can send requests without your page, so hiding a button controls nothing.
You reviewed a diagram last month, then added an email service for booking confirmations. Is the old model enough?
No. The service receives customer data, holds a credential, retries sends, and can fail in new ways. Add it to the map.
An AI tool lists twelve threats and says each is covered. What else do you need?
A pointer from each threat to the code or setting that blocks it and a test showing it works. A list shows what someone thought of, not what was built.