top of page

Race Conditions in Web Apps: Limit Checks and TOCTOU Bugs

Sep 11
2 min read

Race conditions happen when the app checks something, pauses, then acts—as if nothing changed in between. Limits, balances, and one-time tokens are classic victims.


They're finicky to reproduce; that's not an excuse to ignore them on financial flows.

Race Conditions in Web Apps: Limit Checks and TOCTOU Bugs

Race bugs teach humility about flaky reproduction. Capture screen recordings with timestamps when you can; triage teams trust video of a double credit more than a paragraph describing parallel clicks.



Typical hotspots


Coupon redemption, wallet transfers, inventory purchases, vote/likes, and referral bonuses. Parallel requests from the same session often tell the story.


Async workers amplify windows between queue and execution.



Validation approach


On authorized scopes, use controlled parallel requests—not unbounded floods. Capture whether server-side locking exists.


  • Test idempotency keys honestly

  • Compare single-thread vs burst outcomes

  • Note partial failures and double credits



Fixes and detection


Database transactions with row locks, idempotent APIs, and monitoring for duplicate settlement patterns.


Race bugs deserve clear impact—financial loss beats 'undefined behavior.'


Respect program bans on automated concurrency attacks.


If races can't be reproduced reliably, describe the window and business logic clearly—triage sometimes accepts theoretical impact on financial flows with strong code review.


Small habits compound—what feels like overhead early becomes speed when deadlines hit.


Time-box race testing—diminishing returns arrive quickly on flaky endpoints.



Monitoring angles


Recommend logging duplicate transaction IDs and velocity alerts—blue teams fix faster with detection hooks.


Blind races still matter; describe expected vs actual ledger state without hammering prod.



Reproduction notes


Race bugs flake—record multiple attempts and success rate so triage trusts you.


Suggest idempotency keys on financial APIs in remediation sections.


Note timezone and server clock skew if timing tests behave oddly.




Worth reading next


Business Logic Flaws and Broken Access Control


API Hacking: Rate Limiting and Resource Consumption


Bug Bounty: How to Write a Vulnerability Report

Comments


© 2022 by SapiensHack.com (Security)

bottom of page