PrepCity

Business logic flaws and race conditions

Open the lab

By the last page, this is the design you will have built.

Lesson · 14 pages · about 12 min

Business logic flaws and race conditions

A checkout loses money to requests that are each valid: a confirm call that skips payment, a negative quantity, a coupon stacked three times, two redeems of one gift card at once, a retried refund, a script with fresh keys, and a catch block that fails open. Each is played step by step, then fixed on the server.

What it is
Business logic flaws are valid requests in a harmful order, amount or timing; race conditions are valid requests that interleave so a check no longer holds.
What it is for
Input checks, sign-in and WAFs judge each request alone, so they pass every request of an attack that breaks the business itself.
Use it when
In any flow that moves money, stock, credit or state: checkout, coupons, gift cards, refunds, bookings, sign-up bonuses.
Not when
Not every counter needs a lock: views and likes can be approximate. Save locks and invariants for things that must never go wrong.

Words you’ll learn

  • API
  • Payment provider
  • Request
  • Client
  • Retry
  • Parameterised query
  • Business logic flaw
  • WAF
  • Webhook
  • Database

Page by page