The security mindset and threat modeling
Think like an attacker before you write code: map assets, trust boundaries and entry points.
Beginner25 min
Learning objectives
- Explain the CIA triad and how it applies to web apps
- Identify trust boundaries in a request flow
- Run a simple STRIDE threat model on a feature
Why this matters
Security is not a feature you add at the end. Most serious web vulnerabilities come from an assumption nobody questioned:
- “The client will only send valid data.”
- “Only logged-in users can reach this route.”
- “This internal API is safe because nothing outside calls it.”
Each of those assumptions is a bug waiting to be found.
The CIA triad
Every security decision protects one or more of these properties:
- Confidentiality: only authorised people can read the data.
- Integrity: data is changed only by authorised people, and only in expected ways.
- Availability: legitimate users can keep using the system.
Trust boundaries
A trust boundary is any point where data moves into a place with a different level of trust. Everything that crosses a boundary is untrusted input until it has been validated.
[Browser] --HTTP request--> [Web server] --SQL query--> [Database]
^ untrusted ^ boundary: validate ^ boundary: use
every input here safe queries
Ask of every boundary: who controls this data, and what happens if they lie?
Threat modeling with STRIDE
STRIDE is a checklist of six threat categories. For each feature, ask whether each one applies:
| Threat | Meaning | Typical control |
|---|---|---|
| Spoofing | Pretending to be someone else | Strong authentication |
| Tampering | Changing data in transit or at rest | Integrity checks, server-side validation |
| Repudiation | Denying an action happened | Audit logs |
| Information disclosure | Leaking data to the wrong party | Access control, encryption, careful errors |
| Denial of service | Making the service unavailable | Rate limits, quotas, timeouts |
| Elevation of privilege | Gaining rights you should not have | Least privilege, authorisation checks |
Exercise
Take one feature, such as “reset password by email”:
- Draw the data flow from the user to your database and email provider.
- Mark every trust boundary.
- List at least one threat per STRIDE category.
- For each threat, write the control that addresses it.
Key takeaways
- Treat every input as hostile until it is validated at the boundary.
- Threat model before you build. It is far cheaper than patching later.
- Use the OWASP Top 10 as a checklist, not as a complete list of what can go wrong.