Race condition vulnerability in a single-use coupon endpoint
We reproduced a race condition vulnerability in a single-use coupon endpoint running on Python's threaded HTTP server. Widening the gap between the check and the write made sixteen concurrent redemption attempts against one coupon succeed sixteen times out of sixteen, every round. With no added delay the same flaw still let through extra redemptions on three of five rounds, with 3, 8 and 4 successes. A single conditional SQL update closed the gap and held at exactly one success across every retest.
This is a scripted Python and curl experiment with downloadable source and responses. The sixteen concurrent requests were sent with Python threads calling the standard library's urllib , not curl --parallel ; curl sent the sequential control requests.…