Security Notes
Start here

Threat Modelling — Deep Dive

12 min read 7 sections 7 model answers

Breadth layernotes-security-core-knowledge.md covers the definitions (STRIDE letters, DREAD, PASTA). This page is about doing it: drawing the system, finding the threats, ranking them, and answering "threat model this" in an interview.


What Is Threat Modelling?

What is this?Threat modelling is a structured conversation about a system before (or while) it is built: what are we building, what can go wrong, what are we going to do about it, and did we do a good enough job? Those four questions come from Adam Shostack's book Threat Modeling: Designing for Security (2014) and are the simplest way to remember the whole method.

Why it mattersDesign flaws are the expensive ones. A missing authorization check in a design becomes a missing check in every endpoint built from it. OWASP lists "Insecure Design" as A06 in its 2025 Top 10. Interviewers use "threat model this system" because it shows in 30 minutes whether you can reason about a system you have never seen, rather than recite vulnerability names.

How it works

  1. What are we working on?Model10 min
    • Draw a data-flow diagram: users, processes, data stores, external systems
    • Mark trust boundaries: every place data crosses from less trusted to more trusted
  2. What can go wrong?Threats15 min
    • Walk every boundary crossing with STRIDE
    • Ask "how would I abuse this?" for each flow, not each box
  3. What are we going to do about it?Controls10 min
    • One control per threat: prevent, detect, or accept with an owner
    • Rank by likelihood × impact; fix the top few first
  4. Did we do a good job?Check5 min
    • Every boundary has at least one threat considered
    • Every high threat has a ticket, an owner and a test

Step 1 — Draw the System

What is this?A data-flow diagram (DFD) shows how data moves, not how code is organised. It has only five shapes, which keeps it fast:

External entity

Something outside your control: a user, a partner API, an attacker

Process

Code that transforms data: a web app, a Lambda function, a worker

Data store

Where data rests: a database, a bucket, a queue, a cache

Data flow

An arrow: a request, a message, a file transfer

Trust boundary

A dashed line where the level of trust changes: internet to app, app to database, tenant to tenant

In practiceA file-sharing feature drawn in two minutes:

                 ┆ trust boundary: internet → company
  [User browser] ┆──HTTPS upload──▶ (API service) ──signed PUT──▶ [[S3 bucket: uploads]]
                 ┆                        │                              │
                 ┆                        │ writes row                   │ S3 event
                 ┆                        ▼                              ▼
                 ┆                 [[Postgres: files]]   ┆   (Thumbnail worker) ──▶ [[S3: thumbnails]]
                 ┆                                       ┆ ← boundary: worker parses untrusted files
  [Recipient] ◀──┆──── share link (GET /f/{id}) ─────────┆

The arrows crossing a dashed line are where nearly every serious threat lives. Here: the upload, the share link, and the worker that parses files a stranger chose.

Memory hook

threats live on the arrowsBoxes are what you built; arrows are where something you don't control talks to something you do. If you only have five minutes, list the arrows that cross a trust boundary and ask STRIDE questions about each one.


Step 2 — Find the Threats with STRIDE

What is this?STRIDE is a checklist of six ways things go wrong, each the opposite of a security property. Its value is that it forces you past the threats you already thought of.

ThreatQuestion to ask on each flowExample in the file-sharing design
SpoofingCan someone pretend to be another user or service?Share link is guessable (/f/1042), so anyone can fetch other files
TamperingCan data be changed in transit or at rest?Client sets Content-Type: image/png on an HTML file, served back as HTML → stored XSS
RepudiationCould someone deny doing it, and could we prove otherwise?No log of who downloaded a shared file
Information disclosureCan data leak to the wrong party?Bucket policy allows public list; thumbnails keep EXIF GPS data
Denial of serviceCan someone exhaust a resource?50 GB upload, or a zip bomb that the thumbnail worker expands
Elevation of privilegeCan someone gain rights they shouldn't have?ImageMagick-style parser bug gives code execution in the worker, which holds an IAM role over every bucket

STRIDE per elementNot every letter applies to every shape. Shortcut:

External entityS R
ProcessS T R I D E
Data storeT I D (R if it holds logs)
Data flowT I D
External entity
Spoofing and repudiation: who is really calling, and can they deny it?
Process
All six: processes are where logic and privilege live
Data store
Tampering, disclosure, exhaustion
Data flow
Changed, read or blocked in transit

Other lenses worth one sentence each in an interview:

Attack trees.

Put the attacker's goal at the root ("read another tenant's files") and branch into ways to reach it. Good for showing that two medium issues combine into a critical one.

MITRE ATT&CK.

Use it for "what would a real intrusion of this look like, and would we see it?" It links the model to detection.

LINDDUN.

STRIDE's privacy counterpart (linking, identifying, non-repudiation, detecting, data disclosure, unawareness, non-compliance), useful when personal data is the main asset.

PASTA.

A seven-stage, business-risk-driven process; heavier, used where a formal risk record is required.

📰

Real incident — Capital One (2019). A web application firewall on EC2 could be tricked into fetching an attacker-supplied URL (SSRF). It fetched the instance metadata service, which returned temporary credentials for the instance's IAM role, and that role could list and read S3 buckets holding about 106 million customer records. On a data-flow diagram this is one arrow, "WAF → metadata service", crossing a boundary nobody drew. Threat modelling asks what each process can reach, not only what it is meant to reach.


Step 3 — Rank and Decide

What is this?A threat model with 60 equal threats is useless. Rank them, fix the top ones, and write down who accepted the rest.

How it works

Likelihood × impact, in three levels.

High, medium or low for each is enough in a design review. Precision theatre wastes the meeting.

Likelihood

rises with: reachable from the internet without authentication, known exploit techniques, a valuable target.

Impact

rises with: data volume and sensitivity, number of tenants affected, safety or money involved, how hard it is to undo.

DREAD

(damage, reproducibility, exploitability, affected users, discoverability) was Microsoft's numeric score; Microsoft itself dropped it because different people scored the same threat very differently.

CVSS

scores a known vulnerability in shipped software, not a design. Don't use it for threat models.

Each threat ends in one of four decisions:

Mitigate

Add a control and a test that proves it (most threats)

Eliminate

Remove the feature or the data: no stored card numbers means no card theft

Transfer

Make someone else carry it: a payment provider, insurance, a contract

Accept

Documented, with a named owner and a review date. Never silently

In practiceWhat the output looks like in a ticket tracker. This is what interviewers mean by "actionable":

text
TM-FILESHARE-03  Thumbnail worker parses untrusted images with full S3 access     Risk: HIGH
  Threat (E):  parser RCE → worker IAM role → read/write every bucket
  Control:     worker runs in a sandbox with no network; role limited to
               s3:GetObject on uploads/* and s3:PutObject on thumbnails/*     ← least privilege removes the blast radius
  Test:        integration test asserts AccessDenied on s3://uploads-other-tenant/
  Owner:       platform-team   Due: before GA
🎯

On the job. Threat modelling happens in design reviews, usually from a one-page design doc. The useful questions are almost always the same:

  • Where are the trust boundaries?
  • Who can call this without logging in?
  • What can this process reach if it is fully compromised?
  • Where are secrets stored, and who can read them?
  • What do we log, and would we notice abuse?
  • What happens when a dependency is down: does it fail open or closed?

The best outcome is a design change before code exists, not a list of findings after launch.


Worked Example — A Cloud Data Pipeline

Partners upload CSV files over SFTP; a Lambda function validates them and loads them into a data warehouse; analysts query it from a BI tool.

[Partner] ──SFTP──▶ (AWS Transfer) ──▶ [[S3 landing]] ──event──▶ (Lambda: validate+load) ──▶ [[Warehouse]] ◀── (BI tool) ◀── [Analyst]
          ┆ boundary 1: internet                     ┆ boundary 2: untrusted file content      ┆ boundary 3: humans querying data
BoundaryThreatControl
1Spoofing: a stolen partner SSH key uploads poisoned dataPer-partner keys, source-IP allowlist, alert on uploads at unusual times
1Information disclosure: partner A lists partner B's folderPer-partner home directory, scoped IAM role per user
2Tampering: CSV formula injection (=HYPERLINK(...)) executes when an analyst opens an exportEscape leading = + - @ on export
2Elevation: the Lambda role can also write to production tables it doesn't loadRole limited to INSERT on staging schema; promotion job runs separately
2Denial of service: a 10 GB file times out the Lambda and retries foreverSize limit at upload, dead-letter queue, alert on DLQ depth
3Information disclosure: analysts see raw personal data they don't needColumn masking, row-level security, query logging
AllRepudiation: no proof of who uploaded or queried whatCloudTrail data events on the bucket, warehouse query history kept for one year

For an AI agent example (prompt injection, tool permissions, MCP servers), see Agentic AI and MCP security.

📰

Real incident — Storm-0558 (2023). Attackers used a Microsoft consumer-account signing key to forge tokens that Exchange Online accepted for enterprise mailboxes, reading email at US government agencies. Two trust domains, consumer and enterprise, were supposed to be separate, but token validation didn't check which domain a key belonged to. The US Cyber Safety Review Board described it as a cascade of avoidable errors. A threat model asking "what stops a consumer key from signing an enterprise token?" is exactly the boundary question that catches this.


Answering "Threat Model This" in an Interview

What is this?A 30–45 minute exercise: the interviewer names a system ("a URL shortener", "our CI pipeline", "a chatbot with access to customer orders") and watches how you think.

  1. Ask before drawingClarify3 min
    • Who are the users? What data is sensitive? Internet-facing? Multi-tenant?
  2. Sketch the data-flow diagram out loudDraw7 min
    • Name the trust boundaries explicitly: "this arrow crosses from the internet"
  3. STRIDE on the boundary crossingsThreats15 min
    • Lead with the highest-impact threat, not the first letter
  4. One concrete control each, then rankControls10 min
    • Prevent, detect, respond: mention logging and alerting, not only prevention
  5. Summarise top three risks and what you'd ship firstWrap2 min

What interviewers listen for

  • You ask clarifying questions instead of assuming.
  • You name trust boundaries, not just components.
  • You rank, and say why the top threat is the top threat.
  • You include detection and response, not only prevention.
  • You use concrete controls ("scope the role to s3:GetObject on one prefix"), not slogans ("use least privilege").

Interview Questions

Q
Walk me through how you threat model a new service.
Model answer

I follow the four questions: what are we building, what can go wrong, what do we do about it, and did we do enough. I draw a data-flow diagram with the trust boundaries marked, then walk STRIDE over every arrow that crosses a boundary, because that's where untrusted input meets privilege. I rank threats by likelihood and impact in three levels, assign each a decision (mitigate, eliminate, transfer or accept with an owner), and turn the high ones into tickets with a test that proves the control works. Capital One's 2019 breach is my reminder to ask what each process can reach if compromised, not just what it is supposed to reach.

Q
What does each letter of STRIDE protect, and which applies to a data store?
Model answer

Spoofing breaks authenticity, tampering breaks integrity, repudiation breaks accountability, information disclosure breaks confidentiality, denial of service breaks availability, and elevation of privilege breaks authorization. For a data store the main ones are tampering, disclosure and denial of service: can someone change it, read it or fill it up. Repudiation applies too when the store holds audit logs, because tampering with logs lets someone deny what they did.

Q
Why did DREAD fall out of use, and how do you prioritise instead?
Model answer

DREAD gave each threat a numeric score across five factors, but different reviewers scored the same threat very differently, so the numbers looked precise without being reliable, and Microsoft itself stopped using it. I use likelihood times impact in three levels. Likelihood goes up when something is internet-reachable without authentication or uses known techniques; impact goes up with data sensitivity, tenant count and how hard it is to undo. The goal is agreeing on the top three, not perfect scores.

Q
What is a trust boundary? Give an example people often miss.
Model answer

A trust boundary is any point where data or control passes between parties with different levels of trust, like internet to application or application to database. The ones people miss are inside the company: a worker that parses user-uploaded files is processing untrusted input even though it's internal, a CI job running code from a fork, or a service that can reach the cloud metadata endpoint. Storm-0558 is a good example: consumer and enterprise signing keys were meant to be separate trust domains, but nothing enforced that boundary when validating tokens.

Q
How does threat modelling connect to detection engineering?
Model answer

Every threat you decide to mitigate also needs an answer to "how would we know if it happened anyway?" So the threat model produces detection requirements: if the threat is a stolen partner key uploading poisoned files, the detection is an alert on uploads from new IPs or at unusual times. Mapping threats to MITRE ATT&CK techniques gives detection engineers a shared vocabulary and shows coverage gaps, and accepted risks are exactly where you want monitoring because you chose not to prevent them.

Q
When should a team redo its threat model?
Model answer

When a trust boundary changes: a new external integration, exposing an internal service to the internet, adding multi-tenancy, a new kind of sensitive data, or giving an AI agent tool access. Also after an incident or a penetration-test finding that the model didn't predict, because that shows a blind spot in the method. I prefer small, frequent updates tied to design docs over one big annual exercise that nobody reads.

Q
How do you threat model something with an AI component?
Model answer

The same method, with one extra assumption: any text the model reads can become an instruction, so every data source feeding the model is a trust boundary. I list what the model can read, which actions its tools can take, and whose credentials it uses, then check for the lethal trifecta: private data, untrusted content and an outbound channel in one session. The 2025 GitHub MCP attack, where a public issue made an agent leak private repos, is what that looks like when nobody checks. The controls are mostly about limiting tools and permissions, because prompt injection itself can't be fully prevented.