Module 01 · Security · Think Like an Attacker · with code: Python · about 15 min to read
Continue where you left off ×
The shop you secure (defence in a real app)
The Security Mindset · Open board
An ordinary system redrawn with every door an attacker could use marked on it. Every lesson in this track has walked through one of those doors. This one builds the building and puts a lock on each door itself.
Before you start. The Security Mindset gave you the threat model: a written list of the ways a system could be made to misbehave, walked door by door with a six-letter checklist called STRIDE. Authentication through Application Hardening each taught one kind of lock, Whose page is this? (the browser security model) showed which rules the browser enforces for you, and Review the fix (secure code review) had you find missing locks in other people’s code. A shop built to be broken (OWASP Juice Shop practice) let you walk through a shop left open on purpose. This lesson is the other side: a shop you secure, with a test that proves each lock is there. You need Python 3, which most laptops already have.
The idea in 30 seconds
A threat model is a written list of the ways an app could be abused, made by walking STRIDE at every door where outside input comes in.
This shop’s six doors each get one defence: an ownership check, parameterised SQL, output escaping, slow salted password hashing, a per-session form token, and an allowlist for addresses the shop fetches.
A defence is usually one line, and deleting it breaks nothing you can see, which is why each one needs its own test.
A regression test is kept forever so a closed hole cannot quietly reopen, and it is named for what it guarantees.
You trust a test only after you have watched it fail with its defence removed.
A good threat model names what it does not cover. This shop has no audit log and no rate limits.
Read the story
Lesson 31 of 39 in Security
The rest of this lesson is part of a plan.
A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year .
See plans Already a member? Sign in
Or start free : a free account opens lessons 2 and 3 of every track.
In this lesson January 2002: the memo that put security ahead of features The shop, drawn the attacker’s way: a threat model Six doors, six locks: the defences A lock you cannot see is a lock you cannot trust: one test per defence The six locks, as written How slow is slow, measured What these six locks do not cover Remove one lock, watch one test fail Terms it explains: threat model, 1. The ownership check, 2. Parameterised SQL, 3. Output escaping, 4. Slow, salted hashing, 5. The form token, 6. The outbound-fetch allowlist, regression test, assume breach, attack surface, authenticity, CIA triad, complete mediation, defense in depth, fail secure, least privilege, no security through obscurity (Kerckhoffs), non-repudiation, security mindset, stride, trust boundary.
Review Security
Mark as read Saved in this browser, and to your account when you sign in.