portswigger-all-labs

Complete PortSwigger Web Security Academy Lab Writeups Detailed, categorized solutions for every lab — from APPRENTICE to EXPERT — covering all 30 vulnerability types.

View on GitHub

Race Conditions

Race conditions are vulnerabilities that occur when multiple processes access and modify shared data concurrently without proper handling. Attackers exploit the tiny timing window where the application behaves unpredictably, leading to unintended outcomes.


What Is a Race Condition?

A race condition happens when:

  1. A system performs checks and then acts based on those checks.
  2. Multiple requests are sent in parallel, hitting the system in between the check and the action.
  3. The system makes conflicting changes due to inadequate synchronization.

This time gap is called the race window, and attackers can exploit it with well-timed requests.


Real-World Example: Reusing a Discount Code

Consider this checkout flow:

  1. Check if the discount code is unused.
  2. Apply the discount.
  3. Update the database to mark the code as used.

If two requests are sent in parallel before step 3 completes, both may succeed—resulting in the same code being used multiple times. This is a classic race condition.


Common Exploitable Scenarios

Race conditions can allow attackers to:

These are often categorized as Time-of-Check to Time-of-Use (TOCTOU) flaws.


Detecting and Exploiting Race Conditions

Manual Discovery Steps

  1. Identify endpoints with single-use or rate-limited functionality.
  2. Observe if these endpoints perform sequential checks before actions.
  3. Attempt to trigger multiple parallel requests to the same endpoint.

Tooling Support: Burp Suite

Burp Repeater (v2023.9+) provides two key techniques:

These capabilities improve the timing accuracy needed to trigger a collision.


Race Condition Lab Scenarios

Labs often simulate real-world logic flaws such as:

These help practice both identification and exploitation.


Learn More