Skip to content
Race condition Write-up Intermediate

Race Condition Bug In Web App: A Use Case

A free-tier user could create more consoles than the allowed limit by sending many parallel creation requests while simultaneously deleting one console, exploiting a race condition. This let the attacker bypass the account restriction and obtain extra resources.

medium.com

Published on medium.com

Web Development

Mandeep Jadon, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 4 min read.

Context

The target was a website that provides free consoles to its users, along with some limited space and bandwidth. It offered three tiers of accounts: a free account and two paid accounts, each with a different set of benefits. One restriction of the free account was the number of consoles a user could create, limited to 2 consoles per user. Creating a console sent a GET request to the server. The free account was limited to 2 consoles per user, so the question was whether the cap could be bypassed.

Setup

The testing was done with Burp Intruder, using null payloads against the console creation GET request and pushing the maximum possible number of threads. No account names, versions or other environment details are given.

Finding it

While looking at the console creation flow, the researcher noticed that creating a console was a simple GET request. Seeing the GET request, the researcher wondered whether the limited number of consoles could be bypassed.

A race condition occurs when multiple threads simultaneously access the same shared code or resource without locking or synchronisation, which may result in inconsistency of the output. The report notes the common organisational gap behind this: developers assume concurrency is managed by the server, while the server side assumes the developers handle concurrent thread execution. The following diagram shows the execution of processes over the same shared resource.

From the original on medium.com

The report also cites the OWASP theoretical example of a joint savings account. Account A has 100 credits and Account B has 100 credits. Both User 1 and User 2 want to transfer 10 credits from Account A to Account B. If the transaction was correct the outcome should be Account A with 80 credits and Account B with 120 credits. Due to concurrency issues, the following result could be obtained instead:

  1. User 1 checks the value of Account A (=100 credits)
  2. User 2 checks the value of Account A (=100 credits)
  3. User 2 takes 10 credits from Account A (=90 credits) and puts it in Account B (=110 credits)
  4. User 1 takes 10 credits from Account A (still believed to contain 100 credits) (=90 credits) and puts it into Account B (=120 credits)

Result: Account A has 90 credits and Account B has 120 credits.

Exploitation

Step 1: Fire the creation request with many threads

The researcher fired up Intruder with the maximum possible number of threads and intruded the GET request that creates a console, using null payloads, to see how the server would behave.

This did not work well. The first two requests returned valid responses. After that, the responses came back at a fixed length, saying that the console limit is reached.

Limit Reached From the original on medium.com

Step 2: Repeat with more threads

The problem with race condition bugs is that they are not executed in one go. The outcome depends on factors such as the current number of threads on the server, the load on the server, your own internet speed and other factors. The researcher shot the request multiple times with over 100 threads, but got the same reply from the server, and only two consoles were created.

From the original on medium.com

Step 3: Remove a console while the threads run

The workaround was to simulate the same attack but, this time, remove one of the consoles manually from the UI while the threads were being executed. With that change, 3 requests got the same response, so the console limit of the free account was successfully bypassed.

3 Requests executed From the original on medium.com
Success

Root cause

The report does not describe the server-side code. The report does not describe the server-side code or explain the mechanism behind the bypass. The report frames this as the usual split of assumptions between developers and server operators rather than as a specific code defect. Why the manual removal of a console during the run changed the outcome is not explained in the report.

Impact

A free user could create more consoles than the free tier allows. The report demonstrates this with 3 consoles against a limit of 2. The result is not deterministic: it depends on server load, thread count and network conditions, and repeated attempts may still fail.

Fix

Variants to test

The report lists the key factors to keep in mind:

  1. Race condition bugs are mostly on those endpoints which deal with adding, removing or changing a particular resource.
  2. They may or may not be replicated in one go. Try again and again.
  3. The best use case is to test by executing parallel threads and making changes on the particular resource at the same time. There are higher chances you can get it executed.
  4. Ideally you should shoot up 100+ threads if you are testing in Burp.

A positive result looks like more successful responses than the enforced limit allows, as in this case where 3 requests got the same response against a limit of 2 consoles.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 11 min read.

What happened, in plain words

A website gave every user a small number of free "consoles" (think of a console as a small workspace or container the site creates for you). A free account was allowed to have only 2 of them. The person who wrote this report noticed that creating a console was just a normal web request, and wondered whether sending many of those requests at almost exactly the same moment could trick the site into giving a free user more consoles than the rules allow.

That kind of trick is called a race condition. The short version: several requests reach the same shared resource at nearly the same moment and interfere with each other. If several requests arrive inside that gap, they can all be told "you are under the limit" before any of them has actually been recorded as a new console. The result is more consoles than the limit allows.

The report walks through the idea, an everyday banking example, the first failed attempt, a second failed attempt with more parallel requests, and finally a workaround that worked: deleting one console by hand while the parallel requests were running. It ends with a short list of tips for finding similar bugs.

Background: what a race condition is

Before the bug itself, the report explains the concept. A race condition occurs when multiple threads simultaneously access the same shared code or resource without locking or synchronisation, which may result in inconsistency of the output.

A few words in that sentence need unpacking for someone new to this:

  • A thread is one small stream of work inside a program. A web server handles many visitors at once, so it runs many threads at the same time. Picture a supermarket with several tills open: each till is a thread, and the shelves are the shared resource.
  • A shared resource is anything more than one thread can read or change, such as a counter of how many consoles a user has, or a bank balance.
  • Locking (or synchronisation) means making one thread wait until another has finished with the shared resource, like a sign on a fitting room door. Without it, two threads can read the same value and both act on it.
  • Inconsistency of the output means the final result does not match what should have happened if the requests had been handled one at a time.

The report also points at a common organisational gap: while developing the application the developer thinks that the concurrency is managed by the server itself, while the server guys think that the devs would be responsible for dealing with concurrent thread execution. In other words, each side assumes the other has handled it, and nobody does. The report calls this a typical IT company situation.

The following diagram shows the execution of processes over the same shared resource.

From the original on medium.com

The diagram comes from an article on testing race conditions in web applications, linked in the report. It illustrates how several processes reach for the same shared resource at the same time, which is the shape of the problem in this bug.

The banking example

The report cites a theoretical example directly from OWASP, a well-known organisation that publishes guidance on web security. It uses a joint savings account to show how two requests can interfere with each other.

Account A has 100 credits. Account B has 100 credits. Both User 1 and User 2 want to transfer 10 credits from Account A to Account B. If the transaction was correct the outcome should be:

  • Account A has 80 credits.
  • Account B has 120 credits.

However, due to concurrency issues, the following result could be obtained:

  1. User 1 checks the value of Account A (=100 credits)
  2. User 2 checks the value of Account A (=100 credits)
  3. User 2 takes 10 credits from Account A (=90 credits) and puts it in Account B (=110 credits)
  4. User 1 takes 10 credits from Account A (still believed to contain 100 credits) (=90 credits) and puts it into Account B (=120 credits)

Result: Account A has 90 credits and Account B has 120 credits.

Read that again slowly, because it is the whole idea in miniature. Both users looked at the balance before either of them changed it. Each one then subtracted 10 from the number they remembered (100), not from the number that was actually there after the other person's transfer. So Account A lost only 10 credits in total instead of 20, while Account B gained 20. The bank has effectively created 10 credits out of thin air. The same shape of mistake, applied to a console counter instead of a balance, is what the rest of the report is about.

The bug that was found

The report says there were many race condition bugs found that were pretty straightforward to exploit, but it discusses one specific bug to show where to look for these bugs and what techniques to use when you get stuck.

The site and its limits

The site provided free consoles to users, along with some limited space and bandwidth. It had three tiers of accounts: a free account and two paid accounts, each with a different set of benefits. One restriction of the free account was the number of consoles the user could create, limited to 2 consoles per user.

When you create a console, a GET request to the creation of the console was sent. A GET request is the ordinary kind of request your browser makes when you open a page or click a link: it asks the server to give you something. It is the simplest request type on the web, and it is worth knowing that a request which changes something on the server (here, creating a console) can still be a GET request, even though that is not the usual convention.

Seeing this, the researcher wondered whether it would be possible for an attacker to bypass this limited number of consoles. The reasoning is: the limit of 2 is enforced somewhere on the server, and the server has to check the current count before it creates a new console. If many creation requests arrive close enough together, the server might check the count for each of them before any of them has actually created a console. That is exactly the banking example, with consoles instead of credits.

Trying it: the first attempt

The researcher fired up the intruder with the maximum possible number of threads and started to intrude the GET request (using null payloads) to see what the server will behave.

Some terms here:

  • Burp Intruder is a tool inside Burp Suite, a program security testers use to capture and replay web requests. Intruder takes one captured request and sends it many times, optionally in parallel, optionally with different values in chosen places. Think of it as a machine that can knock on a door a hundred times at once instead of you knocking by hand.
  • A null payload means the tool sends the request with no value inserted anywhere. The request is repeated exactly as captured. The point is not to change the request, but to send many identical copies at the same moment.
  • Threads, in this context, are how many copies Intruder sends at the same time. More threads means more requests in flight simultaneously, which is what a race condition needs.

Unfortunately this didn't work well. The researcher was getting valid response for the first two requests. Then after that, responses started coming back at a fixed length, saying that the console limit is reached.

Limit Reached From the original on medium.com

The screenshot is captioned "Limit Reached". In plain terms, the server was doing its job: it counted the consoles, saw the limit, and refused.

Trying again with more threads

The report explains why the first attempt is not the end of the story. The problem with race condition bugs is that they are not executed in one go. The outcome depends on various types of factors like the current number of threads on the server, the load on the server, your own internet speed and other factors.

That is worth pausing on. A race condition is a timing problem, and timing is not fully under your control. The server may be busy with other visitors, your own connection may deliver the requests slightly unevenly, and the server's own scheduling may spread the requests out just enough for the check to happen cleanly each time. So a failed attempt does not mean the bug is not there; it may just mean the requests did not arrive close enough together.

The researcher tried shooting that request multiple times with over 100 threads but got the same reply from the server. Only two consoles were created.

From the original on medium.com

The report states that the same reply came back and only two consoles were created. More threads alone did not win the race.

The workaround that worked

Then the researcher tried the following workaround: simulating the same attack but this time removing one of the consoles manually from the UI while the threads were being executed.

In other words, while the flood of creation requests was running, the researcher opened the site's normal interface in the browser and deleted one of the existing consoles by hand. With that change, 3 requests got the same response, so the console limit of the free account was successfully bypassed.

3 Requests executed From the original on medium.com

The screenshot is captioned "3 Requests executed". The report does not explain why deleting a console during the run changed the outcome; it only reports that it did.

Success From the original on medium.com

The final screenshot is captioned "Success".

Why it works

The report does not describe the server-side code. That is the same shape as the banking example: several requests read the same count, all decide they are under the limit, and all go ahead.

The report frames the underlying cause as the usual split of assumptions between developers and server operators rather than as a specific code defect. Why the manual removal of a console during the run changed the outcome is not explained in the report.

What it means in practice

A free user could create more consoles than the free tier allows. The report demonstrates this with 3 consoles against a limit of 2. The result is not deterministic: it depends on server load, thread count and network conditions, and repeated attempts may still fail.

How it could be fixed

"Atomic" here means all-or-nothing: the check and the creation happen as one indivisible step, so no other request can slip in between them. Going back to the fitting room comparison, it is the difference between glancing at the door and actually locking it behind you.

Tips for finding similar bugs

The report ends with the key factors to keep in mind:

  1. Race condition bugs are mostly on those endpoints which deal with adding, removing or changing a particular resource.
  2. They may or may not be replicated in one go. Try again and again.
  3. The best use case is to test by executing parallel threads and making changes on the particular resource at the same time. There are higher chances you can get it executed.
  4. Ideally you should shoot up 100+ threads if you are testing in Burp.

A positive result looks like more successful responses than the enforced limit allows, as in this case where 3 requests got the same response against a limit of 2 consoles.

Glossary

  • API: the set of requests a website or app accepts from a browser or another program, and the responses it sends back. It is the counter where you place an order, separate from the dining room you see.
  • Atomic: done as a single indivisible step, so nothing else can happen in the middle of it.
  • Burp Intruder: a tool in Burp Suite that takes one captured web request and sends it many times, optionally in parallel and optionally with values inserted in chosen places.
  • Burp Suite: a program security testers use to capture, inspect and replay web traffic between a browser and a server.
  • Check-then-act: a pattern where a program first checks a condition and then acts on it, leaving a gap in which another request can change things.
  • Concurrency: several tasks making progress at the same time rather than strictly one after another.
  • Console: in this report, a small workspace or container the site creates for a user, subject to a per-account limit.
  • Cookie: a small piece of data a website stores in your browser so it can recognise you on later requests, for example to keep you logged in.
  • Endpoint: a specific address on a server that accepts a particular request, such as the one that creates a console.
  • GET request: the ordinary request type a browser uses to ask a server for something, usually by opening a page or following a link.
  • Inconsistency: a final result that does not match what should have happened if the requests had been handled one at a time.
  • Locking: making one thread wait until another has finished with a shared resource, so only one works on it at a time.
  • Null payload: a setting in Intruder that inserts no value at all, so the captured request is repeated exactly as it was.
  • OWASP: a well-known organisation that publishes guidance and examples on web application security.
  • Race condition: a bug where several requests reach the same shared resource at nearly the same moment and interfere with each other, producing a result the rules should not allow.
  • Shared resource: anything more than one request or thread can read or change, such as a counter or a balance.
  • Synchronisation: coordinating threads so they do not touch a shared resource at the same time.
  • Thread: one stream of work inside a program; a busy web server runs many at once, like several tills in a supermarket.
  • Token: a value, often a long string, that a site issues to identify a session or authorise a request, similar in purpose to a cookie.
  • UI: the user interface, the part of the site you see and click in a browser.
  • Vulnerability: a weakness in a website or program that someone can use to make it behave in a way its owners did not intend.

Similar reports

View all

Same bug class and techniques, clearest first.

Race conditions

The lesson behind this report.

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.