REFERENCE GUIDE

Web race conditions and atomic business invariants

Web races occur when concurrent operations observe shared state and violate an invariant that should be enforced atomically.

Also known as: limit-overrun · business logic race

web-race-conditionsweb

Mechanism

Web races occur when concurrent operations observe shared state and violate an invariant that should be enforced atomically. Examples include using a coupon once, reserving a limited balance, or changing a credential between verification and use. A pair of simultaneous requests is useful only when the shared-state transition is understood.

Practical method

Draw the read, check, and write sequence for the operation. Establish sequential behavior, then use two synchronized lab requests with distinct identifiers. Inspect persistent server state after both finish. Identify whether the critical boundary is a database transaction, a cache, or an asynchronous worker.

request A: read balance -> check -> debit
request B: read balance -> check -> debit
required: enforce check and debit as one atomic invariant

Interpreting evidence

Show a durable invariant violation, such as two accepted operations against a single-use resource. Response ordering alone does not prove a race, and retries can create duplicate-looking logs.

Pitfalls and limits

Connection scheduling and worker queues affect overlap. Database isolation levels do not automatically enforce every business rule. A transactional compare-and-update must check the affected-row result.

Sources & further reading

  1. Race conditions ↗portswigger
  2. Business logic testing ↗owasp-wstg

Content license: CC-BY-4.0. Source-derived sections retain their cited licenses and redistribution notices. How this reference is compiled →