February 8, 2025
Bug Bounty Hunting: Web Vulnerability (Race Condition)
Mastering RC: Techniques, Bypasses, and Exploits

By Muhammad Abdullah Niazi
2 min read
- A race condition occurs when two sections of code, intended to execute sequentially, run out of order due to concurrency issues.
- It arises from improper handling of multiprocessing (multiple CPUs executing tasks) or multithreading (multiple threads sharing CPU time).
- Scheduling algorithms dictate thread execution order, leading to unpredictable outcomes when accessing shared resources.
Example of a Race Condition
- Two threads attempting to increment a shared variable may result in an incorrect final value due to unsynchronized execution.
- Without proper synchronization, one thread's update may overwrite another's, leading to data inconsistency.
Security Implications
- Race conditions become security vulnerabilities when they affect security control mechanisms (e.g., authentication, transaction processing).
- These are known as Time-of-Check to Time-of-Use (TOCTOU) vulnerabilities, where an attacker exploits the delay between a security check and an action.
Real-World Exploits
- Banking Exploit: If two simultaneous transactions bypass balance checks, an attacker may withdraw more funds than available.
- Online Voting Manipulation: By sending multiple vote requests before the system marks a user as "already voted," attackers can cast multiple votes.
- E-commerce & Crypto Exploits: Attackers manipulate race conditions to redeem gift cards multiple times, duplicate transactions, or exploit trading platforms.
Exploitation Techniques
- Time-of-Check to Time-of-Use (TOCTOU): Exploits the delay between checking a condition and executing an action. Example: An attacker modifies a request after user permissions are verified. Bypass: Use automation tools (e.g., Burp Suite's Intruder) to quickly change request parameters after validation.
- Delayed Execution: Exploits operations executed in sequence with time gaps. Example: A user cancels a withdrawal request but still receives funds before processing. Bypass: Trigger multiple concurrent requests and manipulate execution timing for unauthorized access.
- File Lock Manipulation: Applications lock files during processing but fail to revalidate access post-unlocking. Bypass: Open a locked file in one process while modifying it immediately after unlocking in another process.
- Symlink Race Attacks: Exploits race conditions in file handling by replacing a legitimate file with a symlink to a sensitive file. Bypass: Create a symlink to sensitive files (e.g., /etc/passwd) and trigger an operation that reads or overwrites it.
- Atomicity Violation: Exploits operations that assume an indivisible process but can be interrupted. Bypass: Send multiple concurrent requests to modify a resource between validation and execution.
- Wallet Balance Manipulation: Common in financial applications where transactions rely on outdated balance checks. Bypass: Submit simultaneous withdrawal requests before the balance updates, leading to overdrawing.
- Double Spending: Involves sending duplicate requests to perform an action twice. Bypass: Use automated scripts to submit the same request multiple times before the first transaction completes.
- Insecure Queues: Race conditions occur in job queues where tasks are processed asynchronously. Bypass: Modify tasks in the queue (e.g., change user ID or permissions) before execution.
- Order of Execution Manipulation: Exploits predictable execution sequences in multi-step processes. Bypass: Rearrange steps using concurrent requests to bypass verification or elevate privileges.
- Token Reuse or Regeneration: Exploits race conditions in token-based authentication. Bypass: Request multiple password reset tokens simultaneously, using the first to invalidate others while still using them.
Prevention Techniques
- Synchronization Mechanisms:
- Prevent multiple threads from modifying shared data simultaneously.
- Ensure operations execute as a single, indivisible step.
- Mutexes & Semaphores: Control access to shared resources.
- Principle of Least Privilege (PoLP): Grant only the necessary permissions to applications and users.
- Use of Transactions: Ensure operations like financial transfers are atomic (all or nothing).
Resources for Further Study
- HackerOne Hacktivity Feed: Real-world race condition vulnerabilities and exploits. HackerOne Race Condition Reports