Skip to content

Course

Race Conditions & TOCTOU Attacks

Concurrency attacks from the attacker's and defender's side — TOCTOU exploitation, web race conditions, double-spend patterns, lock-free bugs, and the design habits that remove entire classes of them.

9 lessons

Course Q&A

Reviews

Enrolled members can rate this course.

No reviews yet.

Foundations of Concurrent Failure

The mental model: interleavings, atomicity, invariants, and why races hide until production timing changes.

  1. 01The Concurrency Mental Model: Interleavings, Not ParallelismWhy race conditions are really about unexpected instruction interleavings, how single operations decompose into steps, and why low traffic is the best hiding place a race can have.22mOpen
  2. 02TOCTOU: Time-of-Check to Time-of-UseHow check-then-use sequences become exploitable gaps across filesystems, permissions, cloud APIs, and application logic.24mOpen
  3. 03Invariants and State Machines: Making Illegal States UnreachableThe defender's core trick: define the invariant, encode valid transitions, and force concurrent operations through those transitions instead of patching individual races.20mOpen

Exploitation in the Wild

TOCTOU, web application races, double-spend patterns, and lock-free code failures.

  1. 01Web Race Conditions: Coupons, Limits, and Parallel RequestsHow attackers weaponize ordinary HTTP concurrency against rate limits, vouchers, invitations, withdrawals, and business logic that assumes one request at a time.26mPremium
  2. 02Double-Spend Patterns Beyond CryptocurrencyHow the same value gets spent twice in gift cards, ledger systems, reward points, tickets, and offline-capable applications — and how authoritative serialization prevents it.24mPremium
  3. 03Lock-Free Bugs: Atomics, Memory Ordering, and ABAWhy lock-free code fails differently, what atomic operations do and do not guarantee, and how memory ordering and ABA bugs produce impossible-looking behavior.27mPremium

Engineering Them Out

Transactional design, idempotency, worker safety, and review techniques that make races structurally impossible.

  1. 01Database Transactions and Constraints as Concurrency ControlsUsing PostgreSQL transactions, unique constraints, row locks, isolation levels, and conditional updates to make unsafe interleavings impossible instead of merely rare.28mPremium
  2. 02Idempotent Workers and the Exactly-Once MythQueues retry, workers crash halfway, and external APIs time out after succeeding. Build idempotent consumers and transactional outboxes instead of chasing exactly-once delivery.25mPremium
  3. 03Testing and Reviewing for Race ConditionsHow to surface concurrency bugs with adversarial tests, stress harnesses, deterministic thinking, and design-review questions that expose hidden assumptions.23mPremium