What is threat modeling?
Threat modeling is planning for security before something goes wrong. You look at a system, like an app, a website, or even your own phone, and you ask: what could go wrong here, and what will we do about it?
You already do this without noticing. Before a trip, you might think, "My bag could get stolen, so I'll keep my phone in my front pocket." That's a tiny threat model. Security teams just do it on purpose, write it down, and do it early, while fixing problems is still cheap and easy.
Most teams follow four simple questions, made popular by security expert Adam Shostack. Throughout this tutorial we'll use them on one example: HomeworkHub, a made-up school app where students upload homework and teachers post grades. Click each question to see it in action.
The four questions applied to HomeworkHub
Simple definition: threat modeling means looking at what you're building, imagining what could go wrong, and deciding what to do about it, before an attacker shows you.
Map the system
You can't protect something you don't understand, so the first step is to draw it. Security teams sketch a data flow diagram: boxes for the parts of the system and arrows for the information moving between them. While drawing, they keep six words in mind.
- Asset
- Anything worth protecting. For HomeworkHub: grades, homework files, passwords, and students' names.
- Threat actor
- Whoever might cause harm, on purpose or by accident: an online scammer, a classmate who wants to change a grade, or a teacher who clicks a bad link.
- Threat
- One specific thing that could go wrong, like "someone signs in as a teacher." It's a possibility, not something that already happened.
- Attack surface
- All the places where someone could poke at the system: login forms, upload buttons, share links, emails. Smaller surface, fewer places to defend.
- Trust boundary
- A line where data moves between parts that trust each other differently, like from a student's phone into the school's server. Threats love to show up here.
- Data flow
- An arrow on the diagram: information moving from one place to another, like a homework file going from phone to server.
Try it: the HomeworkHub whiteboard
Click any box to see what it holds and what could go wrong there. Then switch on the two overlays to see the trust boundaries and the attack surface.
Data flow diagram HomeworkHub
files trust boundary
← start here Pick a box on the diagram to inspect it.
Key idea: most threats cluster where an arrow crosses a trust boundary. Anything coming from the other side of the line should be checked, not just trusted.
STRIDE: six kinds of trouble
When people try to answer "What can go wrong?" they often think of one scary thing and stop. STRIDE is a checklist, first created at Microsoft, that pushes you to think of six different kinds of trouble. Each letter is the opposite of a good security property you want to keep.
Spoofing
breaks: who you arePretending to be someone else. Like a fake account named after your teacher.
Tampering
breaks: data stays correctChanging something you shouldn't. Like secretly editing the due date on a shared assignment.
Repudiation
breaks: proof of who did itSaying "it wasn't me" when nobody can prove otherwise, because nothing kept a record.
Information disclosure
breaks: secrets stay secretPrivate info reaching the wrong people. Like a grade popping up on a phone's lock screen.
Denial of service
breaks: it's there when neededMaking something unusable. Like flooding a site so it crashes the night homework is due.
Elevation of privilege
breaks: only allowed actionsGetting powers you aren't supposed to have. Like a student reaching the teacher-only grade page.
Try it: STRIDE sorter
Read each sticky note and pick the STRIDE letter that fits best. Some threats touch more than one category; pick the main one.
Risk = likelihood × impact
Once you have a pile of sticky notes, you can't fix everything at once. Defenders rank threats by risk, using two questions:
- Likelihood: how likely is this to actually happen? Does it take a genius, or could anyone do it by accident?
- Impact: if it does happen, how bad is it? A small annoyance, or lost grades and leaked private info?
Rate each from 1 (low) to 3 (high) and multiply. A threat that is both likely and harmful (3 × 3 = 9) goes to the top of the list. A rare, minor one (1 × 1 = 1) can wait.
Try it: the risk matrix
Pick a HomeworkHub sticky note, then pick the square where you think it belongs. Your priority list builds itself below. When you're done, compare with how a security team might rate them.
1. Pick a threat
2. Place it on the matrix
Pick a sticky note first.
Your priority list
- Nothing placed yet.
Dashed circles on the matrix show one reasonable rating. Teams often disagree a little; what matters is the reasoning.
Don't skip the small stuff forever: low-risk threats still go on the list. You just handle them after the big ones, or decide on purpose to accept them.
Fix it, then check your work
For each threat on your list, you choose a response. There are four basic options:
Reduce it
Add a defense that makes the threat harder or less harmful. Most threats get this.
Eliminate it
Remove the feature that causes it. No public share links means no leaked share links.
Transfer it
Let someone better equipped handle it, like using a trusted login provider instead of building your own.
Accept it
Decide the risk is small enough to live with, and write down why. Accepting is a choice, not forgetting.
Each STRIDE letter has defenses that usually match it. This table is a good starting point for HomeworkHub:
| Threat type | Good defense | HomeworkHub example |
|---|---|---|
| Spoofing | Strong sign-in | Two-factor authentication for teacher accounts |
| Tampering | Integrity checks and permissions | Only the uploader can replace their own file |
| Repudiation | Logs (records of who did what) | Save who changed each grade and when |
| Info disclosure | Encryption and access control | Share links that need a signed-in classmate |
| Denial of service | Limits and backups | Cap how many requests one account can send per minute |
| Elevation of privilege | Least privilege | Server checks "is this a teacher?" on every grade change |
Did we do a good job?
The last question is the one people forget. A threat model is never truly finished, because the app keeps changing. Teams check their work with questions like these:
- Does the diagram still match the real app, including new features?
- Did every threat get a response, even if the response was "accept"?
- Did we test that the defenses actually work?
- Did someone new look at it with fresh eyes? Outsiders often spot what the builders miss.
Build your personal threat model
Threat modeling isn't only for companies. You can run the same four questions on your own phone or gaming account in about a minute. Answer three quick questions and get your top three actions.
- 1. What
- 2. Who
- 3. Habits
- Your plan
Threat modeling questions, answered
What is threat modeling?
Threat modeling is a way of planning for security before something goes wrong. You look at a system, like an app, a network, or your own phone, and ask what could go wrong, who might cause it, and what you will do about it. Security teams do it early, so they can fix problems while they are still cheap and easy to fix.
What are the four questions of threat modeling?
The four questions are: What are we working on? What can go wrong? What are we going to do about it? Did we do a good job? They come from security expert Adam Shostack and the Threat Modeling Manifesto, and they work for any system, big or small.
What does STRIDE stand for?
STRIDE stands for Spoofing, Tampering, Repudiation, Information disclosure, Denial of service, and Elevation of privilege. It was created at Microsoft as a checklist that helps people think of many kinds of threats, not just the first one that comes to mind.
What is a trust boundary in threat modeling?
A trust boundary is a line on your diagram where data moves between parts that trust each other differently, like the line between a user's phone and a company's server. Many threats show up right at these lines, so they are the first places a defender checks.
How do you calculate risk in threat modeling?
A simple way is risk equals likelihood times impact. Rate how likely a threat is and how bad it would be, for example from 1 to 3, then multiply. Threats with the highest scores get fixed first. Real teams often use more detailed scales, but the idea is the same.
What is an example of threat modeling in everyday life?
Locking your front door, keeping your address off your public profile, and turning on two-factor authentication for a gaming account are all small threat models. You thought about what you care about and what could go wrong, then picked a defense. Threat modeling just does this on purpose and writes it down.
Quick quiz
1. What is the first question in threat modeling?
2. A student finds a way to open the teacher-only "edit grades" page from a student account. Which STRIDE category is this?
3. Threat A has likelihood 3 and impact 1. Threat B has likelihood 2 and impact 3. Which should you fix first?
4. What is a trust boundary?
Keep thinking like a defender
Threat modeling connects to almost every part of cybersecurity. These tutorials go deeper into the ideas you used today.
Part of the Cybersecurity Skills and Careers tutorial series.