Four questions, Q1
Threat modelling means thinking through what could go wrong with a system during design, to fix problems before attackers find them. It follows four questions: what are we working on, what can go wrong, what will we do, did we do enough?
First, draw what you are building. Our example is a small online bakery. A customer (outside the shop) sends orders to the web app (a process), which saves them in a database (a data store). Arrows show the data flows.
Next, name the assets: customer details, password hashes and orders in the database, and the app staying online. Then ask who might cause harm: criminals after data or money, pranksters, or a careless insider. The attacker block stands for all of them.
A trust boundary is where data crosses between places we trust differently. Everything arriving from the internet could come from anyone, the attacker included. Most threats cluster where data crosses this line, so look there first.
Q2: what can go wrong
To answer "what can go wrong?", check each part against STRIDE: Spoofing, Tampering, Repudiation, Information disclosure, Denial of service, Elevation of privilege. Each letter breaks one security property, such as integrity or availability.
Spoofing: someone signs in as a customer using a stolen or guessed password. We write the threat into our list, a Python dict, with its fix: multi-factor authentication (MFA), so a password alone is not enough.
Tampering: the order's price is changed before it reaches the app, for example by editing the page in the browser. The mistake is trusting a price the browser sends. The fix: the app looks up every price itself.
Repudiation: a customer says "I never placed that order" and nobody can prove what happened. The fix is an audit log: the app records who did what and when, and keeps that record safe from changes.
Information disclosure: customer details leak from the database or its queries. One fix is least privilege: the app gets only the access it needs, so one bug cannot expose everything. Passwords are stored only as hashes, never as plain text.
Denial of service: a flood of requests makes the shop too busy for real customers; fix it with rate limits. Elevation of privilege: a customer reaches the staff admin page; fix it by checking their role on every request.
Q3 and Q4: respond, review
For each threat you choose a response. Mitigate: add a fix, as we did. Eliminate: remove the risky feature. Transfer: make another party responsible, like a payment provider. Accept: write down why the risk is small enough.
Finally, check: every threat on the list has a decision, and every fix is tested. Our program prints 6, one entry per threat. A threat model is never finished: run it again whenever the design changes.
What happens
;; step 1/12 · questions
threat model a careful look at what could go wrong
with a system, done while designing it
Q1 What are we working on?
Q2 What can go wrong?
Q3 What are we going to do about it?
Q4 Did we do a good enough job?
A real shop has more parts (a payment provider, staff laptops, a hosting company) and more threats than one per letter. The example keeps one threat per letter so each idea is clear. This course is about defence. It names a threat only at the level of the mistake and its fix, and never shows how to attack a real system.