Secure by design and threat modeling
Find the problems on paper, before they ship
Learn to draw a system, mark where trust changes, list what can go wrong with STRIDE, and turn each threat into a requirement and a test.
beginner level, 18 minutes, 18 slides.
Secure by design and threat modeling
Welcome. Learn to draw a system, mark where trust changes, list what can go wrong with STRIDE, and turn each threat into a requirement and a test. This talk runs about 18 minutes.
Fix it on paper, not in production
Finding security problems during design is far more efficient than fixing them once a system is in production. Threat modeling is how you do it.
Many security problems are baked in at the design stage, long before anyone attacks. OWASP says threat modeling lets security be built into a system rather than bolted on, and that this is far more efficient than fixing flaws after the system is in production. In this talk we learn that habit.
Secure by design: three principles
CISA and 17 U.S. and international partners urge software makers to follow three principles.
- Take ownership of customer security outcomes. The maker, not only the customer, is responsible.
- Embrace radical transparency and accountability. Be open about security.
- Lead from the top. Leaders drive the effort.
Plain meaning: Secure by design means security is the builder's job from the start. Threat modeling is one way to do it.
Secure by design is guidance from CISA and its partners, aimed at software manufacturers. It expands on three principles: take ownership of customer security outcomes, embrace radical transparency and accountability, and lead from the top. In plain words, the builder carries the responsibility. Threat modeling is one practical way a builder can act on that.
What is threat modeling?
Definition: Threat modeling is analyzing representations of a system to highlight concerns about security and privacy characteristics.
- A representation is a drawing or description of the system.
- A threat is something that could go wrong and cause harm.
- You do it during design, and again when the design changes.
The Threat Modeling Manifesto gives a short definition: analyzing representations of a system to highlight concerns about security and privacy. In plain words, you draw your system and you ask what could go wrong. OWASP says you can draw the model with a diagramming tool or on a whiteboard.
The four questions
- What are we working on?. Model the system: parts, data, connections.
- What can go wrong?. Find and rank the threats.
- What are we going to do about it?. Choose a response for each threat.
- Did we do a good enough job?. Review the result with all stakeholders.
Almost every threat modeling method comes down to four questions. What are we working on? What can go wrong? What are we going to do about it? And did we do a good enough job? OWASP turns these into four steps: decompose the application, identify and rank threats, choose mitigations, and review. We will walk through all four with one small example.
Our example: a notes app
A small web app where people sign in and save private notes.
- User: a person with a web browser.
- Web app: runs the logic and checks who you are.
- Database: stores accounts and notes.
- Data we care about: passwords and note text.
Define as you go: A process is code that does work. A data store holds data. An external entity is something outside your control, like a user.
Here is our worked example. A small notes app. A person uses a browser, the web app handles requests, and a database stores accounts and notes. The notes are private, and that is what we are protecting. Keep this picture in your head, because the next slide draws it.
Draw it: a data flow diagram
Two trust zones. The browser is outside our control.
This is a data flow diagram, often shortened to DFD. It shows the parts, the data stores, and the arrows where data moves. OWASP says a good model gives a clear view of trust boundaries, data flows, data stores, processes, and external entities, because these are often the places an attacker will probe. In our drawing, the user can reach the web app, the web app can reach the database, and the user must never reach the database directly.
Trust boundaries
A trust boundary is a line on the diagram where the level of trust changes. Data crossing it needs checks.
Inside the boundary
- Code and data you control
- Checked, logged, patched by you
Outside the boundary
- Users, browsers, other companies
- Treat every input as untrusted
Where to look first: OWASP says trust boundaries and data flows often represent possible attack points.
A trust boundary is a line on your diagram where trust changes. Inside the line you control the code and the data. Outside the line you do not. Whenever an arrow crosses that line, ask who is on the other side and what they could send. OWASP notes that trust boundaries and data flows often represent possible attack points, so start your search there.
STRIDE: six kinds of threat
| Letter | Threat | In plain words |
|---|---|---|
| S | Spoofing | Using someone else's login details |
| T | Tampering | Changing data without permission |
| R | Repudiation | Denying an action, with no proof either way |
| I | Information disclosure | Showing data to people who should not see it |
| D | Denial of service | Making a service unusable for real users |
| E | Elevation of privilege | Gaining more access than you were given |
STRIDE is a checklist of six threat types. Spoofing, tampering, repudiation, information disclosure, denial of service, and elevation of privilege. Use the letters as prompts while you look at each part of your diagram. OWASP suggests brainstorming with your team and recording which components, flows, or trust boundaries each threat touches.
STRIDE on the notes app
| Where | Threat | Type |
|---|---|---|
| Browser to web app | Guessed or stolen password used to sign in | S |
| Web app to database | Note text changed by a crafted request | T |
| Web app | No record of who deleted a note | R |
| Database | One user reads another user's notes | I |
| Web app | Flood of requests blocks real users | D |
| Web app | Normal user reaches admin page | E |
Now we use STRIDE on our example. For each row we name a place, a threat, and its type. Do not worry about being complete on the first pass. The goal is a useful list the team can discuss. Next we decide what to do about each one.
Four ways to respond
| Response | Meaning |
|---|---|
| Mitigate | Reduce the chance the threat happens |
| Eliminate | Remove the feature or component causing it |
| Transfer | Move contractual or financial responsibility to another party |
| Accept | Keep the risk because the other options do not fit |
Transfer is not a fix: Transferring risk does not itself lower the chance or harm of the threat.
Every threat needs a response, and there are four. Mitigate it, eliminate it by removing the feature, transfer it to someone else, or accept it. Be careful with transfer, because moving the contract does not make the harm any smaller. And if you accept a risk, write down why.
Turn threats into requirements
Agreed mitigations should become requirements that can be tested.
- Threat: Other users read my notes
- Requirement: Users only read their own notes
- Test: User A asks for user B's note
- Result: Must be refused
OWASP asks: can the agreed mitigations be tested, and can success or failure be measured?
A list of threats on a wiki page protects nothing. Turn each agreed mitigation into a clear security requirement, then into a test. For our information disclosure threat, the requirement is that users only read their own notes. The test is that user A asks for user B's note and must be refused. Now the threat model can fail a build.
A requirement and its test
Plain-language test case, not tied to any tool
REQ-07 A user can read only their own notes.
TEST-07
Given user A and user B each own one note
When user A requests user B's note
Then the response is "forbidden"
And the attempt is written to the audit log- One requirement, one clear pass or fail.
- Link each test back to the threat it covers.
Here is what that looks like written down. A requirement with a number, and a test with given, when, and then steps. Anyone can read it, even without code skills. The last line matters too: refused attempts should be logged, which also covers our repudiation threat.
Check your understanding
Check yourself: A user denies deleting a note, and the system has no log to prove otherwise. Which STRIDE type is this?
Answer: Repudiation. Repudiation is a user denying an action when nobody can prove otherwise.
Check yourself: You remove a risky feature entirely. Which response is that?
Answer: Eliminate. Eliminate means removing the feature or component that causes the threat.
Two quick questions. Pause the video and try them. Then reveal the answers and check your thinking.
Keep the model alive
Repeat when the design changes.
- Model: Draw the system
- Find threats: STRIDE prompts
- Respond: Requirements and tests
- Review: All stakeholders
Review with everyone involved, not only security or development.
A threat model is not a document you finish. It is a loop. When you add a feature or change how data moves, run the loop again. OWASP also says the review should include all stakeholders, not just the development or security teams.
Recap
- Secure by design puts the security burden on the builder.
- Threat modeling asks four questions about your system.
- Draw data flows and mark trust boundaries.
- Use STRIDE to prompt for threats.
- Choose a response for each threat, then write a test.
To recap: build security in from the start, ask the four questions, draw the flows and trust boundaries, use STRIDE to find threats, pick a response, and write a test for every mitigation. Try the labs next to practice on a real system.
Practise this
- Threat model a system with STRIDE using OWASP Threat Dragon
- Turn a threat model into security test cases that run in CI (so the model cannot silently rot)
Slides only get you so far. Pick one of these hands-on labs and do it today while it is fresh. Every lab is free.
Sources
- OWASP Threat Modeling Cheat Sheet
- CISA: Secure by Design
- Threat Modeling Manifesto
- Microsoft: STRIDE threat categories
Every claim in this deck came from these pages, fetched and checked for this release. Read the originals.
Hands-on labs for this deck
- Threat model a system with STRIDE using OWASP Threat Dragon
- Turn a threat model into security test cases that run in CI (so the model cannot silently rot)
Open the interactive deck or see all slide decks.