Download audit report
This document outlines the security review conducted by Nethermind Security for the Worldcoin Grants4 contracts. These new contracts will replace the previous ones starting from the 39th grant, distributed in August 2024. While grant reservation is no longer possible under the new system, users can still claim reservations made in the past for grants 21 to 38.
From Grant 39 through Grant 88, users are entitled to claim one WLD token drop per month. However, if a user is verified for the first time, they can claim the token drop from the previous month during their first month after joining. The new system also introduces a feature allowing authorized relayers to claim the drops on behalf of users immediately upon verification by the Orb. This enhancement addresses the previous delay, where users had to wait for their identity to be propagated across all relevant L2 networks before claiming their tokens.
The audited code comprises of 369 lines of code written in the Solidity language, and it was performed using (a) manual analysis of the codebase, (b) automated analysis tools, (c) simulation of the smart contract.
| Audit assessment | |
| Audit Type | Security Review |
| Initial Report | Aug 30, 2024 |
| Response from Client | Regular responses during audit engagement |
| Final Report | Sep 23, 2024 |
| Repository | worldcoin-grants-contracts |
| Commit (Audit) | 107a056474 |
| Commit (Final) | e78b7dbc38 |
| Documentation Assessment | Medium |
| Test Suite Assessment | High |
Findings by severity
| # | Contract | LoC | Comments | Ratio | Blank | Total |
| 1 | WLDGrantPreGrant4_new.sol | 28 | 11 | 39.3% | 11 | 50 |
| 2 | RecurringGrantDrop.sol | 132 | 94 | 71.2% | 58 | 284 |
| 3 | WLDGrant.sol | 106 | 26 | 24.5% | 18 | 150 |
| 4 | Grants4FirstBatch/Grants4FirstBatch.sol | 103 | 42 | 40.8% | 36 | 181 |
| Total | 369 | 173 | 46.9% | 123 | 665 |
| # | Finding | Severity | Update |
| 1 | Missing zero address checks in Grants4FirstBatch | Best Practices | Fixed |
| 2 | Third-party code should be imported and installed as an external dependency | Best Practices | Fixed |
| 3 | Unused code in Grants4FirstBatch contract | Best Practices | Fixed |
| 4 | Unused imports | Best Practices | Fixed |
The following section provides an overview of the system architecture and key contracts involved in the current Worldcoin Grants contracts (Grants4) version, which replaces the previous contracts starting from the 39th grant.
The Worldcoin Grants4 system is primarily composed of the following contracts:
grantId of 39 or higher. The contract allows users to claim monthly WLD drops once the Orb verifies them. The contract supports the new feature where authorized relayers can claim drops on behalf of users immediately after their verification.checkValidity(...) function can be used to determine if a particular grantId is claimable.batch(...) function from this contract to claim drops on behalf of the users. This action marks the nullifierHash as used in the RecurringGrantDrop contract to prevent users from claiming the same grant for the second time.RecurringGrantDrop contract.The grant claiming process in the Worldcoin Grants4 system differs depending on whether the grant is part of the new grant cycle (Grants 39-88) or involves reservations made in the previous system. The following section outlines the new grant-claiming process.
For the new grants cycle, starting from Grant 39 and continuing through to Grant 88, users are entitled to claim WLD token drops every month. the new system introduces a decreasing grant amount each month. However, the initial month’s token amount starts from a higher base than in the previous system, providing a larger initial drop. The specific amounts are predetermined and stored in the grantAmountsList array in the WLDGrant contract. Whenever the user or authorized relayer claims a grant, the RecurringGrantDrop contract queries the WLDGrant contract to determine the exact token amount to be distributed for that particular month.
At any given time, two grants are active: the current month’s grant and the previous month’s grant. This allows users who missed claiming their tokens in the current month to still claim them in the following month.
For old reservations (Grants 21-38), users can still claim their previously reserved tokens by interacting with the old instance of the RecurringGrantDrop contract.
One of the enhancements in the Worldcoin Grants4 protocol is the introduction of authorized relayers who can claim WLD token drops on behalf of users immediately after they are verified by the Orb. This feature is designed to improve the user experience by eliminating the delay that existed in the previous system.
Previously, users had to wait until their identity was propagated across all relevant Layer 2 (L2) networks before claiming their tokens, causing a delay between verification and the ability to claim. This created friction, as users could not claim their grant tokens immediately after being verified by the Orb, even though the Worldcoin backend already had their identity data. The delay occurred because this information had yet to be posted on-chain.
In the new system, authorized Worldcoin relayers can now step in to claim the tokens as soon as a user is verified. The relayer interacts with the Grants4FirstBatch contract, using the batch(...) function to claim the tokens. In turn, the Grants4FirstBatch contract calls the setNullifierHash(...) function in the RecurringGrantDrop contract to verify whether the nullifier hash for the particular grant claim has already been used. If the nullifier hash has not been used, the setNullifierHash(...) function sets it and transfers the WLD tokens to the user, completing the claim. If the nullifier hash has already been set, the function skips the grant claim, effectively preventing duplicate claims.
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.
Grants4FirstBatch| File | Fix commit | Type | Status |
Grants4FirstBatch.sol | e78b7db | Best Practices | Fixed |
In the RecurringGrantDrop contract, the constructor(...) and all the setter functions have address(0) checks. This is not the case for the Grants4FirstBatch contract. The constructor(...) doesn’t have address(0) checks for its input parameters, nor do the setter functions setAllowanceModule(...), setWldToken(...), setHolder(...), setRecurringGrantDrop(...), addCaller(...).
Recommendation
Consider adding zero address checks to maintain consistency throughout the codebase
Resolution
Addressed in e78b7db.
| File | Fix commit | Type | Status |
Grants4FirstBatch.sol | e78b7db | Best Practices | Fixed |
The Grants contracts use third-party libraries and utilities, such as OpenZeppelin’s Ownable2Step and SafeERC20. Unlike other contracts, the Grants4FirstBatch contract uses third-party utilities that are directly copied into the project’s source files rather than imported and installed as the project’s external dependencies.
This approach has implications for the security of the codebase. While libraries receive continuous updates to address any vulnerabilities or issues discovered, copying code internally makes tracking and applying necessary security updates more challenging. Additionally, the absence of the library version and the origin from where the code was copied makes it hard to review that particular code or function.
Below is the list of files where this issue is present:
src/Grants4FirstBatch/Context.sol;src/Grants4FirstBatch/Ownable.sol;src/Grants4FirstBatch/Ownable2Step.sol;Recommendation
To mitigate security risks and facilitate the review of the codebase, consider importing third-party code similarly to how it is done in other contracts such as RecurringGrantDrop. Alternatively, add comments about the code’s origin and the version used.
Resolution
Addressed in e78b7db. In some places we decided not to use imports (for now) but added docs there.
Grants4FirstBatch contract| File | Fix commit | Type | Status |
Grants4FirstBatch.sol | e78b7db | Best Practices | Fixed |
The Grants4FirstBatch.sol file contains an Enum contract and a GnosisSafe interface. The execTransactionFromModule(...) function inside the GnosisSafe interface is never called and could be removed to keep the code clean and readable. This change makes the Enum contract obsolete as well.
Recommendation
Consider removing the unused code from the codebase or moving it to a separate file, from where it will be imported when needed.
Resolution
Addressed in e78b7db.
| File | Fix commit | Type | Status |
RecurringGrantDrop.sol | e78b7db | Best Practices | Fixed |
The RecurringGrantDrop.sol file imports OpenZeppelin’s ECDSA library which is unused in the contract.
Recommendation
Consider removing unused import statement to keep the codebase clean and readable.
Resolution
Addressed in e78b7db.
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.
The Worldcoin team has provided documentation about their protocol in the form of in-line comments within the code.
| 44Tests 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