Last updated: May 1, 2026
Race conditions in web apps occur when two requests, processed concurrently, produce a state that neither would alone. Classic TOCTOU (time-of-check-to-time-of-use) bugs. They turn “redeem this coupon once” into “redeem 50 times if you fire 50 requests at the same instant.” James Kettle’s research on single-packet attacks (2023) made these exploitable at high reliability. This module covers detection, exploitation, and defense.
The classic pattern
# Pseudocode of a vulnerable coupon-redeem endpoint
def redeem(user_id, coupon_code):
coupon = db.query("SELECT * FROM coupons WHERE code=?", coupon_code)
if coupon.redeemed_count >= coupon.max_uses:
return "expired"
# ... business logic ...
user.balance += coupon.value
db.execute("UPDATE coupons SET redeemed_count = redeemed_count + 1 WHERE code=?", coupon_code)
db.execute("UPDATE users SET balance=? WHERE id=?", user.balance, user_id)
Two requests arrive concurrently. Both pass the redeemed_count < max_uses check before either UPDATE runs. Both increment balance. Coupon redeemed twice, money credited twice.
Custom team training + practitioner advisory
Beyond the free academy — we run private workshops, vCISO advisory, and red-team exercises tailored to your stack. For Indian SMBs scaling past their first hire.