LS·206
Phase 10 — Security
The tenth phase: web security, OAuth and OIDC, API security, cloud IAM, container security, the software supply chain and threat modelling, ending with the whole application threat-modelled and hardened; the order and why, an entry check, step-by-step exit checks mapped to Volume 10, the project with milestones and definitions of done, traps, a time budget, and a lab that audits a small API before and after hardening.
Start here: Phase 10 in one page
Security has been part of every phase so far (hashing passwords, parameterised queries, least-privilege IAM). Phase 10 makes it systematic: you learn the common failure classes layer by layer, from the browser to the build pipeline, then learn to think like an attacker about your whole design. The project threat-models the entire application, hardens it, and proves the fixes with an audit run before and after.
The sequence
web security → OAuth/OIDC → API security → cloud IAM → container security → supply chain → threat modeling
The order moves outward from the code you've been writing. Web security first (the browser's security model and the OWASP Top 10), then identity (OAuth 2.0 and OpenID Connect, which nearly every login now uses), then the API layer, where authorization flaws dominate. Then the platform: cloud IAM and containers. Then what you build from: dependencies, images and pipelines. Threat modelling comes last because it's the method that pulls all of these together for one whole system; you'll model better once you know the classes of threat in every layer. (Many teams start a design with a quick threat model; you'll do that from now on, too.)
A taste of the project
The lab audited a small orders API (FastAPI, two users, two orders) for six common flaws, then fixed them and audited again:
| Check | Before | After |
|---|---|---|
| read orders without logging in | allowed | 401 |
| read another user's order by changing the ID (BOLA/IDOR) | allowed | 404 |
any website can call the API with the user's cookies (CORS * with credentials) |
allowed | origin allow-list |
| password brute force: 30 guesses | all 30 checked | 5 checked, 25 blocked (429) |
| error responses leak internals (the exception text and a database URL with its password) | yes | generic message |
| security headers (HSTS, CSP, nosniff) | none | all set |
| score | 0 / 6 | 6 / 6 |
None of these needs an exotic attack. Broken object-level authorization ("change the number in the URL") is the most common serious API flaw in the OWASP API Top 10.
How deep to go in Phase 10
Volume 17 defines six mastery levels; Phase 10's exit targets are:
| Topic | Exit level | What that means here |
|---|---|---|
| web security (OWASP Top 10) | L3–L4 | find and fix each class in your code; CSP, CORS, cookies |
| OAuth 2.0 / OIDC | L3 | authorization code + PKCE, tokens, scopes, sessions |
| API security (OWASP API Top 10) | L3–L4 | object- and function-level authorization, rate limits |
| cloud IAM | L3 | least-privilege roles, no long-lived keys |
| container security | L2–L3 | minimal non-root images, scanning, runtime limits |
| supply chain | L2–L3 | lockfiles, scanning, SBOMs, signed artefacts, secrets out of repos |
| threat modelling | L3 | run STRIDE on your whole system |
The sequence, step by step
| Step | Learn | Read | Exit check |
|---|---|---|---|
| 1 | security foundations and web security | Vol. 10, Start Here, ch. 106, 108 | find one instance of three OWASP classes in your own code |
| 2 | OAuth 2.0 and OIDC | Vol. 10, ch. 109 | log in via an OIDC provider with the code flow + PKCE; explain each token |
| 3 | API security and authorization | Vol. 10, ch. 108, 110 | tests proving no cross-user or cross-tenant access |
| 4 | secrets and cryptography | Vol. 10, ch. 107 | no secrets in the repo (scanner) and a rotation runbook |
| 5 | cloud IAM | Vol. 10, ch. 109, 111 | IAM policies reviewed for least privilege; no static keys in CI |
| 6 | container security | Vol. 10, ch. 111 | non-root minimal images with no critical CVEs |
| 7 | supply-chain security | Vol. 10, ch. 112 | an SBOM and dependency scanning in CI |
| 8 | threat modelling and secure design | Vol. 10, ch. 113; projects in ch. 114 | a STRIDE table for the whole system |
Entry check
Phases 4–7: you have an application with authentication, deployed with infrastructure as code.
The phase project: threat-model and harden the entire application
Goal. Threat-model the entire application (frontend, backend, data stores, queues, cloud and pipeline), harden it, and prove the fixes with automated tests.
Milestones. Data-flow diagram and threat model (STRIDE) of the whole system → audit against the OWASP web and API Top 10 → authorization tests for every endpoint (including object-level) → rate limits on login and expensive endpoints → secure headers, CORS and cookies → secrets moved to a manager, scanning in CI → dependency scanning, an SBOM, pinned images → IAM least-privilege review → an external scan (e.g. OWASP ZAP baseline) → a short security report.
Done when. The threat model's high-risk items are mitigated or accepted in writing; authorization tests fail if a check is removed; CI blocks committed secrets and known-critical vulnerabilities; the ZAP baseline shows no high findings; the report lists residual risks.
Stretch. Invite a friend to attack it for an afternoon with a bounty of coffee.
Common traps
- Authorization only in the frontend.
- "We use HTTPS, so we're secure."
- Rolling your own crypto or auth.
- Secrets in environment files committed "temporarily".
- Treating security as a final phase rather than a habit: this phase makes it systematic, but quick threat models and security tests belong in every design from now on.
Exit criteria
- [ ] The project meets its "done when" list.
- [ ] I can threat-model a design with STRIDE.
- [ ] I can explain and test for each OWASP API Top 10 risk.
- [ ] I can design authentication and authorization for a multi-tenant app.
- [ ] I scored at least 80% on 40 questions from Volume 10's quizzes, twice.
Time budget
Volume 10 (about 52,000 words) is about 3.8 hours of reading; with practice, about 15 hours, plus 2 weeks for the project: about 4 weeks at 8 hours a week.
Lab: audit, harden, audit again
Setup. A deliberately small FastAPI app on the lab machine: two users (priya, arun), two orders held in memory, POST /login returning a bearer token, GET /orders/{id}, and an endpoint that throws an error. The same code runs in two modes, switched by an environment variable, so the only difference is the hardening. An audit script (Python httpx) checks six things:
- reading an order with no token;
- BOLA: Priya, logged in, requests Arun's order;
- CORS: a preflight from
https://evil.example; - brute force: 30 wrong passwords for Arun;
- error leakage: does the error response contain internal details?
- security headers: HSTS, CSP and
X-Content-Type-Options.
The hardened mode adds: a token required on every order read; an ownership check returning 404 for others' orders; a CORS allow-list with only the app's own origin; a lockout after 5 failed logins from one IP; a generic error handler; and a header middleware (HSTS, Content-Security-Policy: default-src 'none', nosniff, Referrer-Policy).
Results
| Check | Before | After |
|---|---|---|
| read an order with no token | returned | 401 |
| Priya reads Arun's order | returned | 404 (not 403, so IDs aren't confirmed) |
CORS preflight from https://evil.example |
origin allowed (wildcard, with credentials allowed) | not allowed |
| 30 wrong passwords | 30 checked | 5 checked, 25 blocked (429) |
| error response | the exception text and a database URL with its password | {"error": "internal error"} |
| HSTS, CSP, nosniff | none | all set |
| score | 0/6 | 6/6 |
What it shows
- Every fix was a few lines, and every flaw was invisible in normal use: the app "worked" before hardening. Only adversarial tests reveal them, which is why the project makes them automated and permanent.
- In the lab the ownership check runs after the lookup; with a real database put it in the query itself (
WHERE id = :id AND owner_id = :user) so no code path can forget it. Returning 404 avoids confirming that other users' IDs exist. - Rate limiting changes the economics of online guessing. The lab's lockout is crude (per IP, no expiry); a real one is per account and per IP with a time window. At 5 attempts per 15 minutes per account, trying the 10,000 most common passwords takes about 3 weeks per account instead of seconds.
- 6/6 isn't "secure": it's six known classes closed. The lab app still stores passwords with a single fast salted SHA-256, which the audit didn't test; a stolen user table could be cracked quickly. Use Argon2id or bcrypt. The threat model decides what else to check.
Try it yourself
- Add a password-storage check to the audit, then switch to Argon2id and time one hash.
- Make the lockout per account and per IP with a 15-minute window, and test both.
- Run OWASP ZAP's baseline scan against both modes and compare.
- Add
gitleaksto a pre-commit hook and CI, and commit a fake key to see it blocked. - Remove one authorization check and confirm a test fails.
Revision sheet: Phase 10, security
Key ideas
- Sequence: web security → OAuth/OIDC → API security → cloud IAM → container security → supply chain → threat modelling.
- Learn the threat classes layer by layer, then threat-model the whole system; test the classes of flaw; automate the tests so fixes stay fixed.
- Authorization on the server, on every object, ideally in the query.
- Secrets in managers; dependencies pinned and scanned; IAM least privilege.
Numbers to remember
- Lab: audit 0/6 → 6/6; brute force 30 checked → 5 checked, 25 blocked; password hashing (fast SHA-256) still weak.
- 5 failed logins per 15 minutes ≈ 3 weeks to try 10,000 passwords on one account.
- Budget: ~15 study hours + 2 project weeks ≈ 4 weeks at 8 h/week.
Pitfalls
- Frontend-only authorization; missing object-level checks.
- Verbose errors; permissive CORS.
- Secrets in repos and images.
- Security left to the end.
Glossary
- STRIDE: spoofing, tampering, repudiation, information disclosure, denial of service, elevation of privilege.
- BOLA / IDOR: broken object-level authorization / insecure direct object reference.
- OIDC: OpenID Connect, identity on top of OAuth 2.0.
- SBOM: software bill of materials.
- CSP: Content Security Policy, a header limiting where scripts and resources can load from.