Skip to content

Lesson 3 of 6

Threat modelling

Listen to an AI summary of Threat modelling

0:00 / 0:31

What is a threat model

A threat is something harmful that an attacker could do to an application.

A threat model is a written list of what an attacker wants, where the attacker can get in and what stops the attacker. A team writes the threat model when the team designs the software. The team updates the threat model when the design changes.

Build the model

The example is the sports shop. A customer can sign in, search, view an order, pay at the checkout and upload a photo.

Assets

An asset is something an attacker wants, such as customer data or money. The sports shop has three assets:

  • The passwords that customers sign in with.
  • The home addresses that orders are sent to.
  • The money that customers pay at the checkout.

Entry points

Each part of a request that the code reads is an entry point. Each labelled line of the request below is an entry point.

  1. POST /checkoutPOST sends data to the page /checkout
  2. User-Agent: Firefoxa header
  3. Cookie: session=abc123a cookie
  4. item=hoodie&size=L&price=25.00three form fields from the order form
One request to the checkout of the sports shop.

The trust boundary

The sports shop lets different people do different things. A visitor who has not signed in can look at the products. A customer who has signed in can place an order. An administrator can change prices.

Anyone on the internet can send a request to the sports shop. The shop does not know who sent a request until code on the server checks. Data in a request is trusted less than data that the shop already holds.

A trust boundary is a place where data passes from something less trusted to something more trusted. The sports shop has a trust boundary where a request from the internet reaches the application.

Checks at the trust boundary

Code on the server checks each request before the application acts on the request. One check tests that the customer is signed in. Another check tests that an order belongs to the customer who asks for the order.

A check is one kind of control.

  1. Browser

    anyone on the internet

  2. the trust boundary

    Sports shop application

    on the server, checks each request

  3. checked data

    Database

    the three assets: passwords, home addresses, money paid

A request passes the trust boundary when the request reaches the application.

Find the threats

The next part of the threat model is a list of threats. STRIDE is a list of six kinds of threat, used as a checklist. Each letter of STRIDE starts the name of one kind.

For each entry point, ask whether each of the six kinds could happen there.

S
Spoofing is pretending to be another person or another computer. An attacker guesses the password of a customer and signs in as that customer.
T
Tampering is changing data that the person is not allowed to change. A customer changes the price of a hoodie in a request.
R
Repudiation is denying an action when nothing written down shows who did the action. A customer says that someone else placed an order, and the shop cannot tell.
I
Information disclosure is a person reading data that the person should not see. A customer changes an order number and reads the home address of another customer.
D
Denial of service is making an application so busy that the application slows down or stops for everyone. A program sends the shop thousands of searches every second.
E
Elevation of privilege is a person gaining abilities that the person should not have. A customer opens the page that changes prices, and no code checks that the customer is an administrator.

Tampering in the sports shop

The request in the first picture has the form field price=25.00. The page fills in the price, so the customer never types a price. The browser runs on the customer's own computer, so the customer can change any line of a request before the request is sent.

  1. POST /checkoutPOST sends data to the page /checkout
  2. User-Agent: Firefoxa header
  3. Cookie: session=abc123a cookie
  4. item=hoodie&size=L&price=0.01the price, changed by the customer
The request with the price changed from 25.00 to 0.01.

Code on the server that charges the price in the request sells the hoodie for one penny. Trusting the price from the request is a weakness.

The control is a check on the server. The server ignores the price in the request and looks up the price of a hoodie in the database. A later lesson on rules the code must enforce covers checks like this one in more depth.

Repudiation and the log

A log is a list that software writes of what happened and when. The log of the sports shop has an entry for each order:

2026-11-13 09:14  customer sam placed order 1042

The entry says which account placed order 1042 and when. A customer who denies placing the order can be shown the entry.

Rank the threats

Rank each threat by risk and deal with the threat at the top of the list first.

Any customer with a browser can change the price in a request, and the shop loses money on each order. The price threat goes near the top. Thousands of searches can slow the shop but leak no data, so the search threat goes lower.

The price check on the server reduces the price risk.

Use the threat model in a review

The threat model tells a reviewer which changes need the most care. A change to the checkout code can affect the money, so the reviewer reads that change more slowly than a spelling fix.

Check your understanding

  1. Name three assets of the sports shop.

    Show the answer

    The passwords of customers, the home addresses of customers and the money paid at the checkout.

  2. Which kind of threat in STRIDE is a customer changing an order number to read another customer's home address?

    Show the answer

    Information disclosure. The customer reads data that the customer should not see.

  3. Give one reason why code on the server must not charge the price in a request.

    Show the answer

    The customer can change any line of a request, so the customer could choose the price.