Skip to content
Race condition Write-up Intermediate

How a Race Condition Let Me Buy $40,000 in Stocks With $2,500

A race condition in a stock-buying feature allowed multiple simultaneous purchase requests to be processed against the same available balance, letting the attacker buy far more stock than their funds should permit. The platform later recorded the overspend as a negative balance, so the attacker could profit only if the stock price rose before settlement.

medium.com

Published on medium.com

بِسْ� اللَّه الرَّحْ� ن الرَّحِي� . . اللَّه� َّ صَلِّ وَسلَّ� وبارك على نَبِينَا � ُح� َّد

Ahmed adel, 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.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the balance check and the purchase were not performed atomically, so concurrent requests could all pass the funds check before any debit was recorded.

Impact

An attacker could buy stocks worth far more than their balance, but the platform recorded the overspend as a debt, so profit depended on the stock price rising before the debt was settled.

What the attacker needed

An account on the platform; ability to create a recurring plan; send concurrent requests

How it was found

  1. Find a stock-buying feature that uses a single request without preflight requests or signatures, such as a recurring plan.
  2. Set the funding source to the platform's available balance (BUYING_POWER).
  3. Send many purchase requests at the same time (the author used 16).
  4. Observe that the purchases succeed beyond the available funds, leaving a negative balance.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A race condition happens when a system checks something (like your account balance) and then acts on it, but if many requests arrive at the same moment, the check can pass for all of them before any purchase is recorded. Here, the attacker sent many buy orders at once, so the platform thought each one was affordable and bought far more stock than the money available. The platform did notice the debt afterwards, so the gain depended on the stock price going up.

What is Race condition?

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

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.