Skip to content
Race condition Write-up Advanced

How Primedice was exploited for $1M in Bitcoin

A gambler exploited a race condition in Primedice's provably fair system by flooding the server with requests, causing it to reveal an active server seed. This let him predict bet outcomes and win over 2400 bitcoins.

medium.com

Published on medium.com

This is the story of how we lost around $1 million worth of bitcoin to a hacker who exploited our online casino’s RNG system. This happened last year, but we’ve decided to share our experience for transparency and so that others can learn from our mistakes.

Stunna, 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 a race condition in the seed rotation logic allowed a decrypted server seed to be both revealed and still active when requests were sent rapidly.

Impact

The attacker won over 2400 bitcoins (about $1 million at the time) and later, after a flawed patch, won an additional 2000+ bitcoins but could only withdraw 50-60 due to a drained hot wallet.

What the attacker needed

A free account; ability to send many requests quickly

The fix

The glitch was patched, but the patch was improper and a work-around was found; the text does not describe a correct fix.

How it was found

  1. Create an account and place bets.
  2. Send hundreds of requests in under a second to the server.
  3. Obtain a decrypted server seed that is still active.
  4. Use the known seed to predict bet outcomes and wager accordingly.

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.

Primedice used a system where each bet's outcome was based on a secret random number (server seed) that was later revealed to prove fairness. The attacker sent many requests at once, and the server mistakenly revealed a seed that was still in use, so he could predict wins and bet accordingly.

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.