Skip to content
Tutorials Center
My learning

Topics

Lesson 30 of 38 ยท Secure Development Lifecycle

Threat Modeling with STRIDE

Learn threat modeling step by step: draw a data flow diagram, mark trust boundaries, apply STRIDE to find threats, rate risk and record mitigations.

A threat model is a structured way to ask four questions about a system before you build it: What are we building? What can go wrong? What will we do about it? Did we do a good enough job? It is the main tool behind OWASP's A04: Insecure Design, because many serious weaknesses are design decisions, not coding slips, and no amount of careful code fixes a missing control.

Threat modeling needs a whiteboard and curiosity, not special software. This lesson walks through a small example and gives you a runnable helper that turns the results into a prioritized list. It sits within the secure development lifecycle.

Step 1: what are we building?

Draw a data flow diagram (DFD) with four element types:

  • External entities: people or systems outside your control (a customer, a payment provider).
  • Processes: your code (web app, API, worker).
  • Data stores: databases, files, caches.
  • Data flows: arrows showing data moving between them.

Then draw trust boundaries: dashed lines where the level of trust changes, such as between the internet and your servers, or between your app and a third-party service. Threats cluster where data crosses a boundary.

flowchart LR
    U["Customer (browser)"] -->|"HTTPS: login, order"| W["Web app"]
    W -->|"SQL"| D[("Orders database")]
    W -->|"HTTPS: charge request"| P["Payment provider"]
    A["Admin"] -->|"HTTPS: admin panel"| W

Trust boundaries sit between the customer, your web app, the database and the provider.

Step 2: what can go wrong? STRIDE

STRIDE is a mnemonic of six threat types. Each violates a security property:

Threat Violates Question to ask
Spoofing Authentication Can someone pretend to be another user or system?
Tampering Integrity Can data or code be changed without detection?
Repudiation Non-repudiation Can someone deny an action and we cannot prove otherwise?
Information disclosure Confidentiality Can data leak to the wrong party?
Denial of service Availability Can someone make the system unavailable?
Elevation of privilege Authorization Can someone do more than they should?

Walk each element and flow of the diagram and ask the six questions. Not every cell applies; ignoring those is fine, but ask before you skip.

STRIDE at a glance

Spoofing Pretending to be someone.
Tampering Changing data.
Repudiation Denying an action.

The first three.

1 / 2

Example threats for the shop

  • Spoofing: an attacker replays a stolen session cookie (control: short sessions, MFA, secure cookies).
  • Tampering: a user edits the price field in the order request (control: price from the server, never the client).
  • Repudiation: an admin issues a refund and later denies it (control: audit log with user ID and request ID).
  • Information disclosure: an error page shows a database query (control: generic errors; details only in logs).
  • Denial of service: the login endpoint is flooded (control: rate limits, caching, autoscaling).
  • Elevation of privilege: a customer calls an admin URL directly (control: server-side authorization on every request).

Step 3: rate and decide

You cannot fix everything first, so rank threats by risk = likelihood x impact. A simple 1-to-3 scale per factor is enough for a first pass. Methods like DREAD or CVSS exist, but the value is in having a consistent, shared ranking.

For each threat choose a response:

  • Mitigate: add a control (most common).
  • Eliminate: remove the feature.
  • Transfer: let someone else carry it (for example use a payment provider so you never store card numbers).
  • Accept: knowingly live with it, with an owner and a review date.
Python Rank threats and list mitigations

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The coverage line is a useful habit: an empty category often means "we did not think about it", not "it is safe".

Step 4: did we do enough?

Validate: do all high-risk threats have a mitigation that is implemented and tested? Turn each mitigation into a requirement or a test case (see Security Requirements and Code Review). Revisit the model when the design changes: new feature, new integration or new data type.

Checking trust boundary crossings

A helpful automation is to list every data flow that crosses a trust boundary, since each one needs authentication, validation and logging considered.

Python Find flows that cross trust boundaries

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Tips for a first workshop

  • Invite developers, a tester and someone who knows the business.
  • Timebox to one or two hours; model one feature, not the whole company.
  • Think like a misuser, but keep it respectful and focused on your own system.
  • Record the diagram and the threat list next to the code, and keep them up to date.
  • Use frameworks and cheat sheets for guidance, but do not let a template replace thinking.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What do trust boundaries show on a data flow diagram?

    Threats concentrate where data crosses a boundary, so those flows get the closest review.
  2. 2. In STRIDE, the user edits the price in the request. Which category is this?

    Changing data without authorization violates integrity, which is tampering.
  3. 3. Which response to a threat means removing the feature that creates it?

    Eliminating the feature removes the threat completely; mitigating adds controls, transferring shifts the burden, accepting keeps the risk.
  4. 4. Why does threat modeling help with Insecure Design?

    Design flaws cannot be fixed by perfect coding; they are found by reasoning about what could go wrong at design time.

Summary

  • A threat model answers: what are we building, what can go wrong, what will we do, did we do enough.
  • Draw a DFD with trust boundaries, then apply STRIDE to elements and flows.
  • Rank by likelihood and impact, choose mitigate, eliminate, transfer or accept.
  • Turn mitigations into requirements and tests, and update the model as the design changes.

Next: Security Requirements and Code Review