Skip to content
Race condition Write-up Intermediate

How our users exploited concurrency and how we fixed it

A web game rewarded players for completing goals, but the check-then-act logic was not safe under concurrency, allowing players to submit their final blow multiple times quickly and receive multiple rewards. This gave them inflated scores and an unfair advantage on leaderboards.

eviltrout.com

Published on eviltrout.com

Once upon a time I developed a somewhat popular web game called Forumwarz. At its peak, we were serving about 6 million dynamic requests a day off a single quad-core server.

The author, on eviltrout.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

The code read the goal's completion status and then updated it in separate steps without locking, so concurrent requests could both see the goal as incomplete and both award points.

Impact

Players could earn many multiples more score than intended, giving them a huge advantage on leaderboards.

What the attacker needed

A player account; ability to send multiple requests quickly

The fix

The fix was to perform a conditional update that only sets completed to true if it is currently false, and only award points if exactly one row was changed.

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.

The game gave a reward when you finished a goal. The code first checked if the goal was already done, then gave the reward. If two requests arrived at the same moment, both checks passed before either reward was given, so the player got paid twice. This is called a race condition: the result depends on timing.

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.