Threat Modeling and the CIA Triad Explained
On this page
What is the security mindset?
Most developers test whether a feature works. Attackers test how it breaks: what happens with a negative quantity, a reused link, a million requests, someone else's ID. The security mindset is asking those questions yourself, early, when fixes are cheap.
The CIA triad: confidentiality, integrity, availability
Three properties describe what security protects:
| Property | Means | Broken by |
|---|---|---|
| Confidentiality | Only the right people can read data | Data leaks, stolen credentials, overly broad access |
| Integrity | Data and systems aren't changed improperly | Tampered requests, injection, unauthorized edits |
| Availability | The system works when needed | DDoS, resource exhaustion, ransomware |
Every vulnerability in this course harms at least one of them. Two more properties often join them: authenticity (you know who did something) and non-repudiation (they can't deny it later), supported by authentication and audit logs.
Threat modeling in four questions
Threat modeling is structured thinking about what could go wrong. Adam Shostack's four questions are enough to start:
- What are we working on? Sketch the feature: components, data, who talks to whom, and trust boundaries (where data crosses from less trusted to more trusted, such as browser to server).
- What can go wrong? Brainstorm threats; the STRIDE checklist helps (Day 28).
- What are we going to do about it? For each threat, mitigate it (add a control), accept it (low risk, written down), transfer it (insurance, or a provider who handles it) or avoid it (drop the risky feature).
- Did we do a good job? Review, test, and revisit when the design changes.
Example: threat modeling a password reset feature
Twenty minutes of threat modeling, written down:
Threat model notes: password reset
Asset: the reset token (single use, maps to exactly one account)
Trust boundary: email link -> browser -> our API
Threat: token is guessable -> 256-bit random token from a CSPRNG (crypto.randomBytes(32))
Threat: token works forever -> 15-minute expiry, single use, invalidated on login
Threat: token stolen from our database -> store only a hash of the token
Threat: email enumeration via responses -> same response and timing whether or not the email exists
Threat: reset spam / email bombing -> rate limit per email and per IP
Threat: token leaks via Referer header -> Referrer-Policy: no-referrer on the reset page
Threat: attacker resets, victim unaware -> notify the account owner; end other sessions on resetA CSPRNG is a cryptographically secure random number generator, such as crypto.randomBytes in Node or secrets in Python. Ordinary Math.random() is predictable enough that attackers can sometimes work out the next value.
Each line names a threat and a specific mitigation a developer can implement and test. Notice the threats span the triad: guessing and leaking tokens (confidentiality), taking over the account (integrity), email bombing (availability).
Which threats first?
A list of fifteen threats needs an order. Rate each one quickly on two scales, how likely and how bad, and start with the threats that score high on both:
| Threat | Likely? | Impact | Priority |
|---|---|---|---|
| Reset token works forever | Medium | Account takeover | High |
| Email enumeration | High | Helps later attacks | Medium |
| Reset spam | Medium | Annoyed users | Low to medium |
Rough is fine. The point is to spend the first hour on account takeover, not on the annoying-but-harmless threat.
Making threat modeling routine
- Threat model new features and significant changes, not the whole system once a year.
- Keep it lightweight: a whiteboard sketch and a list in the design doc beats a formal process nobody follows.
- Focus on trust boundaries, where most vulnerabilities live: user input, third-party APIs, uploaded files, internal services that trust each other.
- Turn mitigations into tests and tickets, so they don't stay as notes.
Check yourself
Availability. A DDoS floods the system with traffic so legitimate users can't reach it, even though no data is read or changed. Confidentiality and integrity are untouched, which is why availability needs its own controls like rate limiting and CDNs.
If the database leaks, attackers can't use the stored hashes to reset accounts, because they need the original token that was emailed to the user. It's the same reasoning as password hashing, and a fast hash like SHA-256 is fine here because tokens are long and random.
A point where data passes between parts with different trust levels, such as user input reaching a server; that's where validation and checks are needed and most vulnerabilities appear.
Rate each threat by likelihood and impact, and fix the ones high on both first; accept and document the low-risk ones.