Download audit report
This document outlines the security review conducted by Nethermind on the Holesky Funding Vault by the Ethereum Foundation. The funding vault contract can be controlled by a grant manager, who is able to create grants to given recipients. Both the amount of Ether recieved per claim and the interval between each claim can be specified, allowing for each grant to suit the needs of the recipient. This contract is intended to be used on the Holesky testnet, as a way to reliably distribute large amounts of testnet Ether. Recipients can have multiple grants, and each grant can be individually or batch claimed. To prevent a compromised manager from draining the funding vault, grant managers have a restriction applied to the total value of the grants they can create within a given time window.
The audited code comprises 726 lines of Solidity code. The audit was performed using: (a) manual analysis of the codebase and (b) simulation of the smart contracts. All the other issues are informational or best practices.
| Audit assessment | |
| Audit Type | Security Review |
| Initial Report | May 7, 2024 |
| Response from Client | May 26, 2024 |
| Final Report | May 30, 2024 |
| Methods | Manual Review, Automated Analysis, Tests |
| Repository | Holešovice Funding Vault |
| Commit Hash | 182d23031c |
| Documentation | Code comments |
| Documentation Assessment | High |
| Test Suite Assessment | Medium |
Findings by severity
| # | Contract | LoC | Comments | Ratio | Blank | Total |
| 1 | contracts/ReentrancyGuard.sol | 21 | 43 | 204.8% | 9 | 73 |
| 2 | contracts/IFundingVaultToken.sol | 5 | 1 | 20.0% | 2 | 8 |
| 3 | contracts/FundingVaultProxy.sol | 49 | 11 | 22.4% | 14 | 74 |
| 4 | contracts/IFundingVault.sol | 4 | 1 | 25.0% | 1 | 6 |
| 5 | contracts/FundingVaultToken.sol | 40 | 13 | 32.5% | 12 | 65 |
| 6 | contracts/FundingVaultProxyStorage.sol | 7 | 3 | 42.9% | 1 | 11 |
| 7 | contracts/FundingVaultV1.sol | 362 | 47 | 13.0% | 80 | 489 |
| Total | 488 | 119 | 24.4% | 119 | 726 |
| # | Finding | Severity | Update |
| 1 | Certain calls can be forced to revert with an invalid grant | Medium | Fixed |
| 2 | Manager cooldown period is not consistent | Info | Fixed |
| 3 | Missing zero address checks | Best Practices | Fixed |
| 4 | Other Best Practice fixes | Best Practices | Fixed |
Vault allows for controlled distribution of ETH on the Holesky testnet. Detailed specification is outlined in this document. The Vault defines roles: Grantee, Manager, Admin. Managers create and manage grants, which allow Grantees to spend ETH up to a limit over a specified time. Admins hold special functionality like upgrading contracts, managing grants without limits, or accessing emergency functions. Grants are ERC-721 NFT tokens. Holders of a token (Grantee) can claim ETH up to a limit, but transferring the token is allowed only for Managers. To minimize the risk, Managers’ actions are limited to a defined amount of ETH.
The FundingVaultV1.sol is an upgradeable contract that holds funds and contains the distribution logic of ETH. The contract uses the following storage variables:
address internal _vaultTokenAddr;
uint64 internal _grantIdCounter;
uint32 internal _claimTransferLockTime;
uint128 internal _managerLimitAmount;
uint64 internal _managerLimitInterval;
uint32 internal _managerGrantCooldown;
uint32 internal _managerGrantCooldownLock;
mapping(uint64 => Grant) internal _grants;
mapping(uint64 => uint64) internal _grantClaimLock;
mapping(address => uint64) internal _managerCooldown;The contract exposes the following public or external functions:
Initialization function
function initialize(...) publicReceives ETH
receive(...) external payableAllows admin for rescue transfer of funds
function rescueCall(...) publicAllows managers to create new grants under defined limits
function createGrant(...) publicAllows manager to increase or decrease the granted amount
function updateGrant(...) publicAllows manager to transfer grant NFT token
function transferGrant(...) publicAllows manager to remove grant
function removeGrant(...) publicTemporarily lock claiming of the funds for a particular grant
function lockGrant(...) publicClaims given amount of ETH from either specified grant or all available grants (two overfloaded functions)
function claim(...) publicClaims given amount of ETH from either specified grant or all available grants to given target (two overloaded functions)
function claimTo(...) publicAdmin-only setters
function setPaused(...) public
function setProxyManager(...) public
function setClaimTransferLockTime(...) public
function setManagerGrantLimits(...) publicView functions
function getVaultToken(...) public view
function getGrants(...) public view
function getGrant(...) public view
function getGrantLockTime(...) public view
function getClaimableBalance(...) public view
function getClaimableBalance(...) public view
function getManagerCooldown(...) public viewThe contract inherits the following OpenZeppelin contracts:
AccessControl
PausableAnd the following custom contracts:
FundingVaultProxyStorage
ReentrancyGuard
FundingVaultStorage
IFundingVaultThe FundingVaultToken.sol contract is an ERC721 token that represents a grant. The contract exposes the following non-inherited public or external functions:
Transfers received ETH to the Vault contract
receive() external payableMints, burns, or transfers the token
function tokenUpdate(...) publicReturns Vault address
function getVault(...) public viewThe 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 |
FundingVaultV1.sol | PR #11 | Medium | Fixed |
When calling createGrant the argument interval is used to specify how often the grant recipient should be able to claim. Upon the creation of a grant the claimTime is set as the current timestamp minus the interval, which allows the grant recipient to claim immediately. However, it is possible to set the interval argument to be equal to the block timestamp, resulting in a claimTime of zero.
function createGrant(
address addr,
uint128 amount,
uint64 interval
) public onlyRole(GRANT_MANAGER_ROLE) nonReentrant {
// ...
_grants[grantId] = Grant({
claimTime: _getTime() - interval, // @audit Claim time can be zero
claimInterval: interval,
claimLimit: amount,
dustBalance: 0
});
// ...
}In many other functions, the existence of a grant is checked by ensuring its claim time is not zero. When the function determines that a grant does not exist, the function will revert. A list of all affected functions is shown below:
getGrant(uint64)
getGrantLockTime(uint32)
getClaimableBalance()
getClaimableBalance(uint64)
updateGrant(uint64, uint128, uint64)
transferGrant(uint64, address)
removeGrant(uint64)
lockGrant(uint64, uint64)
claim(uint256)
claim(uint64, uint256)
claimTo(uint256, address)
claimTo(uint64, uint256, address)Most of these functions must take the broken grant ID as an argument to cause a revert, meaning the broken grant can be ignored, and the contract will continue to operate normally. However, the function claim(uint256) operates by loading and attempting to claim from all grants, meaning that any attempts to claim will always revert through this function. If a smart contract is the recipient of the given grant and the contract is written to only claim through this function, it will not be able to receive any funds, even from other unbroken grants.
Recommendation
Consider restricting the interval argument in createGrant to some maximum timeframe, such as monthly or biannual intervals. This restriction will prevent the interval from being high enough to create an invalid grant.
Resolution
Great catch, fixed via 5e2e2a1f0b43. The createGrant function now requires the interval to be smaller than _getTime() to avoid the edge case where claimTime gets initialized with 0.
| File | Fix commit | Type | Status |
FundingVaultV1.sol | — | Info | Fixed |
The managers are limited to creating/transferring grants up to the value of 100k ETH per month. This limitation is intended to protect assets from being drained from the vault in case a grant manager wallet is compromised. Functions that check the limit of manager actions are: createGrant(...), updateGrant(...), and transferGrant(...). The check is done in the following line:
// from createGrant(...)
require(_managerCooldown[_msgSender()] < _getTime() + _managerGrantCooldownLock, "manager cooldown");The value in _managerCooldown mapping is updated in the following:
// from createGrant(...)
_managerCooldown[_msgSender()] += uint64(_managerGrantCooldown * grantQuota / managerQuota) + 1;The cooldown is increased by the number of hours that is proportional to the rato: grantQuota / managerQuota. If this ratio is one, grantQuota == managerQuota, then the cooldown is increased by _managerGrantCooldown which by default is 24 hours. If the grant is created with less quota, then the cooldown increases by some part of 24 hours. During grant creation, the cooldown must pass the check _managerCooldown[_msgSender()] < _getTime() + _managerGrantCooldownLock, which can be summarized as: cooldown < now + 12h. Since during the creation of a grant (with max quota), the cooldown was updated as cooldown = now + 24h, the next creation by this manager may be done after 12 hours. However, the difference in the lock period for managers is not always the same. Consider an example of a manager that:
As can be seen, the waiting period is not always the same and depends on when the previous grant was created. In the given example, the cooldown is updated twice by 24 hours, but the lock period is defined as the current time minus twelve hours. That creates inconsistent waiting periods, regardless of the cooldown values set. Below, we present the described example:
(c) distribution of issues according to the severity
Recommendation
Consider removing _managerGrantCooldownLock from the following statement for consistent time lock periods:
require(_managerCooldown[_msgSender()] < _getTime() + _managerGrantCooldownLock, "manager cooldown");Resolution
This is an intended behavior of the contract to avoid immediate locking for managing multiple smaller grants in one go.
Without that "lock time threshold", managers would always get locked for a certain period of time (proportional to the grant quota) after each management action. The idea of the threshold is to allow managing certain small grants in one go, without always being locked after each interaction. With the default settings applied, a manager is able to create/update/move grants worth 50k ETH/Month before getting locked the first time.
All the manager cooldown-related settings can also be changed by the contract admin via the setClaimTransferLockTime(...) function.
To follow the suggestion and make the cooldown more strict, we could remove that threshold by setting _managerGrantCooldownLock to 0 without a code change.
I’ve updated the description of this behavior in the documentation as well.
| File | Fix commit | Type | Status |
FundingVaultV1.sol | PR #11 | Best Practices | Fixed |
The functions that take an address as an argument do not validate that the address is not 0. Below, we list those functions in the FundingVault1 contract:
function initialize(address tokenAddr) public {
function setProxyManager(address manager) public onlyRole(DEFAULT_ADMIN_ROLE) {
function rescueCall(address addr, uint256 amount, bytes calldata data) public onlyRole(DEFAULT_ADMIN_ROLE) {Recommendation
Consider checking that the address is not address(0).
Resolution
Fixed via a6b6aee8bb41.
| File | Fix commit | Type | Status |
| — | — | Best Practices | Fixed |
The client proactively fixed small issues discussed during the sync calls, but not reported in this document.
block.timestamp helper function _getTime(): 2e58324dff2a;uint64 for grantIds: aa74fa84b776;Resolution
I’ve also fixed the other small issues we discussed in the meeting from Apr-30. The small fixes are detailed above (field Description).
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 Ethereum Foundation provided a separate document that specified the desired features, roles and mechanisms in detail. Moreover, the code contained informative comments. The audit team remained in communication with the client during the audit.
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