Download audit report
This document presents the security review performed by Nethermind on the World ID contracts. World ID is a privacy-first identity protocol that brings global proof of personhood to the internet. It enables verified users to prove they are unique individuals and, optionally, demonstrate that they perform a given action only once. This is accomplished with Blockchain technology and zero-knowledge proofs (ZKP).
The audited code consists of three different components listed below:
− World ID contracts containing 700 lines of code with 89.22% of code coverage;
Each component includes a README file that briefly introduces the code and instructions on using, testing, and deploying these contracts. Moreover, official documentation was utilized during this assessment. The review was supported by open communication with the development team, allowing for a more comprehensive understanding of the protocol mechanisms and addressing any potential gaps.
The audit was performed using (a) manual analysis of the codebase, (b) automated analysis tools, (c) simulation of the smart contracts, and (d) creation of test cases.
| Audit assessment | |
| Audit Type | Security Review |
| Initial Report | Apr. 17, 2023 |
| Response from Client | May 01, 2023 |
| Final Report | May 22, 2023 |
| Methods | Manual Review, Automated Analysis |
| Repository | WorldID, State Bridge, Airdrop Example |
| Commit Hash (Initial Audit - WorldID) | 20fc82fb52 |
| Commit Hash (Initial Audit - State Bridge) | 6d01d2178d |
| Commit Hash (Initial Audit - Airdrop Example) | 1150365d42 |
| Documentation | WorldID Docs WorldId - README State Bridge - README Airdrop Example - README |
| Documentation Assessment | High |
| Test Suite Assessment | High |
Findings by severity
| # | Contract | LoC | Comments | Ratio | Blank | Total |
| 1 | src/WorldIDIdentityManager.sol | 6 | 24 | 400.0% | 4 | 34 |
| 2 | src/WorldIDRouter.sol | 6 | 22 | 366.7% | 4 | 32 |
| 3 | src/WorldIDRouterImplV1.sol | 121 | 170 | 140.5% | 45 | 336 |
| 4 | src/WorldIDIdentityManagerImplV1.sol | 431 | 437 | 101.4% | 104 | 972 |
| 5 | src/abstract/WorldIDProxy.sol | 6 | 19 | 316.7% | 3 | 28 |
| 6 | src/abstract/WorldIDImpl.sol | 14 | 42 | 300.0% | 6 | 62 |
| 7 | src/utils/CheckInitialized.sol | 16 | 17 | 106.2% | 6 | 39 |
| 8 | src/utils/UnimplementedTreeVerifier.sol | 17 | 19 | 111.8% | 3 | 39 |
| 9 | src/utils/SemaphoreTreeDepthValidator.sol | 8 | 8 | 100.0% | 1 | 17 |
| 10 | src/data/VerifierLookupTable.sol | 41 | 74 | 180.5% | 20 | 135 |
| 11 | src/interfaces/IWorldID.sol | 10 | 16 | 160.0% | 1 | 27 |
| 12 | src/interfaces/IBridge.sol | 4 | 4 | 100.0% | 1 | 9 |
| 13 | src/interfaces/IWorldIDGroups.sol | 11 | 18 | 163.6% | 1 | 30 |
| 14 | src/interfaces/ITreeVerifier.sol | 9 | 16 | 177.8% | 1 | 26 |
| Total | 700 | 886 | 126.6% | 200 | 1786 |
| # | Contract | LoC | Comments | Ratio | Blank | Total |
| 1 | src/StateBridge.sol | 74 | 72 | 97.3% | 32 | 178 |
| 2 | src/OpWorldID.sol | 16 | 39 | 243.8% | 8 | 63 |
| 3 | src/PolygonWorldID.sol | 28 | 40 | 142.9% | 10 | 78 |
| 4 | src/abstract/WorldIDBridge.sol | 76 | 109 | 143.4% | 39 | 224 |
| 5 | src/utils/SemaphoreTreeDepthValidator.sol | 8 | 7 | 87.5% | 1 | 16 |
| 6 | src/interfaces/ICrossDomainOwnable3.sol | 4 | 9 | 225.0% | 1 | 14 |
| 7 | src/interfaces/IWorldID.sol | 10 | 17 | 170.0% | 1 | 28 |
| 8 | src/interfaces/IWorldIDIdentityManager.sol | 4 | 9 | 225.0% | 1 | 14 |
| 9 | src/interfaces/IBridge.sol | 4 | 7 | 175.0% | 1 | 12 |
| 10 | src/interfaces/ISendBridge.sol | 4 | 7 | 175.0% | 1 | 12 |
| 11 | src/interfaces/IOpWorldID.sol | 4 | 10 | 250.0% | 1 | 15 |
| Total | 232 | 326 | 140.5% | 96 | 654 |
| # | Contract | LoC | Comments | Ratio | Blank | Total |
| 1 | src/WorldIDAirdrop.sol | 56 | 53 | 94.6% | 26 | 135 |
| 2 | src/WorldIDMultiAirdrop.sol | 67 | 61 | 91.0% | 31 | 159 |
| Total | 123 | 114 | 92.7% | 57 | 294 |
| # | Finding | Severity | Update |
| 1 | Airdrops’ funds can be stolen from the WorldIDMultiAirdrop contract | Critical | Fixed |
| 2 | Old roots can allow invalid proofs to be submitted as valid in the contract WorldIdBridge | Critical | Fixed |
| 3 | Centralization Risks | Medium | Mitigated |
| 4 | PolygonWorldID sender and receiver can be set by any address | Medium | Fixed |
| 5 | Absence of ROOT_HISTORY_EXPIRY update mechanism in StateBridge contract | Low | Fixed |
| 6 | Lack of a two-step process for transferring ownership | Low | Fixed |
| 7 | NonExistentRoot() may not be executed for nonexistent roots | Low | Fixed |
| 8 | actionId is hashed two times in WorldIDAirdrop contract | Low | Fixed |
| 9 | ActionID may not be unique across applications | Info | Acknowledged |
| 10 | Double initialization of the tree depth | Info | Fixed |
| 11 | Unnecessary storage writes | Info | Fixed |
| 12 | Lack of events for relevant operations | Best Practices | Fixed |
| 13 | Low-level calls may cause errors | Best Practices | Fixed |
| 14 | Non-private functions are not virtual | Best Practices | Fixed |
| 15 | Presence of unused variables | Best Practices | Fixed |
The audit encompasses three components: a) World ID contracts, comprising fourteen contracts; b) World ID state bridge, consisting of eleven contracts; and c) World ID airdrop, containing two contracts. Fig. 2 illustrates a structural diagram of the contracts and their relationships with WorldIDIdentityManager. Subsequently, we outline the primary contracts (highlighted in yellow): VerifierLookupTable, WorldIDIdentityManager, WorldIDRouter, StateBridge, PolygonWorldID, and OpWorldID.
VerifierLookupTable: This contract establishes a mapping between batch sizes and tree verifiers, returning the suitable verifier for a specific batch size before employing that verifier to validate a tree modification proof. The contract inherits from the Ownable contract, which offers a straightforward access control mechanism, ensuring only the contract owner can modify the lookup table. The contract features several public functions for interacting with the lookup table:
a. The getVerifierFor(...) function takes a batch size as input and returns the associated tree verifier instance. It checks that the batch size is valid, i.e., that there is an associated verifier for that size.
b. The addVerifier(...) function allows the owner to add a new verifier for a given batch size. It checks that there is no existing verifier for the given batch size and returns an error if there is.
c. The updateVerifier(...) function allows the owner to update an existing verifier for a given batch size.
d. The disableVerifier(...) function allows the owner to disable a verifier for a given batch size by setting it to null.
WorldIDIdentityManager: Designed to operate behind a proxy, this contract implements a batch-based identity manager for the WorldID protocol, which verifies externally created Zero Knowledge Proofs. The contract features various public functions serving different purposes, such as:
a. The functions setRegisterIdentitiesVerifierLookupTable(...) and setIdentityUpdateVerifierLookupTable(...), which allow setting lookup tables of verifiers used for identity updates.
b. The function setSemaphoreVerifier(...) enables setting the address for the semaphore verifier used for verifying semaphore proofs.
c. The functions enableStateBridge(...) and disableStateBridge(...), which enable or disable the state bridge.
d. The function verifyProof(...), which allows verifying semaphore proofs.
e. The updateIdentities(...) and registerIdentities(...) functions, allowing the owner to modify the current registry of identities in a group. It is worth mentioning that most checks are done when modifying the identities in the group are executed in the proof generation phase and not performed on the smart contracts layer.
The contract owner can only call all of the previously mentioned functions, except for the verifyProof(...). Two of the functions, registerIdentities(...) and updateIdentities(...), require meeting specific conditions for successful verification. After meeting these conditions, the latest root is updated, the previous root is added to history, and its expiration timestamp is set. Fig. 3 shows a sequence diagram to illustrate how contracts interact with each other to register identities. As can be observed, registerIdentities(...) sends the latest WorldID Identity Manager root to all chains.
WorldIDRouter: This contract is designed to operate behind a proxy. Specifically, WorldIDRouter is responsible for dispatching group numbers to the correct identity manager implementation. The contract implements several public functions that serve different purposes:
a. routeFor(...) returns the target address to specific groups based on a provided group number.
b. addGroup(...) adds a new group to the router.
c. updateGroup(...) updates the target address for a group in the router.
d. disableGroup(...) disables the target group in the router.
e. groupCount(...) returns the number of groups in the routing table.
StateBridge: The StateBridge contract is responsible for distributing new World ID Identity Manager roots and timestamps to the supported chains, namely Polygon and Optimism. This contract lives on Ethereum Mainnet and is called by the WorldIDIdentityManager contract through the registerIdentities(...) and updateIdentities(...) functions described below:
a. sendRootMultichain(...) is used to transmit the latest WorldID Identity Manager root to all chains supported by the WorldID Identity Manager contract. The root is provided as an argument to this function. Before transmitting, this function verifies that the caller is the WorldID Identity Manager contract. Fig. 3 describes the sequence to send the root to the chains.
b. transferOwnershipOptimism(...) allows the StateBridge contract to transfer ownership of OpWorldID to another contract on L1 or to a local Optimism EOA. This function can only be called by the contract owner.
PolygonWorldID: The PolygonWorldID contract manages the root history of the WorldID Merkle root on Polygon PoS. Its primary goal is to allow semaphore-proof verifications on the Polygon PoS chain. As described in Fig. 2, it inherits from the WorldIDBridge, FxBaseChildTunnel, and Ownable contracts. This contract is deployed on Polygon PoS and is invoked by the StateBridge contract for each new root insertion. Fig. 3 illustrates the internal function StateBridge.sendRootToPolygon sending the new root to PolygonWorldID. This contract implements the following functions:
a. setRootHistoryExpiry(...) sets the amount of time it takes for a root in the root history to expire. It takes in one parameter: expiryTime, which is the new amount of time it takes for a root to expire. This function can only be called by the contract owner.
b. _processMessageFromRoot(...) is an internal override function called via a system call to receive messages from the StateBridge contract. It calls the _receiveRoot function upon receiving a message from the StateBridge contract via the FxChildTunnel.
c. The function verifyProof(...), which allows verifying semaphore proofs.
OpWorldID: Similarly to the PolygonWorldID contract, OpWorldID manages the root history of the WorldID Merkle root, but it is deployed on the Optimism chain. Its primary goal is to allow semaphore-proof verifications on the Optimism chain. As described in Fig. 2, it inherits from the WorldIDBridge and CrossDomainOwnable3 contracts and implements the IOpWorldID interface. This contract is invoked by the StateBridge contract for each new root insertion. Fig. 3 illustrates the internal function StateBridge.sendRootToOptimism sending the new root to OpWorldID. This contract implements the following functions:
a. receiveRoot(...) is called by the state bridge contract when it forwards a new root to the bridged WorldID. It sets the new root and supersedes the timestamp in the root history.
b. setRootHistoryExpiry(...) sets the expiration time for a root in the root history to expire. Only the owner of the contract can call this function.
c. The function verifyProof(...), which allows verifying semaphore proofs.
This component consists of two template contracts for WorldID users: a) WorldIDAirdrop is aimed for airdropping tokens to World ID members, and b) WorldIDMultiAirdrop manages multiple airdrops to World ID users. Fig. 4 illustrates the interactions between contracts in the sequential order to claim the airdrop in WorldIDAirdrop contract.
In this section, we present a formal proof of equivalence between implementing the Poseidon hash and a zero-knowledge circuit for it using the Lean proof assistant. Firstly, we provide a brief overview of the Poseidon hash (Section 5.1), followed by a discussion of the Lean formalization in Section 5.2.
4.3.1 An overview of Poseidon hash
31 n 31
Let Fp be a prime field where p is approximately greater than 2 , i.e., p ≈ 2 > 2 . The Poseidon hash is a function that maps strings from Fp to fixed-length strings over Fpo, where o is usually equal to 1.Implementing the Poseidon hash uses the concept of rounds, executed over the state a number of times. Each round applies an S-box function to the entire state (full rounds) or a single value, while the rest remains unchanged (half-rounds). Intuitively, each round function consists of the following three steps:
a. A step for adding constants, which sums a vector to a column of the state representation;
b. A subwords step applies an S-box function to the state. When the S-box is applied to just one state entry; we call this a half-round. Applying S-box to all state entries is named a full round.
c. A mixing step multiplies the current state by an MDS matrix.
The next Section presents more details about the Lean formalization of Poseidon hash and the proof of equivalence with a zero-knowledge circuit using the Lean proof assistant.
4.3.2 Lean formalization
Here, we present more details about the Poseidon hash implementation in Lean and proof of its equivalence with encoding a ZK-circuit as a relational specification. For each implementation component, we show its Lean implementation and its corresponding ZK-circuit together with a theorem statement establishing its correctness.
4.3.2.1 Definition of a finite field type
We start our formalization by defining a type for denoting finite fields:
def Order : N := -- some prime number
variable [Fact (Nat.Prime Order)]
abbrev F := ZMod OrderWe start by defining a constant Order for denoting the order of our finite field type. We postulate the fact that Order is a prime number and then define a type F as the type of integers modulus the prime Order.
4.3.2.2 Function sbox
The first function defined for the Poseidon implementation is sbox:
def sbox(v : F) : F := v ^ 5The function takes a field value and raises it to the 5th power. The following proposition describes the circuit definition for this function:
def sboxConstraint (v : F)(res : F) : Prop :=∃ v2 v4, v2 = v * v ∧ v4 = v2 * v2 ∧ res = v * v4
Finally, we can say that sbox function is sound by stating the following theorem:
theorem sboxSound (v res : F) : sboxConstraint v res ↔ sbox v = resThe theorem ensures that sbox result agrees with the circuit defined by sboxConstraint.
4.3.2.3 Function applyMDS
The next function definition is applyMDS, which multiplies the current state by an MDS matrix. Its implementation uses Lean Mathlib’s matrix multiplication operation.
def applyMDS {n : N} (state : Matrix (Fin (n + 1)) Unit F)
(mds : Matrix (Fin (n + 1)) (Fin (n + 1)) F) : Matrix (Fin (n + 1)) Unit F
:= Matrix.mul mds stateThe circuit for expressing matrix multiplication is defined by quantifying all possible rows of the output as follows:
def applyMDSConstraint{n : N}
(mds : Matrix (Fin (n + 1)) (Fin (n + 1)) F)
(state : Matrix (Fin (n + 1)) Unit F)
(res : Matrix (Fin (n + 1)) Unit F) : Prop :=The soundness theorem for the function applyMDS ensures that the function’s result agrees with the circuit implementation:
theorem applyMDSSound {n : N} (mds : Matrix (Fin (n + 1)) (Fin (n + 1)) F)
(state : Matrix (Fin (n + 1)) Unit F)
(res : Matrix (Fin (n + 1)) Unit F) :
applyMDSConstraint mds state res ↔ applyMDS state mds = resThe Lean proof script for this theorem can be found here.
4.3.2.4 Function half-round
The definition of the function half-round takes the current state, the MDS matrix, the index of the column that should be used by the actual round, the matrix of constants, and it performs the following steps:
sbox function to the first entry of the new state value;def halfRound {n : N}(mds : Matrix (Fin (n + 1)) (Fin (n + 1)) F)
(pround : Fin (n + 1))
(constants : Matrix (Fin (n + 1)) (Fin (n + 1)) F)
(state : Matrix (Fin (n + 1)) Unit F)
: Matrix (Fin (n + 1)) Unit F :=
let constm := col (constants pround)
let state' := state + constm
let state'' : Matrix (Fin (n + 1)) Unit F := updateEntry state'
applyMDS state'' mdsThe relational definition of the ZK-circuit for half-round is:
def halfRoundConstraint {n : N}(mds : Matrix (Fin (n + 1)) (Fin (n + 1)) F)
(pround : Fin (n + 1))
(constants : Matrix (Fin (n + 1)) (Fin (n + 1)) F)
(state : Matrix (Fin (n + 1)) Unit F)
(res : Matrix (Fin (n + 1)) Unit F) : Prop :=∃ res1 res2, sumGadget state (col (constants pround)) res1 ∧ updateEntryConstraint res1 res2 ∧ applyMDSConstraint mds res2 res
it uses the sumGadget, the constraint representation for the sum of two vectors. The definition of the sumGadget constraint can be found here. The soundness theorem for the function half-round ensures that the function’s result agrees with its circuit implementation:
theorem halfRoundSound {n : N}(mds : Matrix (Fin (n + 1)) (Fin (n + 1)) F)
(pround : Fin (n + 1))
(constants : Matrix (Fin (n + 1)) (Fin (n + 1)) F)
(state : Matrix (Fin (n + 1)) Unit F)
(res : Matrix (Fin (n + 1)) Unit F) :
halfRoundConstraint mds pround constants state res ↔ halfRound mds pround constants state = resThe complete Lean proof script for the soundness theorem can be found online here.
4.3.2.5 Function full-round
The definition of the function full-round takes the current state, the MDS matrix, the index of the column that should be used by the actual round, and the matrix of constants, and it performs the following steps:
sbox function all entries of the current state;def fullRound {n : N} (mds : Matrix (Fin (n + 1)) (Fin (n + 1)) F)
(fround : Fin (n + 1))
(constants : Matrix (Fin (n + 1)) (Fin (n + 1)) F)
(state : Matrix (Fin (n + 1)) Unit F)
: Matrix (Fin (n + 1)) Unit F :=
let constm := col (constants fround)
let state' := state + constm
let state'' := Matrix.map state' sbox
applyMDS state'' mdsThe relational definition of the ZK-circuit for full-round is:
def fullRoundConstraint {n : N} (mds : Matrix (Fin (n + 1)) (Fin (n + 1)) F)
(pround : Fin (n + 1))
(constants : Matrix (Fin (n + 1)) (Fin (n + 1)) F)
(state : Matrix (Fin (n + 1)) Unit F)
(res : Matrix (Fin (n + 1)) Unit F) : Prop :=∃ res1, sumGadget state (col (constants pround)) res1 ∧ ∃ res2, (∀ i, sboxConstraint (res1 i unit) (res2 i unit)) ∧ applyMDSConstraint mds res2 res
The soundness theorem for the function full-round ensures that the function’s result agrees with its circuit implementation:
theorem fullRoundSound {n : N} (mds : Matrix (Fin (n + 1)) (Fin (n + 1)) F)
(pround : Fin (n + 1))
(constants : Matrix (Fin (n + 1)) (Fin (n + 1)) F)
(state : Matrix (Fin (n + 1)) Unit F)
(res : Matrix (Fin (n + 1)) Unit F) :
fullRoundConstraint mds pround constants state res ↔ fullRound mds pround constants state = resThe complete Lean proof script for the soundness theorem can be found online here.
4.3.2.6 Function poseidonIter
The function poseidonIter implements the core functionality of the Poseidon hashing by iterating nTotal times over the state. Based on the current iteration, the algorithm decides if it should apply a half or full round to the current state. After nTotal iterations the function poseidonIter returns the resulting state matrix.
def poseidonIter {n : N}(mds : Matrix (Fin (n + 1)) (Fin (n + 1)) F) (nTotal nFull : N)
(constants : Matrix (Fin (n + 1)) (Fin (n + 1)) F)
(state : Matrix (Fin (n + 1)) Unit F): ∀ (i : N), Matrix (Fin (n + 1)) Unit F := | i =>
if h : i < nTotal + 1 then
let state' := if i < nFull || i < (nTotal - nFull) then
fullRound mds i constants state
else halfRound mds i constants state
poseidonIter mds nTotal nFull constants state' (i + 1)
else state
termination_by poseidonIter mds nTotal nFull constants state i => nTotal + 1 - i
decreasing_by {apply minus_lt ; exact h}The clauses termination_by and decreasing_by are used by the Lean equation compiler to guarantee the poseidonIter does terminate. The ZK-circuit for poseidonIter is defined as:
def poseidonIterConstraint {n : N}(mds : Matrix (Fin (n + 1)) (Fin (n + 1)) F) (nTotal nFull : N)
(constants : Matrix (Fin (n + 1)) (Fin (n + 1)) F) :
Matrix (Fin (n + 1)) Unit F →Matrix (Fin (n + 1)) Unit F → N → Prop :=
| state res i =>
if h : i < nTotal + 1 then
if i < nFull ∨ i < (nTotal - nFull) then∃ res1, fullRoundConstraint mds i constants state res1 ∧ poseidonIterConstraint mds nTotal nFull constants res1 res (i + 1)
else
∃ res1, halfRoundConstraint mds i constants state res1 ∧ poseidonIterConstraint mds nTotal nFull constants res1 res (i + 1)
else res = state
termination_by poseidonIterConstraint _ nTotal _ _ _ _ i => nTotal + 1 - i
decreasing_by {apply minus_lt ; exact h}The soundness proof for poseidonIterConstraint ensures that the functions result agrees with its circuit implementation:
theorem poseidonIterSound {n : N}
(mds : Matrix (Fin (n + 1)) (Fin (n + 1)) F)(nTotal nFull : N)
(constants : Matrix (Fin (n + 1)) (Fin (n + 1)) F) :
∀ state res i,
poseidonIterConstraint mds nTotal nFull constants state res i ↔
poseidonIter mds nTotal nFull constants state i = res :=The complete proof script for poseidonIterSound can be found at here.
4.3.2.7 Function poseidon
The function poseidon implements the hashing algorithm by getting the updated state by poseidonIter and returns the first entry of the resulting matrix.
def poseidon {n : N}(mds : Matrix (Fin (n + 1)) (Fin (n + 1)) F) (nTotal nFull : N)
(constants : Matrix (Fin (n + 1)) (Fin (n + 1)) F)
(state : Matrix (Fin (n + 1)) Unit F) : F :=
let state' := poseidonIter mds nTotal nFull constants state 0
state' 0 unitThe relational definition of the ZK-circuit for poseidon is:
def poseidonConstraint{n : N}
(mds : Matrix (Fin (n + 1)) (Fin (n + 1)) F)(nTotal nFull : N)
(constants : Matrix (Fin (n + 1)) (Fin (n + 1)) F)
(state : Matrix (Fin (n + 1)) Unit F)(res : F) : Prop :=∃ res1, poseidonIterConstraint mds nTotal nFull constants state res1 0 ∧ res = res1 0 unit
The soundness theorem for the function poseidon ensures that the function’s result agrees with its circuit implementation:
theorem poseidonSound{n : N}
(mds : Matrix (Fin (n + 1)) (Fin (n + 1)) F)(nTotal nFull : N)
(constants : Matrix (Fin (n + 1)) (Fin (n + 1)) F)
(state : Matrix (Fin (n + 1)) Unit F)
(res : F) :
poseidonConstraint mds nTotal nFull constants state res ↔
poseidon mds nTotal nFull constants state = resThe complete Lean proof script for the soundness theorem for poseidon can be found online here.
4.3.3 Final Remarks
We presented an abstract formal specification for the Poseidon hash function as ZK-circuits using the Lean proof assistant. The formalization is composed of three main components: 1) a specification of the Poseidon hash algorithm as Lean functions; 2) the implementation of Poseidon hash as ZK-circuits implemented as Lean propositions over prime fields and 3) proofs ensuring the soundness of the circuit representations with respect to the Poseidon hash specification. The complete Lean formalization is available at https://github.com/NethermindEth/WorldCoin-poseidon-verification.
The risk rating methodology used by Nethermind Security follows the principles established by the OWASP Foundation. The severity of each finding is determined by two factors: Likelihood and Impact.
Likelihood measures how likely the finding is to be uncovered and exploited by an attacker. This factor will be one of the following values:
When defining the likelihood of a finding, other factors are also considered. These can include but are not limited to motive, opportunity, exploit accessibility, ease of discovery, and ease of exploit.
Impact is a measure of the damage that may be caused if an attacker exploits the finding. This factor will be one of the following values:
When defining the impact of a finding, other factors are also considered. These can include but are not limited to data and state integrity, loss of availability, financial loss, and reputation damage. After defining the likelihood and impact of an issue, the severity is determined according to the table below.
| Impact / Likelihood | Low | Medium | High |
| High | Medium | High | Critical |
| Medium | Low | Medium | High |
| Low | Info / Best Practices | Low | Medium |
| Undetermined | Undetermined | Undetermined | Undetermined |
To address issues that do not fit a High, Medium or Low severity, Nethermind Security also uses three more finding severities: Informational, Best Practices, and Undetermined.
WorldIDMultiAirdrop contract| File | Fix commit | Type | Status |
WorldIDMultiAirdrop.sol | PR #38 | Critical | Fixed |
The WorldIDMultiAidrop contract allows any user to create a new airdrop by calling the createAirdrop(...) function:
function createAirdrop(uint256 groupId, ERC20 token, address holder, uint256 amount) public {
Airdrop memory airdrop = Airdrop({
groupId: groupId,
token: token,
manager: msg.sender,
/////////////////////////////////////////////////////////////////////////////
// @audit "holder" argument can be any address
/////////////////////////////////////////////////////////////////////////////
holder: holder,
amount: amount
});
getAirdrop[nextAirdropId] = airdrop;
emit AirdropCreated(nextAirdropId, airdrop);
++nextAirdropId;
}To create an airdrop, the creator needs to provide four parameters:
groupId: The WorldID group containing all eligible recipients for the airdrop;token: The asset to be airdropped;holder: The account holding the funds to be airdropped. This account must approve sufficient funds for the WorldIDMultiAirdrop;amount: The amount sent to each user claiming the airdrop;When a user claims their reward for a specific airdrop, they provide the airdrop’s id and data proving their membership in the eligible group. If the proof is valid, the WorldIDMultiAirdrop contract transfers the reward from the airdrop’s holder to the receiver.
worldIdRouter.verifyProof(
root,
airdrop.groupId,
abi.encodePacked(receiver).hashToField(),
nullifierHash,
abi.encodePacked(address(this), airdropId).hashToField(),
proof
);
nullifierHashes[nullifierHash] = true;
emit AirdropClaimed(airdropId, receiver);
/////////////////////////////////////////////////////////////////////////////
// @audit - Assets are sent from the "holder" to the "receiver" parameter
/////////////////////////////////////////////////////////////////////////////
SafeTransferLib.safeTransferFrom(airdrop.token, airdrop.holder, receiver, airdrop.amount);As there are no restrictions on the holder parameter during airdrop creation, a malicious user can create a new airdrop using any address that has granted an allowance to the WorldIDMultiAirdrop contract as the holder. The attacker can then claim the airdrop, effectively stealing assets from the holder’s account.
Recommendation
Create separate contracts for each airdrop to ensure that the holder only grants allowance to the specific airdrop.
Resolution
We decided that we won’t use WorldIDMultiAirdrop.sol in production anymore and we have deleted the contract from the repo. Fixed in commit world-id-example-airdrop@b830bf8.
WorldIdBridge| File | Fix commit | Type | Status |
WorldIDBridge.sol | 5a340f6PR #50 | Critical | Fixed |
The WorldIdBridge.verifyProof(...) function enables verification of the proof provider’s group membership. As groups are subject to change over time, the validity of roots endures for some time after their replacement. To verify the validity of a given root at the present time, the checkValidRoot(...) function is employed. This function is intended to return true for valid roots and to revert for invalid ones. The function with audit comments is reproduced below.
function checkValidRoot(...) public view returns (bool isValid) {
if (root == _latestRoot) {
return true;
}
uint128 rootTimestamp = rootHistory[root];
if (block.timestamp - rootTimestamp > ROOT_HISTORY_EXPIRY) {
revert ExpiredRoot();
}
if (rootTimestamp == 0) {
revert NonExistentRoot();
}
////////////////////////////////////////////////////
// @audit When the old block is still valid
// the value of `isValid` is false
////////////////////////////////////////////////////
}The function verifyProof(...) is expected to revert when invalid proofs are provided. The function is shown in the next code snippet.
function verifyProof(...) public view virtual onlyProxy onlyInitialized {
/////////////////////////////////////////////
// @audit when `checkValidRoot` returns false
// the proof is not verified by
// `semaphoreVerifier`
/////////////////////////////////////////////
if (checkValidRoot(root)) {
semaphoreVerifier.verifyProof( root, nullifierHash, signalHash, externalNullifierHash, proof, treeDepth );
}
}Nevertheless, it is evident from the aforementioned code that the checkValidRoot(...) function produces a false return value for older, albeit still valid, roots, which is an erroneous outcome. This particular flaw carries a greater risk, given that the verifyProof(...) function does not execute the verifyProof(...) function from the semaphore contract in instances where the outcome of checkValidRoot(...) is false. As a result, verifyProof(...) will not revert even in the case of an invalid proof, which may enable an attacker to submit invalid proofs as valid when an old root remains valid.
Recommendation
Add the return statement in the checkValidRoot(...) function with the proper value when the root is still valid.
Resolution
Fixed in commits world-id-state-bridge@5a340f6, world-id-state-bridge@1ad9dc2
| File | Fix commit | Type | Status |
| — | dd7b7f6 | Medium | Mitigated |
The reviewed contracts contain multiple sensitive actions that can only be executed by accounts with special roles. These actions include:
These actions could render the system unusable or damage its users. In the event of private key leaks or similar incidents, malicious actors could easily harm the protocol and its users.
Recommendation
To mitigate this issue, consider implementing the following measures:
Resolution
Fixed in commit world-id-contracts@dd7b7f6.
PolygonWorldID sender and receiver can be set by any address| File | Fix commit | Type | Status |
PolygonWorldID.solStateBridge.sol | 5310dfa | Medium | Fixed |
The PolygonWorldID contract is responsible for managing the root history of the WorldID Merkle root on Polygon PoS. Each new root insertion is called by StateBridge (L1). The mechanism that is used for sending the state from Ethereum to Polygon PoS consists of two actors: Child and Root. The PolygonWorldID is the Child since it’s a message receiver, and the StateBridge is a Root that sends a state. Both contracts inherit Child and Root functionality from FxBaseChildTunnel and FxBaseRootTunnel, respectively. The issue is that functions for setting Child address in Root contract, and Root address in Child contract are public/ external. This creates a situation where a transaction for setting the Child and the Root may be front-run by an adversarial actor. Below we present those functions:
FxBaseChildTunnel.setFxRootTunnel(...)
function setFxRootTunnel(address _fxRootTunnel) external virtual {
require(fxRootTunnel == address(0x0), "FxBaseChildTunnel: ROOT_TUNNEL_ALREADY_SET");
fxRootTunnel = _fxRootTunnel;
}FxBaseRootTunnel.setFxChildTunnel(...)
function setFxChildTunnel(address _fxChildTunnel) public virtual {
require(fxChildTunnel == address(0x0), "FxBaseRootTunnel: CHILD_TUNNEL_ALREADY_SET");
fxChildTunnel = _fxChildTunnel;
}Recommendation
There are at least two approaches for solving this issue: a) set the Child/Root address in the constructor when deploying contracts. Addresses of deployed contracts can be known upfront; b) overwrite the setting functions and add the onlyOwner modifier to prevent front-running the call.
Resolution
Fixed in commit world-id-state-bridge@5310dfa.
ROOT_HISTORY_EXPIRY update mechanism in StateBridge contract| File | Fix commit | Type | Status |
OpWorldID.sol | ee74770 | Low | Fixed |
The OpWorldID contract uses the onlyOwner modifier for the functions receiveRoot(...) and setRootHistoryExpiry(...), as illustrated below.
contract OpWorldID is WorldIDBridge, CrossDomainOwnable3, IOpWorldID {
...
function receiveRoot(...) external virtual onlyOwner {
_receiveRoot(newRoot, supersedeTimestamp);
}
////////////////////////////////////////////////////////////////
// @audit Only the StateBridge contract can call this function
////////////////////////////////////////////////////////////////
function setRootHistoryExpiry(...) public virtual override onlyOwner {
_setRootHistoryExpiry(expiryTime);
}
}The receiveRoot(...) function is called by the StateBridge contract (the owner) to forward the latest root to the bridged WorldID. In contrast, setRootHistoryExpiry(...) updates the expiration time for a root. However, the StateBridge contract does not have a function for calling setRootHistoryExpiry(...) to update the expiration time. To invoke this function, the owner of StateBridge must transfer ownership of OpWorldID to another contract or to a local Optimism EOA.
Recommendation
Add an external function in the StateBridge contract that can only be called by the owner to invoke OpWorldID.setRootHistoryExpiry(...).
Resolution
Fixed in commit world-id-state-bridge@ee74770.
| File | Fix commit | Type | Status |
WorldIDImpl.sol | c8a10af | Low | Fixed |
The contract WorldIDImpl is derived from OpenZeppelin’s OwnableUpgradeable contract, which furnishes a single-step ownership transfer. The transferOwnership(...) function facilitates the transfer of ownership of the contract in one step. However, if the contract’s owner is assigned to an address that is not managed by the Worldcoin team, reclamation of ownership of the contract will not be feasible.
Failing to use such a mechanism can introduce several issues. If the ownership transfer is not properly controlled and executed, it can create security vulnerabilities in the contract. Without proper access control, a malicious actor could gain control of the contract and perform unauthorized actions.
Changing ownership without proper access controls and protocols can lead to a lack of transparency and accountability in the transfer process. This can harm the trust and credibility of the contract and its stakeholders.
Recommendation
Consider implementing a two-step process for transferring ownership, such as the propose-accept scheme. Check the Ownable2StepUpgradeable.sol contract from OpenZeppelin.
Resolution
Fixed in commit world-id-contracts@c8a10af.
NonExistentRoot() may not be executed for nonexistent roots| File | Fix commit | Type | Status |
WorldIDBridge.solWorldIDIdentityManagerImplV1.sol | — | Low | Fixed |
The function checkValidRoot(...) checks if a given root value is valid. When the root is not the latest, the next if statement is executed. In case the root does not exist, the rootTimestamp value is zero, and the function reverts with the error ExpiredRoot(), and the condition if (rootTimestamp == 0) will not be reached.
function checkValidRoot(uint256 root) public view returns (bool isValid) {
if (root == _latestRoot) {
return true;
}
uint128 rootTimestamp = rootHistory[root];
if (block.timestamp - rootTimestamp > ROOT_HISTORY_EXPIRY) {
revert ExpiredRoot();
}
////////////////////////////////////////////////////////////////////
// @audit The "if" condition below may not be reached when
// "block.timestamp > ROOT_HISTORY_EXPIRY" and rootTimestamp = 0
////////////////////////////////////////////////////////////////////
if (rootTimestamp == 0) {
revert NonExistentRoot();
}
}Recommendation
Switch the order of the if statements as shown below.
-// Expired roots are not valid.
-if (block.timestamp - rootTimestamp > ROOT_HISTORY_EXPIRY) {
- revert ExpiredRoot();
-}
-
-// And roots do not exist if they don't have an associated timestamp.
-if (rootTimestamp == 0) {
- revert NonExistentRoot();
-}
+ // And roots do not exist if they don't have an associated timestamp.
+ if (rootTimestamp == 0) {
+ revert NonExistentRoot();
+ }
+ // Expired roots are not valid.
+ if (block.timestamp - rootTimestamp > ROOT_HISTORY_EXPIRY) {
+ revert ExpiredRoot();
+ }Resolution
Fixed in commits world-id-contracts@95691df, world-id-state-bridge@5a340f6.
actionId is hashed two times in WorldIDAirdrop contract| File | Fix commit | Type | Status |
WorldIDAirdrop.sol | f7b0cee | Low | Fixed |
The WorldIDAirdrop constructor requires several parameters, as outlined below.
constructor(IWorldIDGroups _worldIdRouter, uint256 _groupId, string memory _actionId,
ERC20 _token, address _holder, uint256 _airdropAmount) {
worldIdRouter = _worldIdRouter;
groupId = _groupId;
actionId = abi.encodePacked(_actionId).hashToField();
token = _token;
holder = _holder;
airdropAmount = _airdropAmount;
}The constructor accepts the _actionId as registered in the developer portal, creates a keccak256 hash of it, and stores the hash in the actionId state variable. When a user claims their reward, they provide the data proving their membership in the group, as demonstrated in the function below.
function claim(address receiver, uint256 root, uint256 nullifierHash, uint256[8] calldata proof) public
{
if (nullifierHashes[nullifierHash]) revert InvalidNullifier();
worldIdRouter.verifyProof(
groupId,
root,
abi.encodePacked(receiver).hashToField(), // The signal of the proof
nullifierHash,
//////////////////////////////////////////////////////////////
// @audit the "actionId""" is already hashed
// in the constructor
//////////////////////////////////////////////////////////////
abi.encodePacked(actionId).hashToField(), // The external nullifier hash
proof
);
...
}However, the claim(...) function hashes the already hashed actionId once more. If the proof is not generated for the double-hashed actionId, the worldIdRouter.verifyProof will revert.
Recommendation
Remove the double hashing.
function claim(address receiver, uint256 root, uint256 nullifierHash, uint256[8] calldata proof) public
{
if (nullifierHashes[nullifierHash]) revert InvalidNullifier();
worldIdRouter.verifyProof(
groupId,
root,
abi.encodePacked(receiver).hashToField(), // The signal of the proof
nullifierHash,
////////////////////////////////////////
// @audit the actionId is already hashed
// in the constructor
///////////////////////////////////////
- abi.encodePacked(actionId).hashToField(), // The external nullifier hash
+ actionId, // The external nullifier hash
proof
);
...
}Resolution
Fixed in commit world-id-example-airdrop@f7b0cee.
ActionID may not be unique across applications| File | Fix commit | Type | Status |
| — | — | Info | Acknowledged |
When verifying a claim through WorldIDGroups, a user must provide six elements:
groupId: A group to which the user belongs;root: The root of the Merkle tree containing all identities in the group;signalHash: The hash of a message the user commits to;nullifierHash: An identifier for the proof, derived from the user’s identity and ActionId;externalNullifierHash: The ActionId represents the user’s desired action;proof: Eight values used to validate the provided arguments;Provided all the values are correct, the caller proves that:
groupId;ActionId/ExternalNullifierHash;signalHash for their action;Although WorldIDGroup does not prevent reusing proofs, applications built on top of it can do so using the nullifierHash. Allowing a specific nullifierHash to be used only once means each user can execute the action identified by externalNullifierHash only once.
However, since this check is performed in each application, proofs can still be reused across different applications. This can be mitigated by using unique ActionIDs for each application. The WorldCoin team recommends building ActionIDs using the application address as a prefix, but there are no restrictions preventing a malicious user from using the same ActionIDs as other applications.
An attacker could create a phishing application and incentivize users to submit proofs to it, then reuse these proofs in other applications using WorldID. The severity and likelihood of this attack vary across applications.
Recommendation
In order to mitigate this issue, we recommend doing the following:
WorldID to follow a well-defined standard for creating ActionIds. The ActionIds should include identifiers unique to the application and easily verifiable by users, such as the address of the contract;ActionIds. For example, in addition to the ActionId, display the values used to generate it, which could include application identifiers such as the address;ActionIds they are signaling when submitting proofs;Resolution
Working on documentation to explain how this will be/is handled.
| File | Fix commit | Type | Status |
PolygonWorldID.sol | 25e6d85 | Info | Fixed |
The constructor of the PolygonWorldID contract checks and sets the tree depth, as we can see in the code below.
contract PolygonWorldID is WorldIDBridge, FxBaseChildTunnel, Ownable {
constructor(uint8 _treeDepth, address _fxChild)
WorldIDBridge(_treeDepth)
FxBaseChildTunnel(_fxChild)
{
if (!SemaphoreTreeDepthValidator.validate(_treeDepth)) {
revert UnsupportedTreeDepth(_treeDepth);
}
///////////////////////////////////
// @audit tree depth is set here //
///////////////////////////////////
treeDepth = _treeDepth;
}However, the identical process occurs within the WorldIDBridge contract, from which the PolygonWorldID contract inherits. This results in a superfluous assignment of the tree depth.
abstract contract WorldIDBridge is IWorldID {
...
constructor(uint8 _treeDepth) {
if (!SemaphoreTreeDepthValidator.validate(_treeDepth)) {
revert UnsupportedTreeDepth(_treeDepth);
}
////////////////////////////////////////
// @audit tree depth is also set here //
////////////////////////////////////////
treeDepth = _treeDepth;
}
}Recommendation
Avoid redundant operations.
Resolution
Fixed in commit world-id-state-bridge@25e6d85.
| File | Fix commit | Type | Status |
WorldIDRouterImplV1.sol | PR #100 | Info | Fixed |
The WorldIDRouter contract utilizes an array as a routingTable, which stores all registered groups and identifies them by their index in the array. The array is initialized with a length of DEFAULT_ROUTING_TABLE_SIZE. When a new group is added, and the current number of elements in the routingTable equals its size, a new array is created in memory with a length equal to the current size plus DEFAULT_ROUTING_TABLE_GROWTH. The newly created array is then copied element by element to the storage.
function insertNewTableEntry(uint256 groupId, address targetAddress)
internal
onlyProxy
onlyInitialized
{
while (groupId >= routingTable.length) {
uint256 existingTableLength = routingTable.length;
address[] memory newRoutingTable =
new address[](existingTableLength + DEFAULT_ROUTING_TABLE_GROWTH);
for (uint256 i = 0; i < existingTableLength; ++i) {
newRoutingTable[i] = routingTable[i];
}
// @audit - This operation overwrites storage values, causing
// unnecessary gas consumption.
routingTable = newRoutingTable;
}
routingTable[groupId] = targetAddress;
_groupCount++;
}This operation overwrites existing storage values with the same values, leading to unnecessary gas consumption.
Recommendation
Consider removing reallocation logic and using the push method for storage arrays instead.
- /// The default size of the internal routing table.
- uint256 internal constant DEFAULT_ROUTING_TABLE_SIZE = 10;
- /// How much the routing table grows when it runs out of space.
- uint256 internal constant DEFAULT_ROUTING_TABLE_GROWTH = 5;
/// The null address.
address internal constant NULL_ADDRESS = address(0x0);
/// The routing table is used to dispatch from groups to addresses.
address[] internal routingTable;
- /// The number of groups currently set in the routing table.
- uint256 internal _groupCount;
function initialize(address initialGroupIdentityManager) public reinitializer(1) {
// Initialize the sub-contracts.
__delegateInit();
// Now we can perform our own internal initialisation.
- routingTable = new address[](DEFAULT_ROUTING_TABLE_SIZE);
- routingTable[0] = initialGroupIdentityManager;
- _groupCount = 1;
+ routingTable.push(initialGroupIdentityManager);
// Mark the contract as initialized.
__setInitialized();
}
function groupCount() public view onlyProxy onlyInitialized returns (uint256 count) {
- return _groupCount;
+ return routingTable.length;
}
function insertNewTableEntry(uint256 groupId, address targetAddress)
internal
onlyProxy
onlyInitialized
{
- while (groupId >= routingTable.length) {
- uint256 existingTableLength = routingTable.length;
- address[] memory newRoutingTable =
- new address[](existingTableLength + DEFAULT_ROUTING_TABLE_GROWTH);
-
- for (uint256 i = 0; i < existingTableLength; ++i) {
- newRoutingTable[i] = routingTable[i];
- }
-
- routingTable = newRoutingTable;
- }
-
- routingTable[groupId] = targetAddress;
- _groupCount++;
+ routingTable.push(targetAddress);
}
function nextGroupId() public view onlyProxy onlyInitialized returns (uint256 count) {
- return _groupCount;
+ return routingTable.length;
}Resolution
Fixed in commits world-id-contracts@95691df, world-id-contracts@38a5d1c.
| File | Fix commit | Type | Status |
WorldIDIdentityManagerImplV1.solWorldIDRouterImplV1.solWorldIDBridge.solWorldIDAirdrop.sol | 5f0f56cPR #50 PR #38 PR #100 | Best Practices | Fixed |
Several relevant operations in the contracts do not emit events, making it difficult to monitor and review the contracts’ behavior once deployed.
Operations that would benefit from emitting events include:
- WorldIDIdentityManagerImplV1.initialize(...)
- WorldIDIdentityManagerImplV1.registerIdentities(...)
- WorldIDIdentityManagerImplV1.updateIdentities(...)
- WorldIDIdentityManagerImplV1.setStateBridge(...)
- WorldIDIdentityManagerImplV1.setSemaphoreVerifier(...)
- WorldIDIdentityManagerImplV1.setRootHistoryExpiry(...)
- WorldIDRouterImplV1.initialize(...)
- WorldIDRouterImplV1.addGroup(...)
- WorldIDRouterImplV1.updateGroup(...)
- WorldIDBridge._setRootHistoryExpiry(...)
- WorldIDAirdrop.claim(...)Emitting events for the relevant operations will enable users and blockchain monitoring systems to easily detect suspicious behaviors and ensure the correct functioning of the contracts.
Recommendation
Add events for all relevant operations to facilitate contract monitoring and detect suspicious behavior more effectively.
Resolution
Fixed in commits world-id-contracts@5f0f56c, world-id-state-bridge@aab1ea1, world-id-example-airdrop@f7d60fe, world-id-contracts@d29d6a9.
| File | Fix commit | Type | Status |
WorldIDRouterImplV1.sol | 95691df | Best Practices | Fixed |
The verifyProof(...) function, present within the WorldIDRouter contract, retrieves the appropriate IdentityManager for the indicated group and invokes the verifyProof(...) function of that IdentityManager. This call to the IdentityManager is accomplished by employing the following code.
bytes memory callData = abi.encodeCall(
IWorldID.verifyProof, (root, signalHash, nullifierHash, externalNullifierHash, proof)
);
(bool success,) = identityManager.call(callData);
if (!success) {
revert FailedToVerifyProof();
}As demonstrated in the code excerpt provided, a low-level call instruction is utilized. Utilizing low-level calls is not advisable as they do not ordinarily implement security precautions. For instance, in this particular scenario, if the address pointed to by identityManager lacks any code, this function will succeed when it should actually revert.
Recommendation
Avoid using low-level calls. Use IWorldID as the type of identityManager.
Resolution
Fixed in commit world-id-contracts@95691df.
| File | Fix commit | Type | Status |
WorldIDRouterImplV1.sol | 95691dfPR #100 | Best Practices | Fixed |
The optimal practices for implementing contracts are defined at the commencement of WorldIDRouterImplV1 contract. Nevertheless, the advice to make all non-private functions virtual has not been strictly adhered to, as there exist non-private functions that lack virtual property. This might result in an inability to update these functions if a new implementation were to inherit from the present one.
Recommendation
Define non-private functions as virtual in implementation contracts.
Resolution
Fixed in commits world-id-contracts@95691df, world-id-contracts@5034fec.
| File | Fix commit | Type | Status |
StateBridge.solWorldIDBridge.sol | 93fc506PR #50 PR #100 | Best Practices | Fixed |
The presence of unused variables is generally considered a practice to be avoided, as they may lead to potential issues such as:
The state variable worldID in the StateBridge contract is only set in the constructor and is not used throughout the contract.
contract StateBridge is FxBaseRootTunnel, Ownable {
...
// @audit unused state variable
IWorldIDIdentityManager internal worldID;
...
}Another example of an unused variable is present in the WorldIDBridge contract, declared in the function checkValidRoot(...). The function contains the local variable isValid, which is never assigned a value, so it assumes its initialization value. When the if condition is not satisfied, false will always be returned without any warning of the forgotten statement return.
abstract contract WorldIDBridge is IWorldID {
...
function checkValidRoot(uint256 root) public view returns (bool isValid) {
// @audit a value is never assigned to isValid
if (root == _latestRoot) {
return true;
}
uint128 rootTimestamp = rootHistory[root];
// Expired roots are not valid.
if (block.timestamp - rootTimestamp > ROOT_HISTORY_EXPIRY) {
revert ExpiredRoot();
}
// And roots do not exist if they don't have an associated timestamp.
if (rootTimestamp == 0) {
revert NonExistentRoot();
}
}
...
}List of unused local variables in return statements:
- WorldIDRouterImplV1
- function routeFor(...)
- WorldIDBridge
- function checkValidRoot
- function latestRoot()
- function rootHistoryExpiry()
- function getTreeDepth()
- WorldIDIdentityManagerImplV1
- function queryRoot(...)
- function latestRoot() stateBridge()
- function isInputInReducedForm(...)
- function reduceInputElementInSnarkScalarField(...)
- function getRegisterIdentitiesVerifierLookupTableAddress()
- function getIdentityUpdateVerifierLookupTableAddress()
- function getSemaphoreVerifierAddress()
- function getRootHistoryExpiry()
- function getTreeDepth()Unused state variable:
StateBridge
- IWorldIDIdentityManager internal worldIDRecommendation
We recommend removing all unused variables from the codebase to enhance code quality and minimize the risk of unexpected errors or inefficiencies.
Resolution
Fixed in commits world-id-state-bridge@93fc506, world-id-state-bridge@1f8366c, world-id-contracts@275e2aa.
Software documentation refers to the written or visual information that describes the functionality, architecture, design, and implementation of software. It provides a comprehensive overview of the software system and helps users, developers, and stakeholders understand how the software works, how to use it, and how to maintain it. Software documentation can take different forms, such as user manuals, system manuals, technical specifications, requirements documents, design documents, and code comments. Software documentation is critical in software development, enabling effective communication between developers, testers, users, and other stakeholders. It helps to ensure that everyone involved in the development process has a shared understanding of the software system and its functionality. Moreover, software documentation can improve software maintenance by providing a clear and complete understanding of the software system, making it easier for developers to maintain, modify, and update the software over time. Smart contracts can use various types of software documentation. Some of the most common types include:
These types of documentation are essential for smart contract development and maintenance. They help ensure that the contract is properly designed, implemented, and tested, and they provide a reference for developers who need to modify or maintain the contract in the future.
To assist the audit process, the World ID team provided Unit Tests, Worldcoin docs on the Github repository, and extensive documentation available here. The documentation embraces detailed specifications for the contracts under auditing, e.g., how World ID proofs are verified on-chain and how they use Zero-Knowledge proofs. Notably, their code is rich in inline comments, significantly contributing to understanding the implementation and functionality.
In addition to the official documentation, we also rely on documentation for:
The documentation provided by the WorldCoin team and the additional sources we utilized enabled us to thoroughly cover the terms used in the source code, core business logic, and function flow. Reviewing the entire documentation suite, we comprehensively understood how the contracts should function. The provided documentation is well-written and structured, making it an excellent resource for developers and auditors. The codebase contains an adequate number of inline comments and well-named functions and variables, which greatly assisted the audit team in understanding the function flow and identifying any potential issues.
The relevant output is presented below.
The relevant output is presented below.
The relevant output is presented below.
| 181Tests passed | 0Failed |
The complete test output is in the full report.
As auditors, we recommend that any changes or updates made to the audited codebase undergo a re-audit or security review to address potential vulnerabilities or risks introduced by the modifications. By conducting a re-audit or security review of the modified codebase, you can significantly enhance the overall security of your system and reduce the likelihood of exploitation. However, we do not possess the authority or right to impose obligations or restrictions on our clients regarding codebase updates, modifications, or subsequent audits. Accordingly, the decision to seek a re-audit or security review lies solely with you.
This report is based on the scope of materials and documentation provided by you to Nethermind in order that Nethermind could conduct the security review outlined in 1. Executive Summary and 2. Audited Files. The results set out in this report may not be complete nor inclusive of all vulnerabilities. Nethermind has provided the review and this report on an as-is, where-is, and as-available basis. You agree that your access and/or use, including but not limited to any associated services, products, protocols, platforms, content, and materials, will be at your sole risk. Blockchain technology remains under development and is subject to unknown risks and flaws. The review does not extend to the compiler layer, or any other areas beyond the programming language, or other programming aspects that could present security risks. This report does not indicate the endorsement of any particular project or team, nor guarantee its security. No third party should rely on this report in any way, including for the purpose of making any decisions to buy or sell a product, service or any other asset. To the fullest extent permitted by law, Nethermind disclaims any liability in connection with this report, its content, and any related services and products and your use thereof, including, without limitation, the implied warranties of merchantability, fitness for a particular purpose, and non-infringement. Nethermind does not warrant, endorse, guarantee, or assume responsibility for any product or service advertised or offered by a third party through the product, any open source or third-party software, code, libraries, materials, or information linked to, called by, referenced by or accessible through the report, its content, and the related services and products, any hyperlinked websites, any websites or mobile applications appearing on any advertising, and Nethermind will not be a party to or in any way be responsible for monitoring any transaction between you and any third-party providers of products or services. As with the purchase or use of a product or service through any medium or in any environment, you should use your best judgment and exercise caution where appropriate. FOR AVOIDANCE OF DOUBT, THE REPORT, ITS CONTENT, ACCESS, AND/OR USAGE THEREOF, INCLUDING ANY ASSOCIATED SERVICES OR MATERIALS, SHALL NOT BE CONSIDERED OR RELIED UPON AS ANY FORM OF FINANCIAL, INVESTMENT, TAX, LEGAL, REGULATORY, OR OTHER ADVICE.
The Leading Engineers of Blockchain Infrastructure