Ethereum Foundation
Holesky Funding Vault

The Ethereum Foundation uses this vault to hand out Holesky testnet ETH through grants with set amounts and claim intervals. We reviewed grant creation and claiming, and the limits that stop a compromised manager from draining it.
report id
0234
category
Infra & Wallets
language
Solidity
final report
May 30, 2024
lines of code
488
Content

Download audit report

1

Executive Summary

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 TypeSecurity Review
Initial ReportMay 7, 2024
Response from ClientMay 26, 2024
Final ReportMay 30, 2024
MethodsManual Review, Automated Analysis, Tests
RepositoryHolešovice Funding Vault
Commit Hash182d23031c
DocumentationCode comments
Documentation AssessmentHigh
Test Suite AssessmentMedium
Total findings
4
Fixed
4
Acknowledged
0
Mitigated
0
Unresolved
0

Findings by severity

  • Critical0
  • High0
  • Medium1
  • Low0
  • Informational1
  • Best Practices2

2

Audited Files

#ContractLoCCommentsRatioBlankTotal
1contracts/ReentrancyGuard.sol2143204.8%973
2contracts/IFundingVaultToken.sol5120.0%28
3contracts/FundingVaultProxy.sol491122.4%1474
4contracts/IFundingVault.sol4125.0%16
5contracts/FundingVaultToken.sol401332.5%1265
6contracts/FundingVaultProxyStorage.sol7342.9%111
7contracts/FundingVaultV1.sol3624713.0%80489
Total48811924.4%119726

3

Summary of Issues

4

System Overview

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(...) public

Receives ETH

receive(...) external payable

Allows admin for rescue transfer of funds

function rescueCall(...) public

Allows managers to create new grants under defined limits

function createGrant(...) public

Allows manager to increase or decrease the granted amount

function updateGrant(...) public

Allows manager to transfer grant NFT token

function transferGrant(...) public

Allows manager to remove grant

function removeGrant(...) public

Temporarily lock claiming of the funds for a particular grant

function lockGrant(...) public

Claims given amount of ETH from either specified grant or all available grants (two overfloaded functions)

function claim(...) public

Claims given amount of ETH from either specified grant or all available grants to given target (two overloaded functions)

function claimTo(...) public

Admin-only setters

function setPaused(...) public
function setProxyManager(...) public
function setClaimTransferLockTime(...) public
function setManagerGrantLimits(...) public

View 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 view

The contract inherits the following OpenZeppelin contracts:

AccessControl
Pausable

And the following custom contracts:

FundingVaultProxyStorage
ReentrancyGuard
FundingVaultStorage
IFundingVault

The 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 payable

Mints, burns, or transfers the token

function tokenUpdate(...) public

Returns Vault address

function getVault(...) public view

5

Risk Rating Methodology

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:

  1. High: the issue is trivial to exploit and has no specific conditions that need to be met;
  2. Medium: the issue is moderately complex and may have some conditions that need to be met;
  3. Low: the issue is very complex and requires very specific conditions to be met.

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:

  1. High: the issue can cause significant damage, such as loss of funds or the protocol entering an unrecoverable state;
  2. Medium: the issue can cause moderate damage, such as impacts that only affect a small group of users or only a particular part of the protocol;
  3. Low: the issue can cause little to no damage, such as bugs that are easily recoverable or cause unexpected interactions that cause minor inconveniences.

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 / LikelihoodLowMediumHigh
HighMediumHighCritical
MediumLowMediumHigh
LowInfo / Best PracticesLowMedium
UndeterminedUndeterminedUndeterminedUndetermined

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.

  1. Informational findings do not pose any risk to the application, but they carry some information that the audit team intends to pass to the client formally;
  2. Best Practice findings are used when some piece of code does not conform with smart contract development best practices;
  3. Undetermined findings are used when we cannot predict the impact or likelihood of the issue.

6

Issues

6.1 Certain calls can be forced to revert with an invalid grant

FileFix commitTypeStatus
FundingVaultV1.solPR #11MediumFixed

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.

6.2 Manager cooldown period is not consistent

FileFix commitTypeStatus
FundingVaultV1.sol—InfoFixed

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:

  • Creates a grant with a maximum quota ;
  • After 12 hours, creates another grant with a maximum quota ;
  • To create the next (third) grant, the manager must wait 24 hours ;

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.

6.3 Missing zero address checks

FileFix commitTypeStatus
FundingVaultV1.solPR #11Best PracticesFixed

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.

6.4 Other Best Practice fixes

FileFix commitTypeStatus
——Best PracticesFixed

The client proactively fixed small issues discussed during the sync calls, but not reported in this document.

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).

7

Documentation Evaluation

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:

  • Technical whitepaper: A technical whitepaper is a comprehensive document describing the smart contract’s design and technical details. It includes information about the purpose of the contract, its architecture, its components, and how they interact with each other;
  • User manual: A user manual is a document that provides information about how to use the smart contract. It includes step-by-step instructions on how to perform various tasks and explains the different features and functionalities of the contract;
  • Code documentation: Code documentation is a document that provides details about the code of the smart contract. It includes information about the functions, variables, and classes used in the code, as well as explanations of how they work;
  • API documentation: API documentation is a document that provides information about the API (Application Programming Interface) of the smart contract. It includes details about the methods, parameters, and responses that can be used to interact with the contract;
  • Testing documentation: Testing documentation is a document that provides information about how the smart contract was tested. It includes details about the test cases that were used, the results of the tests, and any issues that were identified during testing;
  • Audit documentation: Audit documentation includes reports, notes, and other materials related to the security audit of the smart contract. This type of documentation is critical in ensuring that the smart contract is secure and free from vulnerabilities.

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.

8

Remarks & Test Suite

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.