Download audit report
This document outlines the security review conducted by Nethermind Security for the WORLD NFC-ID contracts. The codebase is an evolution of the codebase audited in the report NM-0302-WORLDCOIN-GRANTS4 contracts. This audit focused on two contracts: src/NFC_ID/NFC_ID.sol and src/GatedMulticall3/GatedMulticall3.sol comprising 281 lines of Solidity code, and it was performed using (a) manual analysis of the codebase, (b) automated analysis tools, (c) simulation of the smart contract. The codebase has high quality.
The issues relate to best practices that enhance code consistency and pose no security threats. For example, missing zero-address checks, unnecessary payable keywords, and omitted event emissions do not compromise contract security but can improve reliability and maintainability when addressed.
Out of the six issues identified, three were fixed: First, the issue with events not being emitted in the constructor was resolved, ensuring that storage variable updates trigger events as expected. Second, a zero-address check was added to the addAuthorizedCaller function, aligning it with the rest of the codebase’s standards for address validation. Third, an unchecked conversion on the _amount parameter in the claim(...) function was addressed by implementing a check to prevent overflow, thus improving reliability.
The remaining three issues were acknowledged. Centralization risks were accepted. Additionally, functions that don’t expect native tokens to be transferred were left marked as payable to maintain compatibility with the Allowance Module interface, avoiding interface modifications. Finally, the lack of enforcement linking _nullifierHash and _recipient was accepted as a manageable risk, given that only trusted callers can access the function.
| Audit assessment | |
| Audit Type | Security Review |
| Initial Report | Nov 15, 2024 |
| Response from Client | Regular responses during audit engagement |
| Final Report | Nov 18, 2024 |
| Repository | World NFC-ID |
| Commit (Audit) | 8672196e6b |
| Commit (Final) | d82b025501 |
| Documentation Assessment | High |
| Test Suite Assessment | High |
Findings by severity
| # | Contract | LoC | Comments | Ratio | Blank | Total |
| 1 | src/GatedMulticall3/GatedMulticall3.sol | 186 | 69 | 37.1% | 41 | 296 |
| 2 | src/NFC_ID/NFC_ID.sol | 95 | 40 | 42.1% | 34 | 169 |
| Total | 281 | 109 | 38.8% | 75 | 465 |
| # | Finding | Severity | Update |
| 1 | Centralization Risks | Info | Acknowledged |
| 2 | Functions that don’t expect native tokens to be transferred shouldn’t be payable | Best Practices | Acknowledged |
| 3 | Events not emitted in the constructor | Best Practices | Fixed |
| 4 | Lack of zero address check on GatedMulticall3::addAuthorizedCaller function | Best Practices | Fixed |
| 5 | Unchecked conversion on _amount in the function claim(...) | Best Practices | Fixed |
| 6 | Lack of enforcement linking _nullifierHash and _recipient | Best Practices | Acknowledged |
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 to claim drops on behalf of users. This action marked the nullifierHash as used in the RecurringGrantDrop contract to prevent users from claiming the same grant twice. This was replaced by the NFC_ID contract.Multicall3, adding an authorization layer. Only authorized msg.sender accounts can interact with it, ensuring secure execution of multiple contract calls in a single transaction.Grants4FirstBatch. It allows authorized relayers to claim WLD tokens for individual users. Unlike its predecessor, NFC_ID does not handle batch claims but instead stores the nullifierHash directly within the contract, eliminating the need to call the RecurringGrantDrop contract for nullifier validation.The grant-claiming process in the Worldcoin Grants4 system remains largely similar, 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 updated 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 improves the user experience by eliminating delays 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. In the new system, authorized Worldcoin relayers interact with the NFC_ID contract to claim tokens for users individually.
When a claim is made, the NFC_ID contract validates the nullifierHash directly. If the nullifierHash has not been used, it is marked as used within NFC_ID, and the WLD tokens are transferred to the user, completing the claim. If the nullifierHash has already been set, the claim is skipped, 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.
| File | Fix commit | Type | Status |
src/NFC_ID/NFC_ID.sol | — | Info | Acknowledged |
The contract allows the owner to update the address of the WLD token, the HOLDER, and the ALLOWANCE_MODULE. Arbitrary changes in critical configuration contracts may open the door to malicious modifications compromising contract security. The functions setWldToken(...), setHolder(...), and setAllowanceModule(...) are reproduced below.
function setWldToken(address _wldToken) external onlyOwner {
if (_wldToken == address(0)) {
revert ZeroAddress();
}
WLD_TOKEN = _wldToken;
emit WldTokenSet(_wldToken);
}
function setHolder(address _holder) external onlyOwner {
if (_holder == address(0)) {
revert ZeroAddress();
}
HOLDER = GnosisSafe(_holder);
emit HolderSet(_holder);
}
function setAllowanceModule(address _allowanceModuleAddress) external onlyOwner {
if (_allowanceModuleAddress == address(0)) {
revert ZeroAddress();
}
ALLOWANCE_MODULE = AllowanceModule(_allowanceModuleAddress);
emit AllowanceModuleSet(_allowanceModuleAddress);
}Recommendation
No action is required.
Resolution
While it is true that it is questionable that we will ever update the token address, etc. The owner will be a trusted multisig, and we accept these risks.
| File | Fix commit | Type | Status |
src/GatedMulticall3/GatedMulticall3.sol | — | Best Practices | Acknowledged |
The aggregate(...), tryAggregate(...), tryBlockAndAggregate(...), blockAndAggregate(...), and aggregate3(...) function doesn’t expect any native tokens to be transferred unlike aggregate3Value(...) so they shouldn’t be payable. Any native token sent will be locked in the contract.
Recommendation
Consider removing the payable keyword in the functions that don’t expect native tokens to be transferred.
Resolution
We won’t fix it. The Allowance Module interface expects a payable address, so to avoid changes to the interface, we keep marking it as payable.
Update from Nethermind Security
We agree with this decision.
| File | Fix commit | Type | Status |
src/NFC_ID/NFC_ID.sol | PR #36 | Best Practices | Fixed |
When ALLOWANCE_MODULE, WLD_TOKEN or HOLDER is changed using setAllowanceModule(...), setWldToken(...) or setHolder(...) function respectively, event AllowanceModuleSet, WldTokenSet or HolderSet is emitted but when these variables are initially set in the constructor, no events are emitted.
Recommendation
Emit appropriate events in the constructor as the storage variables are also updated in the constructor.
Resolution
Added in d82b025501f3d4d90899b6ed20ca1e1676efe70e.
GatedMulticall3::addAuthorizedCaller function| File | Fix commit | Type | Status |
src/GatedMulticall3/GatedMulticall3.sol | PR #36 | Best Practices | Fixed |
All the setter functions inside the codebase have a check that prevents the owner from giving any roles to address(0x0), except for the function GatedMulticall3::addAuthorizedCaller(...). The function is reproduced below.
function addAuthorizedCaller(address _caller) public onlyOwner {
////////////////////////////////////////////////
//@audit: lack of zero address check
////////////////////////////////////////////////
authorizedCallers[_caller] = true;
emit AuthorizedCallerAdded(_caller);
}Recommendation
Consider adding a zero address check in this function to maintain consistency throughout the codebase. However, there is no harm in keeping the code as it is.
Resolution
Fixed in d82b025501f3d4d90899b6ed20ca1e1676efe70e.
_amount in the function claim(...)| File | Fix commit | Type | Status |
src/NFC_ID/NFC_ID.sol | PR #36 | Best Practices | Fixed |
The function claim(...) converts the variable _amount from uint256 to uint96 but there is no check to ensure that _amount actually fits within a uint96.
function claim( uint256 _nullifierHash, address _recipient, uint256 _amount ) external {
...
/////////////////////////////////////////////////////////
// @audit: Check if "_amount" fits in a uint96 before
// making the conversion.
/////////////////////////////////////////////////////////
AllowanceModule(ALLOWANCE_MODULE).executeAllowanceTransfer(
HOLDER, WLD_TOKEN, payable(_recipient), uint96(_amount)
);
emit NFCIDGrantClaimed(_recipient);
}Recommendation
Add a check to ensure that _amount always fits a uint96 before making the conversion.
Resolution
Fixed in d82b025501f3d4d90899b6ed20ca1e1676efe70e.
_nullifierHash and _recipient| File | Fix commit | Type | Status |
src/NFC_ID/NFC_ID.sol | — | Best Practices | Acknowledged |
The function NFC_ID::claim(...) does not enforce any relationship between the _nullifierHash and the _recipient parameters. As long as the caller provides a valid _nullifierHash, they can set their own address as the _recipient, claiming the tokens meant for other users.
Since this function can only be called by a whitelisted allowedCaller, the impact is mitigated, but the security of this function can be further improved if these two parameters are tied together.
Recommendation
Consider adding checks that tie the _nullifierHash to the adequate _recipient.
Resolution
We won’t fix it. The contract can only be called by a trusted caller, and we accept this risk.
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 World team has provided documentation about their protocol in the form of in-line comments within the code.
Remarks about World test suite
The World team has a comprehensive test suite that checks the main features of the codebase. This rigorous testing contributes to a well-written and secure codebase.
| 59Tests 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