Skip to content
Race condition Write-up Intermediate

The Fast and the Curious: Finding a Race Condition in Worldcoin

A race condition in the World ID SDK's cloud implementation allowed an attacker to bypass the preset verification limit, enabling multiple verifications from the same user. An attacker could exploit this to perform actions beyond the intended limit, such as casting multiple votes instead of one.

Dane Sherrets Follow

Published on medium.com

Bounty$3,000 View original

In August of 2023 I applied the “State Machine” research from James Kettle on the World ID SDK and identified a Race Condition that would have enabled an attacker to bypass the preset verification limit on a cloud-based implementation. Exploitation of this vulnerability would have devastating consequences for a…

Dane Sherrets, 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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 4 min read.

Context

Worldcoin is a cryptocurrency project with two stated aims: biometrically verifying unique humans, and providing a distribution mechanism for Universal Basic Income. Beyond the token, the project ships an SDK built around biometric authentication, so that other applications can use it to confirm that one user equals one human being. The author frames this as an identity provider (IDP) and enforcer for limits an integrating app configures, for example allowing a unique human to vote only once on a given issue.

From the original on medium.com

There are two implementations of the SDK: one for EVM-compatible blockchains, and a cloud-based version that requires no blockchain integration. Both use merkle-tree based cryptography to create a tamper-proof log of transactions. The author does not go into that cryptography because it is not relevant to the bug.

Example use cases for World ID From the original on medium.com

Example use cases for World ID

In the developer workflow, an account lets you create "Actions" (for example, "vote on this proposal") and set a maximum number of "Verifications" (for example, how many times a human can vote on a proposal). Worldcoin provides a simulator for testing transactions and verifications, and the author did most of his testing there, running the requests through Burp Suite.

Burp request for performing a single action From the original on medium.com

Burp request for performing a single action

The requests were all very similar, though the "credential type" could be changed between "orb", "device" and "chain". The author spent many hours trying to break the flow and the signatures without success, and gave up for a few weeks.

Setup

The testing was done against the cloud-based implementation, using the Worldcoin simulator and a developer account that could create Actions with a maximum number of Verifications. Requests were captured and replayed with Burp Suite, and the parallel-sending capability used later is a Burp Pro feature. The author notes that he only tested the cloud version: he assumed the blockchain version would not be affected because it would require a transaction to be finalised, and the team confirmed that assumption was correct.

Finding it

After DEF CON 31, where James Kettle presented research on Smashing The State Machine, the author thought the technique might be worth trying on Worldcoin, though he did not expect anything to come of it. He then caught Covid, was stuck on his couch in front of a computer, and decided to give it a shot. He opened a Burp Repeater tab, made sure he had the Burp update containing the "Send in Parallel" feature, and applied it to the Worldcoin flow described above.

Exploitation

Step 1: capture the request

Capture the request for the action and send it to Repeater.

Step 2: create a new tab

Make a new tab in Repeater for the request.

Step 3: duplicate the request

Duplicate the original request roughly 20 times in the new tab.

Step 4: send in parallel

Send all of the duplicated requests "In Parallel".

Feature in Burp Pro that enables sending parallel requests that results in race condition From the original on medium.com

Feature in Burp Pro that enables sending parallel requests that results in race condition

Result

The requests succeeded beyond the configured limit. Where the author should have seen only 2 verifications of "unique humans", he saw 20.

The address ending in `7c6` should only be able to appear twice on this list… but because of race condition it appears 20+! From the original on medium.com

The address ending in 7c6 should only be able to appear twice on this list, but because of the race condition it appears 20+ times

Root cause

Because the Worldcoin project is open source, the author could review the code, and he saw a red flag in the canVerifyForAction util.

From the original on medium.com

The way nullifier was referenced in other parts of the codebase allowed for a race condition: it was simply added to an array without a lock, so parallel requests were all treated equally. Parallel requests were all treated equally because the array was appended to without a lock.

Impact

The vulnerability would have enabled an attacker to bypass the preset verification limit on a cloud-based implementation. For a project relying on World ID to restrict how many actions a user can take, the consequences would be severe: if a project used the SDK to say a user should only be able to cast one vote, an attacker could exploit the bug to cast 20. The author describes the consequences as devastating for such a project, and the report was triaged as "High" and awarded $3000.

Fix

The Worldcoin team addressed the issue by using the database to create an artificial lock, so that even if two requests arrive at the same time they are treated properly. In the linked pull request, new database tables for nullifiers were added, and the canVerifyForAction code was updated to reference the nullifier number of uses instead of just the length of the array.

From the original on medium.com

Variants to test

The author's broader point is that Web3 projects still rely heavily on Web2, so vulnerabilities are not limited to the blockchain or smart contract layer. He has since found similar High and Critical issues in the wild, and published a basic Python script to automate testing for them, intended as a starting point for hunters without Burp Suite Pro.

A positive result is more records accepted than the configured maximum, as with the 20 verifications where 2 were expected. A positive result is a check-then-act pattern with no atomicity between the two. A positive result is the limit being bypassed on any one of them. A positive result is the race succeeding on the cloud path while the blockchain path, which requires transaction finalisation, holds.

Or watch on YouTube
From the original on medium.com

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 11 min read.

What happened, in plain words

A security researcher found a bug in Worldcoin, a cryptocurrency project that also offers a service for proving that a user is a real, unique human being. The bug let someone do an action more times than the service was supposed to allow. If an app used Worldcoin to say "each person may vote once", an attacker could use the bug to vote many times instead.

The bug is called a race condition. Imagine two shop assistants both looking at the last concert ticket at the same moment, both seeing it is available, and both selling it. Two people now hold a ticket for one seat. A race condition in software works the same way: several requests arrive so close together that each one checks a limit before any of them has recorded its own action, so all of them are let through.

The researcher found it by sending about 20 copies of the same request at exactly the same time, using a feature of a tool called Burp Suite. Where the system should have accepted only 2 verifications, it accepted 20. The Worldcoin team fixed it, rated the report "High", and paid a $3000 bounty.

From the original on medium.com

Background: what Worldcoin is

Worldcoin describes two aims: checking biometrically that each person is a unique human, and distributing a Universal Basic Income. Most people know it as the company with the orb you look into to receive cryptocurrency. The researcher is not enthusiastic about handing biometric data to one central company, but he argues that stopping fake accounts (Sybil resistance) is one of the hardest problems on the internet, especially as anyone can now create hundreds of AI-powered bots.

The part that matters here: the SDK

An SDK (software development kit) is a ready-made set of code that other developers plug into their own apps, so they do not have to build a feature from scratch. Worldcoin's SDK is built around biometric authentication: another app can use it to confirm that one user account equals one real human being.

The researcher calls this an identity provider (IDP). An IDP is a service that vouches for who you are, the way "Sign in with Google" tells a website that you really are the owner of a Google account. Here the SDK also acts as an enforcer: the app tells it a rule such as "one vote per human", and the SDK is trusted to apply that rule.

That sounds small, but it matters for voting, airdrops (free token distributions) and bot protection. If you wanted an app where a unique human could vote only once on an issue, you could make every user authenticate through the Worldcoin SDK, which would act as the identity provider and the enforcer of the limit you configured.

Example use cases for World ID From the original on medium.com

Example use cases for World ID

Two versions of the SDK

There are two implementations. One works with EVM-compatible blockchains (blockchains that follow the Ethereum standard). The other is cloud-based: it runs on ordinary internet servers and needs no blockchain at all. Both use merkle-tree based cryptography to build a tamper-proof log of transactions. A merkle tree is a way of fingerprinting a whole list of records so that changing any one record changes the fingerprint; the researcher skips the details because they are not relevant to the bug.

Actions, Verifications and the simulator

In the developer workflow you create "Actions", for example "vote on this proposal", and set a maximum number of "Verifications", for example how many times a human may vote on that proposal. Worldcoin provides a simulator for testing transactions and verifications, and the researcher did most of his testing there, sending the traffic through Burp Suite.

Burp Suite is a tool that sits between your browser and a website. It records every request your browser sends and lets you edit and resend it. A request is simply the message your browser sends to a server, for example "here is my vote".

Burp request for performing a single action From the original on medium.com

Burp request for performing a single action

The requests were all very similar. The "credential type" could be changed between "orb", "device" and "chain", meaning the kind of proof a user presents. The researcher spent many hours trying to break the flow and the signatures without success, and gave up for a few weeks. A signature here is a cryptographic stamp proving a message really came from the holder of a key; forging one is meant to be practically impossible, which is why that route led nowhere.

Setup: what was tested and how

Testing was done against the cloud-based implementation, using the Worldcoin simulator and a developer account that could create Actions with a maximum number of Verifications. Requests were captured and replayed with Burp Suite. The parallel-sending feature used later exists only in Burp Pro, the paid edition.

The researcher tested only the cloud version. He assumed the blockchain version would not be affected, because a blockchain transaction has to be finalised (confirmed and written permanently into the chain) before it counts, and the team confirmed that assumption was correct.

Finding it: where the idea came from

At the DEF CON 31 security conference, James Kettle presented research called Smashing The State Machine. The idea is to attack the order in which a server moves through the steps of a process, rather than attacking a single request. The researcher thought the technique might be worth trying on Worldcoin, though he did not expect anything to come of it. He then caught Covid, was stuck on his couch in front of a computer, and decided to give it a shot. He opened a Burp Repeater tab (Repeater is the part of Burp where you edit and resend a request by hand), made sure he had the Burp update containing "Send in Parallel", and applied it to the Worldcoin flow described above.

Exploitation: the four steps

Step 1: capture the request

Capture the request for the action and send it to Repeater. You do this so you hold the exact message the app sends when a human verifies, ready to replay as often as you like.

Step 2: create a new tab

Make a new tab in Repeater for the request. Keeping the copies in their own tab leaves the original untouched and makes it easy to fire many at once.

Step 3: duplicate the request

Duplicate the original request roughly 20 times in the new tab.

Step 4: send in parallel

Send all of the duplicated requests "In Parallel". Sending in parallel means firing them all at the same moment instead of one after another. This is the heart of the attack: if the requests arrive one at a time, the server records the first and rejects the rest. If they arrive together, each one may check the limit before any of the others has been recorded.

Feature in Burp Pro that enables sending parallel requests that results in race condition From the original on medium.com

Feature in Burp Pro that enables sending parallel requests that results in race condition

Result

The requests succeeded beyond the configured limit. Where the researcher should have seen only 2 verifications of "unique humans", he saw 20.

The address ending in `7c6` should only be able to appear twice on this list… but because of race condition it appears 20+! From the original on medium.com

The address ending in 7c6 should only be able to appear twice on this list, but because of the race condition it appears 20+ times

Root cause: why it worked

Because the Worldcoin project is open source (its code is public), the researcher could read it, and he saw a red flag in the canVerifyForAction util. A util is a small helper function that other parts of the code call to do a common job; this one decides whether a given action may still be verified.

From the original on medium.com

The way nullifier was referenced in other parts of the codebase allowed for a race condition. It was simply added to an array (an ordered list held in memory) without a lock. A lock is a mechanism that lets only one request at a time change a shared piece of data; without one, parallel requests were all treated equally. Each concurrent request checked the limit against the same state, before any of the others had been added, and every one of them was allowed through.

Impact: what an attacker could do

The bug would have let an attacker bypass the preset verification limit on a cloud-based implementation. For a project relying on World ID to restrict how many actions a user can take, the consequences would be severe: if a project used the SDK to say a user should only be able to cast one vote, an attacker could exploit the bug to cast 20. The researcher calls the consequences devastating for such a project. The report was triaged as "High" and awarded $3000.

Fix: how the team closed it

The Worldcoin team addressed the issue by using the database to create an artificial lock, so that even if two requests arrive at the same time they are treated properly. A database is the server's organised store of records, and it can enforce that only one change happens at a time. In the linked pull request, new database tables for nullifiers were added, and the canVerifyForAction code was updated to reference the nullifier number of uses instead of just the length of the array.

From the original on medium.com

Variants to test: where else to look

The researcher's broader point is that Web3 projects still rely heavily on Web2, meaning blockchain projects still run ordinary web servers and databases behind the scenes, so vulnerabilities are not limited to the blockchain or smart contract layer. He has since found similar High and Critical issues in the wild, and published a basic Python script to automate testing for them, meant as a starting point for hunters who do not have Burp Pro.

A positive result is more records accepted than the configured maximum, as with the 20 verifications where 2 were expected. A positive result is a check-then-act pattern with no atomicity between the two: the check and the act are not guaranteed to happen as one indivisible step. A positive result is the limit being bypassed on any one of them. A positive result is the race succeeding on the cloud path while the blockchain path, which requires transaction finalisation, holds.

Or watch on YouTube
From the original on medium.com

Glossary

  • API: a defined way for one piece of software to talk to another, like a menu of requests a service accepts.
  • Action: in Worldcoin's developer workflow, a named thing a user can do, such as "vote on this proposal".
  • Airdrop: a free distribution of cryptocurrency tokens to many users.
  • Array: an ordered list of values held in a program's memory.
  • Atomicity: the property that a group of operations happens as one indivisible step, so nothing can slip in between.
  • Biometric authentication: proving who you are using a physical characteristic, such as an iris scan.
  • Blockchain: a shared ledger of records that many computers keep in sync and that is very hard to alter after the fact.
  • Bounty: a reward a company pays to someone who reports a security bug responsibly.
  • Burp Pro: the paid edition of Burp Suite, which includes features such as sending requests in parallel.
  • Burp Repeater: the part of Burp Suite where you edit a captured request and resend it by hand.
  • Burp Suite: a tool that sits between your browser and a website, recording, editing and replaying requests.
  • Check-then-act: a pattern where code first checks a condition and then acts on it, with a gap in between that another request can exploit.
  • Cloud-based: running on ordinary internet servers rather than on a blockchain.
  • Credential type: the kind of proof a user presents, here "orb", "device" or "chain".
  • Cryptocurrency: digital money recorded on a blockchain.
  • Database: a server's organised store of records, which can enforce that only one change happens at a time.
  • DEF CON: a well-known security conference where researchers present new attack techniques.
  • EVM-compatible: following the Ethereum standard for blockchains and smart contracts.
  • Finalised: said of a blockchain transaction once it is confirmed and permanently written into the chain.
  • Identity provider (IDP): a service that vouches for who you are to another app, like "Sign in with Google".
  • Lock: a mechanism that lets only one request at a time change a shared piece of data.
  • Merkle tree: a way of fingerprinting a whole list of records so that changing any one record changes the fingerprint.
  • Nullifier: a value that marks a particular proof as already used, so it cannot be spent twice.
  • Open source: said of software whose code is publicly available to read.
  • Orb: Worldcoin's physical device for scanning a person's iris.
  • Parallel requests: requests sent at the same moment rather than one after another.
  • Pull request: a proposed change to a codebase, published for review before it is merged.
  • Race condition: a bug where several operations run so close together that they interfere, each acting on a state the others have not yet updated.
  • Request: the message a browser or tool sends to a server, for example "here is my vote".
  • SDK (software development kit): a ready-made set of code that developers plug into their own apps.
  • Signature: a cryptographic stamp proving a message came from the holder of a key.
  • Simulator: Worldcoin's test environment for trying out transactions and verifications.
  • Smart contract: code that runs on a blockchain and enforces rules automatically.
  • State machine: a model of a process as a set of steps and allowed transitions between them; attacking it means abusing the order of those steps.
  • Sybil resistance: the ability of a system to stop one person from creating many fake identities.
  • Triaged: said of a bug report once the receiving team has reviewed it and assigned it a severity.
  • Universal Basic Income (UBI): a regular payment made to everyone, unconditionally.
  • Util: a small helper function that other parts of a codebase call to do a common job.
  • Verification: in Worldcoin's workflow, one accepted proof that a unique human performed an action.
  • Web2: the ordinary, server-and-database web, as opposed to blockchain-based Web3.
  • Web3: applications built on blockchains and smart contracts.

More from Tools for Humanity (Worldcoin)

View all

The newest disclosed reports for this program.

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.