How I Created 20 Super-Admins in 1 Second: Exploiting a Race Condition in Querybook
The signup logic checked whether any admin existed and then promoted the new user, without locking, so concurrent requests all saw zero admins. An attacker could send many simultaneous signups and create multiple super-admin accounts on a fresh instance.
A deep dive into a Time-of-Check to Time-of-Use (TOCTOU) flaw during application setup, and the debate between “Internal Tools” vs. Zero Trust.
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 read-then-write check for an existing admin was not atomic, with no database lock or mutex protecting the critical section.
Impact
An attacker with local network access during the narrow setup window could create multiple permanent admin accounts, though the program owner argued this requires a highly trusted internal position.
What the attacker needed
Fresh Querybook instance during setup; local network access to the setup endpoint; ability to send concurrent requests
The fix
The check should be made atomic using database-level locks, unique constraints, or a mutex around the initialisation logic.
How it was found
- Start a fresh Querybook instance locally with Docker.
- Write a script that synchronises many signup requests to fire at the same instant.
- Send the simultaneous signup requests to the signup endpoint.
- Observe that all requests succeed and check the database for multiple admin users.
- Log in with one of the created accounts and confirm admin access.
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.
When a new Querybook instance starts, the first person to sign up is meant to become the administrator. The program checked 'is there an admin yet?' and then made the user an admin, but if many signups arrived at the same moment they all got the answer 'no admin yet' and all became admins. This is called a race condition: the result depends on timing between two steps.
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.