Module 16 · Race Conditions in Web Apps

Manish Garg
Manish Garg Associate of (ISC)² · RingSafe
Apr 22, 2026
11 min read
Read as

Last updated: May 1, 2026

100% Free

No signup. No paywall. No catch. One of our 10 most-requested practitioner modules — published in full so anyone can learn for free. We earn through consulting, not by gating knowledge.

See all 10 free modules →

TOCTOU, single-packet attacks, where races hide, Burp testing, transactional + idempotency-key defenses.

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.

Want this for your team?

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.

Book team training call Replies in 4 working hrs · India-only · Senior consultants