Explore our new Cybersecurity Terms Glossary, explained by our experts.

View the Glossary View the Glossary
PRIVIA

Cybersecurity Terms Glossary

What Is a Race Condition?

A race condition is a flaw in which the outcome depends on the timing of concurrent operations, letting an attacker exploit the gap between a check and the action that follows it.

Illustration for the cybersecurity term Race Condition
Home / Blog / Cybersecurity Terms / What Is a Race Condition?
17 November 2026

What Is a Race Condition?

What Is a Race Condition?

Software that assumes operations happen one after another usually behaves correctly until two requests arrive at the same moment. A race condition is the resulting flaw: the outcome depends on timing rather than on logic, and an attacker who can control the timing can produce an outcome the developer never intended. MITRE catalogues the general form as CWE-362 and the most common web variant, time-of-check to time-of-use, as CWE-367.

The Window Between Check and Use

Almost every exploitable case has the same structure. The application reads a value, decides something based on it, and then acts. Between the read and the write there is a window, usually a few milliseconds, during which the value can change. Send two requests inside that window and both pass the check:

balance = read(account)        // both requests read 100
if (balance >= amount)         // both see enough funds
    write(account, balance - amount)   // both write 50

The account has paid out twice and lost one payment’s worth of money. The same pattern applies to redeeming a single-use voucher, accepting an invitation to a workspace, claiming a limited quantity of stock, and counting failed login attempts.

Limit Overrun in Practice

What changed the picture for web applications was the realisation that the window can be made far more reliable. At Black Hat USA in August 2023, James Kettle presented the single-packet attack, which uses HTTP/2 to place the final bytes of twenty or thirty requests into one TCP packet, removing network jitter almost entirely and delivering them to the server within a fraction of a millisecond of each other. Techniques that previously succeeded occasionally became dependable, and classes of bug that had been dismissed as theoretical turned out to be exploitable in production systems.

The practical consequences include redeeming one gift card many times, bypassing an anti-brute-force counter by submitting all attempts simultaneously, exceeding a rate limit that is enforced per completed request, and converting a single-use password reset token into several valid sessions. Turbo Intruder and the Burp Suite repeater group feature implement the technique.

Beyond the Web

Race conditions are not a web phenomenon. Dirty COW, CVE-2016-5195, disclosed on 19 October 2016, was a race in the Linux kernel’s copy-on-write handling that allowed any local user to write to read-only files and escalate to root; it had been present since 2007 and was found through observed exploitation. Filesystem races where a privileged process checks a path and then opens it, allowing a symbolic link to be swapped in between, are a standing hazard in installers and backup agents.

Designing the Window Out

  1. Make the check and the action one atomic operation. A conditional update such as UPDATE accounts SET balance = balance - 50 WHERE id = 1 AND balance >= 50 cannot be interleaved, and the affected row count tells you whether it succeeded.
  2. Lock the row you are about to change, with SELECT ... FOR UPDATE inside a transaction, so a second transaction waits rather than reading stale state.
  3. Let the database enforce the invariant. A unique constraint on a voucher redemption table makes double redemption impossible regardless of application logic.
  4. Use idempotency keys on operations that must happen once, so a repeated request returns the original result instead of performing the action again.
  5. Avoid check-then-act across services. Where state lives in more than one system, use a distributed lock with a timeout, or redesign so one service owns the decision.
  6. Set appropriate transaction isolation. Read committed, the default in several databases, does not prevent the pattern above; serialisable isolation does, at a cost in throughput.

Testing and Detection

These flaws are invisible to a scanner that sends one request at a time, and they are equally invisible to manual testing performed at human speed. Finding them means identifying every endpoint where a limit, a quantity, or a single-use token is involved, then firing concurrent requests at it and checking the resulting state. Logs help afterwards: several identical operations on one object within the same millisecond is a distinctive signature worth alerting on. Because the outcomes map directly onto money and entitlement, these defects sit close to business logic flaws, and both are covered in our web application security testing.

FAQ – Frequently Asked Questions

Why Do Scanners Never Find Race Conditions?

Because automated scanners send requests sequentially and judge each response on its own. A race condition only manifests when two or more requests are processed concurrently, and the evidence is in the resulting state rather than in any single response. Detecting it requires deliberately concurrent requests and a check of the data afterwards, which is a manual test design rather than a signature.

Does Rate Limiting Prevent Limit Overrun?

Usually not, and the two are often the same bug. If the rate limiter increments a counter after each request completes, simultaneous requests all read the same counter value and all pass. Enforcing the limit atomically, for example with an atomic increment in Redis evaluated before processing, is what makes it effective against concurrent traffic.

What Is the Single-Packet Attack?

A technique that uses HTTP/2 multiplexing to send the final bytes of many requests inside one TCP packet, so the server begins processing them within a fraction of a millisecond of each other. It removes network jitter, which was previously the main obstacle to exploiting narrow timing windows, and made many theoretical race conditions reliably exploitable from across the internet.

Which Features Should We Test First?

Anything with a limit or a single use: payment and withdrawal flows, voucher and discount redemption, referral bonuses, stock allocation on limited items, invitation acceptance, password reset tokens, and rate-limited or attempt-limited actions. Also check any workflow that moves an object between states, where two concurrent transitions may both be accepted.

Related Terms

You May Be Interested In These

What Is Double Extortion Ransomware?

Cybersecurity Terms

17 November 2026

What Is Double Extortion Ransomware?

Read More
What Is an IMSI Catcher?

Cybersecurity Terms

17 November 2026

What Is an IMSI Catcher?

Read More
What Is IP Spoofing?

Cybersecurity Terms

21 June 2021

What Is IP Spoofing?

Read More