Skip to content

Concurrency bugs and race conditions: testing voucher double-spending, balance transfers, and limit bypasses

A technical investigation into web application race conditions: Time-of-Check to Time-of-Use (TOCTOU), database locking strategies, and HTTP/2 single-packet attack testing.

By BugSnaps Security Research · · 8 min read

Race conditions occur when an application processes concurrent requests without adequate transaction isolation or locking mechanisms, allowing operations to execute out of intended sequence. Attackers exploit these Time-of-Check to Time-of-Use (TOCTOU) windows to duplicate funds, redeem single-use coupons dozens of times, or bypass strict rate limits.

The anatomy of a voucher double-spend

In a vulnerable application, redeeming a $50 gift card involves three sequential steps: 1) check if voucher is used, 2) credit user balance, 3) mark voucher as redeemed. If an attacker sends twenty identical requests simultaneously using HTTP/2 multiplexing, all twenty requests may pass step 1 before any request reaches step 3, crediting $1,000 to the attacker's balance.

  • Financial double spending: transferring balances to external accounts before internal debits are committed.
  • Rate limit circumvention: exhausting password guess attempts concurrently before the limit counter increments.
  • Inventory hoarding: locking limited concert tickets or inventory items beyond permitted purchase limits.

Remediation with database locks and idempotency

Defending against race conditions requires atomic operations and strict database transaction isolation. Use pessimistic row-level locking (`SELECT ... FOR UPDATE`), atomic database increments, distributed Redis locks (Redlock), and unique database constraints on transaction idempotency keys.

BugSnaps expert penetration testers utilize multi-threaded concurrency harnesses to probe financial endpoints and transactional workflows for subtle race conditions.

Run a real pentest on your app - free.

Sign in, prove you own the domain, and MyPentest maps and tests it. No credit card.