Written by: Mio Kanzaki(Security Analyst (AI))Reviewed by: 千葉圭介Updated
A race condition exploits a gap between simultaneous operations to make something process twice. MITRE's CWE-362 describes it as a weakness where a shared resource should be used by only one process at a time, yet a time gap remains in which another process can change it.
How does a race condition work?
Imagine two people withdrawing from the same bank account at the same moment. If the clerk does "checking the balance" and "paying out" as separate tasks, both pass the check and together take out more than the balance.
Inside a program, the same thing happens if there is a gap between checking and using. CWE-367 describes, as TOCTOU (time of check to time of use), a weakness in which the state of a resource changes between the check and the use so that the result of the check can no longer be trusted. On a website, care is needed in processing that has limits on counts or quantities, such as the last items in stock, or a coupon allowed once per person.
CWE-362 lists as measures using a synchronization mechanism, reducing shared resources, and using operations that cannot be split (atomic operations). To see how your ordering or booking screens look from outside, you can start with the free URL check.
Why does a race condition matter?
Each operation works correctly by itself, so it is hard to find in ordinary tests. Trying once at a time from the screen does not expose the gap. Only when processing overlaps within a very short time does the odd result appear.
For sites with ordering, booking, or points, if limits on counts or quantities break, the loss is direct. More stock than exists may be sold, or a coupon may be used many times.
On the development side, the basic approach is to combine checking and updating into one operation that cannot be split. Operators can ask their agency whether it considered what happens when processing that handles counts or quantities is called simultaneously.
Related terms
- Business logic vulnerability: a flaw where someone gains unfairly by abusing a gap in the rules
- Insecure design: a problem where protection is missing at the design stage, before building starts
Frequently asked questions
Is a race condition a problem only for busy sites?
A busy site has more chances for operations to overlap, but a quiet site can be affected too. The cause is a gap in how the processing is built, and traffic alone does not decide it. If you have processing that deals in quantities or counts, a design review is worthwhile.
Can an assessment tool find a race condition?
Situations where operations overlap are hard to reproduce, and tools alone may find it hard. For processing that handles quantities or counts, work with whoever built it to check what happens when it is called at the same time.
Next step
The points to check are collected on the race condition vulnerability page. The free URL check shows only what is visible from outside, so contact us to review how your ordering or booking works.
Frequently asked questions
Is a race condition a problem only for busy sites?
A busy site has more chances for operations to overlap, but a quiet site can be affected too. The cause is a gap in how the processing is built, and traffic alone does not decide it. If you have processing that deals in quantities or counts, a design review is worthwhile.
Can an assessment tool find a race condition?
Situations where operations overlap are hard to reproduce, and tools alone may find it hard. For processing that handles quantities or counts, work with whoever built it to check what happens when it is called at the same time.