Track cheat sheet
Security cheat sheet
Sessions, tokens, access checks, secrets, forged requests and scraping: each attack animated, then the defence, then a real breach.
Key concepts
- Sessions vs tokens
- A signed token is checked without a lookup, so the server cannot take it back before it expires.
- Token pitfalls
- A correct signature proves only that a trusted key signed the token, not that it was meant for you.
- Checking access at every hop
- Signing in proves who you are; only an ownership check proves the record is yours.
- Secrets out of code
- A key in code is copied to every clone and readable by every account on the code host, forever.
- The server tricked into fetching
- A server that fetches user-given URLs can be pointed at addresses only it can reach, like the metadata service.
- Rate limits people get around
- A per-account limit stops one noisy client; a patient attacker spreads over many accounts.
Decision rules
- Short-lived access tokens, plus a refresh token or session the server looks up and can revoke.
- Check algorithm, issuer, audience, expiry and key scope; rotate keys automatically.
- Check ownership on every request, where the record is read: id AND owner.
- Credentials at run time from a secrets manager or cloud role, short-lived and scoped; scan commits.
- Validate the resolved address (and every redirect), egress through a proxy, require IMDSv2, least-privilege roles.
- Combine per-account, per-device and system-wide budgets with checks on what is being looked up.
Common traps
- Day-long tokens: signing out deletes the user's copy, not the stolen one.
- Trusting every key on the list, including one that should have retired years ago.
- Fetching any ID the request names because the user is signed in.
- A 'private' repository with a long-lived key, and accounts without a second factor.
- Fetching whatever URL the user supplies, from a server whose role can read everything.
- A lookup endpoint that answers anyone, any number of times, as long as each account is slow.
Lessons and boss fights
- Sessions vs tokens · 3 min
- Token pitfalls · 3 min
- Checking access at every hop · 3 min
- Secrets out of code · 3 min
- The server tricked into fetching · 3 min
- Rate limits people get around · 3 min
Real outages on this track: The session that left the laptop · The key that signed for everyone · Change one digit · The key in the repository · The firewall that fetched keys · Find your friends, at scale
BuildBreak · Security · each line comes from its lesson, where the sources are linked.