Topic 158 / Core
Security fundamentals, defense in depth and threat modeling
Chapter 10.1 · Security Thinking
What and why
Every topic up to this point assumed a caller who might be careless but not hostile; Part 10 drops that assumption. Security is the practice of keeping a system's confidentiality (only the right parties read data), integrity (data and behavior aren't tampered with), and availability (the system keeps working for legitimate users) intact against an adversary who is actively trying to break one of the three. Two postures make that practical: least privilege (every caller, service and person gets the minimum access that lets it do its job, nothing more) and defense in depth (no single control is trusted alone — if one layer fails, another still holds). Threat modeling is the process that turns "we should be secure" into a specific list of risks and mitigations for this design, before it's built. Builds on: → 39 (API authentication and authorization basics).
Diagram
STRIDE: one letter, one question, asked of every trust boundary in the design:
| STRIDE threat | Property attacked | Example | Mitigation direction |
|---|---|---|---|
| Spoofing | Authentication | Caller claims to be someone else | Verify identity (→ 159–161) |
| Tampering | Integrity | Request or stored data altered in transit/rest | Signing, checksums, encryption (→ 164) |
| Repudiation | Non-repudiation | "I never did that" with no record to refute it | Audit logging (→ 171) |
| Information disclosure | Confidentiality | Data exposed to a party that shouldn't see it | Access control, encryption (→ 163, 164) |
| Denial of service | Availability | System overwhelmed or made unusable | Rate limiting (→ 96), redundancy |
| Elevation of privilege | Authorization | Caller gains rights beyond what was granted | Least privilege, resource-level checks (→ 163) |
How it works
- Model the system — draw the data flow: actors, components, data stores, and every place data crosses a trust boundary (e.g. internet → load balancer, service → database).
- Enumerate threats per boundary using STRIDE — ask all six questions at each crossing, not just the obvious one.
- Rate and prioritize — likelihood × impact; a theoretical threat with catastrophic impact still outranks a trivial one that happens constantly.
- Mitigate — assign each real threat a specific control (the "mitigation direction" column above points to where each control is taught in full).
- Validate — did the mitigation actually get built, and does it hold under the attack it was designed for? A threat model that's never checked against the shipped system is just a document.
Practical example
(illustrative). Threat-modeling one boundary of Project 1 (task management): the browser → API crossing. STRIDE's spoofing question surfaces: "can a caller present someone else's session token?" The mitigation direction is authentication (→ 159); the specific control chosen is short-lived tokens plus a resource-level ownership check on every task read — exactly the gap topic 39 already named as the most common real-world bug. Running all six STRIDE questions against this one boundary, not just spoofing, is what separates threat modeling from a single lucky guess.
When to use it
- Use when: a design adds a new trust boundary, handles new sensitive data, or changes how a caller is authenticated or authorized — before the code is written.
- Avoid when: forcing a full STRIDE pass on a trivial, low-stakes internal change; scale the depth of the exercise to what's actually at risk.
- Failure scenarios: threat modeling done once at launch and never revisited as the system changes; a model that lists threats but assigns no owner or mitigation, so it's filed and forgotten; validation skipped, so a listed mitigation was never actually built.
- Simpler alternative: for a low-risk change, a short checklist pass (reuse the six STRIDE questions without the full diagram) instead of a complete model.
Practice
(Process kind — fill the template on a small real system; 20–30 min, no lab services). Take Project 1 (task management) or Project 3 (authentication platform) at its current design. Draw its data flow with trust boundaries, then run all six STRIDE questions against each boundary. For every real threat found, write one mitigation and name who owns it. Done when every boundary has been asked all six questions — not just the one that seemed obviously relevant — and every listed threat has a named mitigation.
Key takeaway
Security rests on three properties (confidentiality, integrity, availability) defended in layers, never by one control alone; threat modeling is how a specific design gets a specific list of risks before it ships. Done when you can: produce a threat model for a small system and defend why each STRIDE category was or wasn't a real risk at each boundary. Used next in → 159 (identity as the first control), → 166 (OWASP Top 10 as a pre-built threat catalog), → 172 (secure design reviews reuse this process).
References
None — this topic makes no external claims.
Source directory