Is It Really a Race Condition?

Race conditions are funny things. You spend time trying to get multiple requests to arrive at roughly the same moment, and when they finally do, you get a bunch of 200 OK responses staring back at you. Great. Except now you have to figure out whether you've actually broken anything.

Even if both requests appear to have worked, there's another question worth asking: did the issue actually require concurrent requests, or would the same thing have happened if we'd sent them one after the other?

One Invitation, Two Accounts

Imagine we're testing an application that allows administrators to invite users to their organisation through a single-use invitation link. Once someone accepts the invitation, it becomes invalid, and anyone attempting to reuse it should be rejected.

The application has an endpoint that handles invitation acceptance:

POST /api/invitations/accept HTTP/2
Host: app.example.com
Authorization: Bearer %s
Content-Type: application/json

{"invitation_token":"INV-12345"}

We have two test accounts, Alice and Bob, and one invitation. Sending the requests sequentially works as expected. Alice accepts the invitation, while Bob gets rejected because it's already been used.

But what if both requests arrive at almost exactly the same time?

If the application checks whether the invitation is valid before marking it as used, there's a chance both requests could pass the check before either one marks the invitation as used.

Getting the Timing Right

Burp Repeater can send requests in parallel, which is often enough for initial testing. For more control, there's Turbo Intruder.

Here's a simplified Turbo Intruder script that queues two requests, one authenticated as Alice and the other as Bob, behind the same gate and releases them together:

def queueRequests(target, wordlists):
    engine = RequestEngine(
        endpoint=target.endpoint,
        engine=Engine.BURP2,
        concurrentConnections=1
    )

    alice_token = 'ALICE_TOKEN'
    bob_token = 'BOB_TOKEN'

    engine.queue(target.req, alice_token,
                 gate='race1', label='Alice')

    engine.queue(target.req, bob_token,
                 gate='race1', label='Bob')

    engine.openGate('race1')

def handleResponse(req, interesting):
    table.add(req)

This uses HTTP/2 request synchronisation, so the target needs to support HTTP/2. The %s placeholder in our earlier request is replaced with Alice's or Bob's authentication token. Both requests use the same invitation and are queued behind the same gate before being released together.

James Kettle's Smashing the State Machine: The True Potential of Web Race Conditions covers these techniques in much greater detail, so I won't repeat them here.

Did It Actually Work?

Let's say both requests go through, and Alice and Bob receive the following response:

HTTP/2 200 OK
Content-Type: application/json

{"status":"success","message":"Invitation accepted"}

At first glance, it looks like both accounts have successfully accepted the invitation. But before writing up a finding, I'd want to know what actually happened.

Perhaps Alice can access the organisation, but Bob can't. A database constraint might have prevented the second membership from being created, or the application might have acknowledged the request before processing was complete. So we can't really say we've bypassed the single-use restriction.

To verify this, I'd log in separately as Alice and Bob and check whether both accounts have actually been added to the organisation. I'd also try accessing an organisation-specific resource using each account's session, rather than relying solely on what the interface shows.

For example, if the application has an endpoint that returns organisation details, I'd send the following request using each account's authentication token:

GET /api/organisations/12345 HTTP/1.1
Host: app.example.com
Authorization: Bearer <alice-or-bob-token>

If Alice can access the resource but Bob receives a 403 Forbidden, that would suggest Bob hasn't been granted the same access, despite receiving a successful invitation response. Of course, we'd still need to check whether Bob had been added as a member with different permissions or whether another part of the application was affected.

Now imagine both accounts appear in the organisation's member list and can access its resources. If the invitation was only supposed to work once, we've got a problem.

There are other things worth checking too. Did both accounts receive the same permissions? Were two licences allocated? Did either request trigger downstream operations that shouldn't have occurred?

Is It Actually a Race Condition?

But even if we've confirmed that both accounts joined using the same invitation, there's still another question: was concurrency actually necessary?

I'd want to go back and try the same thing sequentially with a fresh invitation. Let Alice accept it first, wait for that request to complete, and then have Bob attempt to use it.

If Bob can still join, the single-use restriction is broken even without concurrent requests. We might be looking at a validation or business logic issue rather than a race condition.

But if the sequential test consistently rejects Bob, while concurrent requests occasionally allow both accounts to join, that's much stronger evidence that timing is involved.

I'd repeat both tests with fresh invitations to see how consistently the behaviour occurs. Race conditions aren't always reproducible on every attempt, so one failed attempt doesn't necessarily rule out the issue.

What About the Fix?

If it's a race condition, the fix might involve database locking or an atomic conditional update to make sure only one request can successfully use the invitation, even if multiple requests arrive at the same time.

But if the same thing happens with sequential requests, locking isn't going to help much. We'd need to look at how the application checks whether an invitation has already been used, and why it's allowing another account to accept it.

So, What's the Finding?

If two accounts can accept the same single-use invitation, we've got something worth reporting. But calling it a race condition without checking whether concurrency is actually required could send developers looking in the wrong place.

The impact might be the same, but the underlying issue isn't necessarily the same. And the fix probably won't be either.

More research

Richard Appleby · · 8 min read

Stealing Auth Tokens Through the WebView Bridge

A JavaScript bridge with no origin check and a navigation policy with no host allowlist — how two missing lines of code chain into silent account takeover on iOS and Android.

All research