Puffer
PufferPool & pufETH

Puffer is a native liquid restaking protocol on EigenLayer. We reviewed PufferPool, which handles node operators and validator provisioning, and the V2 upgrade of the pufETH vault and depositor.
report id
0202
category
DeFi & Yield
language
Solidity
final report
April 16, 2024
lines of code
2351
Content

Download audit report

1

Executive Summary

This document outlines the security review conducted by Nethermind Security for the Puffer contracts. Puffer is a decentralized native liquid restaking protocol (nLRP) built on Eigenlayer. The audit focuses on two sets of contracts: PufferPool and pufETH.

PufferPool is primarily handling interactions with node operators. Its functions include validator registration, node provisioning, rewards distribution, restaking, and validator exiting. These operations are safeguarded by the guardian module, requiring a threshold number of guardian signatures for execution.

On the other hand, pufETH is the main point of interaction for stakers. Stakers can deposit ETH into PufferVault and receive yield-bearing pufETH tokens in return. The ETH deposited into PufferVault is used to provision nodes in the Puffer Protocol. Node operators must purchase a validator ticket, after which their validators are provisioned with 32 ETH to begin their validator duties. Due to validator ticket sales, the value of the pufETH token will increase over time.

The audited code consists of 2,351 lines of Solidity. Of these lines, 2,016 corresponds to PufferPool. The remaining 335 are connected to pufETH, focusing on the V2 upgrade of PufferVaultV2 and PufferDepositorV2 contracts. Overall, the audited code is of high quality and shows a strong understanding of Solidity’s best practices. The team provided documentation presenting the main use cases and protocol mechanisms. This documentation was supported by a walkthrough of the code and continuous communication with the team.

The audit was performed using: (a) manual analysis of the codebase, (b) simulation of the smart contracts and (c) automation analysis of the smart contracts.

Audit assessment
Audit TypeSecurity Review
Initial ReportApr 12, 2024
Final ReportApr 16, 2024
MethodsManual Review, Automated analysis
RepositoryPufferPool & pufETH
Commit Hash (Initial Audit - PufferPool)0c60cef014
Commit Hash (Initial Audit - pufETH)1b8ec764c1
Final Commit Hash (PufferPool)2c25db3cc7
Final Commit Hash (pufETH)a510fd5924
DocumentationProtocol docs
Documentation AssessmentHigh
Test Suite AssessmentMedium
Total findings
23
Fixed
17
Acknowledged
6
Mitigated
0
Unresolved
0

Findings by severity

  • Critical0
  • High1
  • Medium2
  • Low5
  • Informational11
  • Best Practices4

2

Audited Files

2.1 PufferPool

#ContractLoCCommentsRatioBlankTotal
1LibGuardianMessages.sol4041102.5%889
2PufferModuleManager.sol1837239.3%39294
3PufferProtocolStorage.sol1111100.0%325
4Errors.sol39300.0%214
5EnclaveVerifier.sol533260.4%16101
6ValidatorTicket.sol1176152.1%24202
7PufferOracle.sol282485.7%860
8ValidatorTicketStorage.sol1428200.0%345
9PufferOracleV2.sol666293.9%17145
10PufferModule.sol23811950.0%51408
11RestakingOperator.sol815061.7%19150
12LibBeaconchainContract.sol251560.0%141
13GuardianModule.sol26213350.8%65460
14PufferProtocol.sol46020544.6%122787
15interface/IEnclaveVerifier.sol2035175.0%863
16interface/IValidatorTicket.sol1755323.5%1486
17interface/IBeaconDepositContract.sol131076.9%225
18interface/IRestakingOperator.sol1133300.0%751
19interface/IWETH.sol18422.2%224
20interface/IPufferModule.sol4771151.1%18136
21interface/IPufferModuleManager.sol79166210.1%29274
22interface/IPufferProtocol.sol85237278.8%53375
23interface/IGuardianModule.sol60163271.7%33256
24struct/StoppedValidatorInfo.sol1011110.0%122
25struct/Validator.sol9444.4%215
26struct/NodeInfo.sol6466.7%111
27struct/ProtocolStorage.sol2052260.0%375
28struct/Status.sol8450.0%113
29struct/RaveEvidence.sol6466.7%111
30struct/ValidatorKeyData.sol9444.4%114
31integrations/BalancerRateProvider.sol171588.2%537
Total2016173486.0%5594309

2.2 pufETH

#ContractLoCCommentsRatioBlankTotal
1PufferVaultV2.sol27517463.3%71520
2PufferDepositorV2.sol602338.3%1396
Total33519758.8%84616

3

Summary of Issues

#FindingSeverityUpdate
1Potential front-running provisionNode(...) to overwrite withdrawal credentialHighFixed
2Potential hash collision between different guardian messagesMediumAcknowledged
3The check in setting fees is wrongMediumFixed
4Incorrect index used when calculating sharesWithdrawnLowFixed
5No check of low-level call executionLowFixed
6Threshold is not checked when removing guardiansLowFixed
7Unfair module choosing when some modules are emptyLowAcknowledged
8numberOfActiveValidators variable is not updated when skipProvisioning(...) is calledLowFixed
9Changing the daily withdrawal limit resets daily withdrawalsInfoAcknowledged
10Disabling function depositToEigenLayer(...) in PufferVaultV2InfoFixed
11Duplicate codeInfoFixed
12Function addGuardian(...) does not check if the address to be added as a Guardian is an EOAInfoAcknowledged
13Inappropriate names for functions and variablesInfoFixed
14Invariant violation in function setValidatorLimitPerModule(...)InfoFixed
15Lack of slippage protection when purchasing validator ticketInfoAcknowledged
16Missing input validationsInfoFixed
17Module is not validated to have a name different than NO_VALIDATORSInfoFixed
18Slasher is not implemented in the upgraded version of EigenLayer contractsInfoAcknowledged
19Unnecessary usage of _disableInitializers() in the constructor of PufferDepositorV2InfoFixed
20Incorrect comments about ValidatorTicket feeBest PracticesFixed
21Lack of _disableInitializers() in some upgradable contractsBest PracticesFixed
22Unnecessary cast to uint56 when setting priceBest PracticesFixed
23Unnecessary external call to get deposit data rootBest PracticesFixed

4

System Overview

Puffer is a decentralized native liquid restaking protocol (nLRP) built on Eigenlayer. It makes native restaking on Eigenlayer more accessible, allowing anyone to run an Ethereum Proof of Stake (PoS) validator while supercharging their rewards.

The Puffer Protocol comprises two sets of contracts: pufETH and PufferPool

  • pufETH is the main point of interaction for stakers. Stakers can deposit ETH and mint the pufETH nLRT via the PufferVault contract, which serves as a redeemable receipt for their restaked ETH. If sufficient exit liquidity is available, stakers can reclaim their ETH from the PufferVault. Over time, the redeemable amount is expected to increase from validator tickets and restaking rewards.
  • PufferPool is primarily handling interactions with node operators. Its functions include validator registration, node provisioning, rewards distribution, restaking, and validator exiting. These operations are safeguarded by the guardian module, requiring a threshold number of guardian signatures for execution.

Fig. 2 The diagram shows interactions between Puffer contracts and external entities.

32*N ETH 32*N ETH 32*N ETH Eigenpod Eigenpod Eigenpod

32 ETH 32 ETH 32 ETH 32 ETH 32 ETH

1 ETH Bond + ≥ 28 VTs 1 ETH Bond + ≥ 28 VTs 2 ETH Bonds + ≥ 28 VTs

4.1 pufETH

pufETH is a native liquid restaking token (nLRT). Users can deposit ETH and mint the pufETH nLRT through the PufferVault contract, serving as a redeemable receipt for their restaked ETH. Current pufETH holders earn LST yield, Puffer points and can participate in DeFi without lockups.

Before Puffer’s full mainnet launch, users can deposit stETH into the PufferVault to participate in Puffer’s early adopter program. Users without stETH can also participate as the contract supports token swapping to stETH before depositing. In return, depositors receive pufETH, which appreciates as the underlying stETH in the contract accrues.

Upon Puffer’s full mainnet launch, stETH will be withdrawn from EigenLayer and converted to ETH via Lido. This process is expected to take approximately 10 days. During this time, depositors can continue to mint pufETH, but the contract will switch to accept ETH & WETH deposits.

After the withdrawal process, the ETH is used to provide decentralized Ethereum validators within the Puffer protocol. This marks a transition from Lido LST rewards to Puffer Protocol rewards. pufETH holders don’t need to take any action. However, as the Puffer protocol operates, the value of pufETH is expected to increase faster as it now captures both PoS and restaking rewards.

This audit focused on the mainnet launch upgrade of pufETH with two contracts: PufferVaultV2 and PufferDepositorV2.

  • PufferVaultV2 is responsible for holding funds for the Puffer protocol. The initial V1 deployment is an ERC4626 vault with stETH as the underlying asset. The PufferVaultV2 contract is the next upgrade, changing the underlying asset to WETH and adding functionality to support the Puffer protocol’s mainnet deployment. At any point in time, the full backings of PufferVaultV2 may be a combination of stETH, WETH, and ETH.
  • PufferDepositorV2 facilitates the deposit of stETH and wstETH into the PufferVaultV2. Deposit of wstETH will be unwrapped to stETH before depositing to PufferVaultV2.

4.2 PufferPool

PufferPool is the core of the Puffer protocol, primarily handling interactions with node operators. The audit scope includes all contracts in this repository:

  • PufferProtocol is central to managing validator operations, including accounting and custody of validator bonds and VTs. Node operators start by registering a validator using the function registerValidatorKey(...). They can purchase or transfer validator tickets to this contract to start a new validator. Node operators can also specify the PufferModule in which they will participate.
  • PufferModuleManager is a factory contract for creating protocol-owned PufferModule and RestakingOperator contracts. It also serves as a central contract for coordinating calls to the PufferModule and RestakingOperator contracts. Interactions from DAO will initiate in the PufferModuleManager contract, which will then call the equivalent PufferModule and RestakingOperator.
  • PufferModule contract owns an EigenPod and is responsible for managing and interacting with the EigenLayer contracts. As Puffer’s permissionless node operators deploy their validators, they set their withdrawal credentials to point to a PufferModule’s EigenPod to participate in restaking. PufferModule can then delegate their restaked beacon chain ETH to an operator to service AVSs.
  • RestakingOperator contract handles EigenLayer interactions. This reduces the trust placed in the operators, as the RestakingOperator contract controls AVSs selections. All RestakingOperator contract functions are restricted to the PufferModuleManager contract, giving the DAO control over which AVSs the operator can participate in.
  • GuardianModule contract is used to manage the Guardians of the Puffer protocol. Guardians play a vital role in Puffer’s protocol. They are a collective of respected community members deeply aligned with Ethereum’s principles and values. The roles of the Guardians include:
  • – Provisioning new validators who registered
  • – Skipping malformed validator registrations
  • – Ejecting validators whose ETH balance has fallen too low or who have exhausted their Validator Tickets
  • – Validator tickets accounting for node operators
  • – Handling full withdrawal requests
  • – Reporting the number of active Puffer validators
  • – Reporting the total number of active Ethereum validators for enforcing the BurstThreshold
  • ValidatorTicket is used as validator time at a discounted price. To run validators in Puffer, node operators lock VT ERC20s in the PufferProtocol contract. Each validator consumes 1 VT per day they are active. Notably, VTs are consumed only after the validator has been activated on the beacon chain, meaning their tickets do not expire while in the queueing process.
  • PufferOracleV2 contract is used to set important variables for the protocol’s accounting. These variables include the number of active Puffer validators, the total number of validators on Ethereum, and the validator ticket price.

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 Potential front-running provisionNode(...) to overwrite withdrawal credential

FileFix commitTypeStatus
PufferProtocol.sol—HighFixed

After node operators register a validator, guardians verify the validator’s setup and sign a message. This allows anyone to call the provisionNode(...) function, provide the signatures, and activate the validator.

The vulnerability stems from the fact that Beacon Chain allows multiple deposits for a single validator public key. It does not check that all deposits have the same withdrawal credentials and assumes the withdrawal credential is in the first valid deposit.

In the Puffer Protocol, the provisionNode(...) function stakes 32 ETH for a validator through the EigenPod. This function sets the withdrawal credential to the EigenPod contract. However, if the validator front-runs this provisionNode(...) transaction and deposits directly to the Beacon Deposit Contract, they can redirect the withdrawal credential to an address they control instead of the EigenPod.

Recommendation

Consider adding the deposit root of the Beacon Deposit Contract to the guardian’s signature. In the function provisionNode(...), ensure that the current deposit root matches the provided one.

Resolution

provisionNode is now permissioned, and for the no enclave case, we will use the deposit root hash

PR #224

Update from Nethermind Security

The issue is fixed due to the restriction of the function calling to Paymaster. However, the proper fix should include depositRootHash in the data for the guardians’ signature.

The current design makes a protocol more centralised. The protocol relied initially on N guardians, but now it depends on one Paymaster entity.

Update from the client

The exclusion of depositRootHash from the guardian’ signature is intentional to shorten the time from setting the deposit root hash and the transaction execution. We will extend the access to this function to the guardians other than the paymaster to prevent centralization.

6.2 Potential hash collision between different guardian messages

FileFix commitTypeStatus
LibGuardianMessages.sol—MediumAcknowledged

The data lengths being hashed in the functions _getSkipProvisioningMessage(...) and _getSetNumberOfValidatorsMessage(...) are both 64 bytes. This could potentially lead to hash collisions between these two guardian messages.

function _getSkipProvisioningMessage(bytes32 moduleName, uint256 index) internal pure returns (bytes32) {
// All guardians use the same nonce
return keccak256(abi.encode(moduleName, index)).toEthSignedMessageHash();
}

function _getSetNumberOfValidatorsMessage(uint256 numberOfValidators, uint256 epochNumber)
internal
pure
returns (bytes32)
{
return keccak256(abi.encode(numberOfValidators, epochNumber)).toEthSignedMessageHash();
}

As a result, when a guardian signs a message, the same signature can potentially be used for both skip provisioning and setting the number of validators.

Recommendation

Adhere to EIP-712 to avoid hash collision between different types of messages.

Resolution

Mitigated by changing the functions to restricted to authorized addresses (paymaster). In the future upgrades, we will update all signed message formats to adhere with to EIP-712.

Making the related functionality setTotalNumberOfValidators permissioned.

However, this is highly unlikely to happen given the type of the values encoded are different:

  • abi.encode(moduleName, index) → moduleName: bytes32, index: uint256;
  • abi.encode(numberOfValidators, epochNumber) → numberOfValidators: uint256;
  • 38d8fce;

6.3 The check in setting fees is wrong

FileFix commitTypeStatus
ValidatorTicket.sol—MediumFixed

DAO address can set fees for purchasing validator tickets. There are two categories of fees: Protocol fee and Guardian’s fee. The first fee is sent to the protocol’s treasury, and the second one to the contract where guardians are managed.

The maximum fee should be 10%, as stated in the following comment:

function _setProtocolFeeRate(uint256 newProtocolFeeRate) internal virtual {
ValidatorTicket storage $ = _getValidatorTicketStorage();
// Treasury fee can not be bigger than 10%
...
}

However, when setting new fees for both protocol and guardians (_setProtocolFeeRate(...) and _setGuardiansFeeRate(...)), a new fee is not compared with the maximum value at all. In reality, a current fee is compared with the maximum value.

function _setProtocolFeeRate(uint256 newProtocolFeeRate) internal virtual {
ValidatorTicket storage $ = _getValidatorTicketStorage();
// Treasury fee can not be bigger than 10%
if ($.protocolFeeRate > (1000)) { // @audit wrong comparison
revert InvalidData();
}
...
}

function _setGuardiansFeeRate(uint256 newGuardiansFeeRate) internal virtual {
ValidatorTicket storage $ = _getValidatorTicketStorage();
// Treasury fee can not be bigger than 10%
if ($.protocolFeeRate > (1000)) { // @audit wrong comparison
revert InvalidData();
}
...
}

As a result, a fee bigger than 10% is possible. Furthermore, once a fee larger than 10% is set in the current implementation, it will not be possible to change it.

Recommendation

Replace the current fee rate in the conditional statement with the new one.

Resolution

Fixed the natspec and using the correct values in the setter functions

6.4 Incorrect index used when calculating sharesWithdrawn

FileFix commitTypeStatus
PufferModuleManager.sol—LowFixed

The function callCompleteQueuedWithdrawals(...) calculates the total number of shares withdrawn by performing a nested loop through all the withdrawal shares and summing them up. However, the index used to get the share value is incorrect, resulting in an incorrect calculation.

function callCompleteQueuedWithdrawals(
...
) external virtual restricted {
...
uint256 sharesWithdrawn;

for (uint256 i = 0; i < withdrawals.length; i++) {
for (uint256 j = 0; j < withdrawals[i].shares.length; j++) {
sharesWithdrawn += withdrawals[i].shares[i]; // @audit Should use withdrawals[i].shares[j] instead
}
}
...
}

Recommendation

Use withdrawals[i].shares[j] instead of withdrawals[i].shares[i] when calculating sharesWithdrawn.

Resolution

065fa2b

6.5 No check of low-level call execution

FileFix commitTypeStatus
PufferProtocol.sol—LowFixed

During the execution of batchHandleWithdrawals(...), a transferAmount of ETH is sent from the puffer module to PufferVault:

IPufferModule(validatorInfos[i].module).call(address(PUFFER_VAULT), transferAmount, "");

The line above executes a high-level function call(...). If investigate this function further:

function call(address to, uint256 amount, bytes calldata data) external onlyPufferProtocol returns (bool success, bytes memory) {
return to.call{ value: amount }(data);
}

It executes a low-level call, which returns a boolean value indicating its successful execution. However, this boolean value is never checked, which can create issues if not enough ETH balance is present in a module.

Recommendation

Consider checking the result of a low-level call.

Resolution

Fixed by checking the return success and revert if fail.

6.6 Threshold is not checked when removing guardians

FileFix commitTypeStatus
GuardianModule.sol—LowFixed

When removeGuardian(...) is called, the guardian count may drop below the threshold, so the number of signers would not be enough to create a valid signature, potentially leaving the protocol in an inoperative state until either a new guardian is added or the threshold is updated.

function removeGuardian(address guardian) external restricted {
splitGuardianFunds();
(bool success) = _guardians.remove(guardian);
if (success) {
emit GuardianRemoved(guardian);
}
}

Recommendation

Consider validating the threshold to ensure that after removing a guardian, the remaining number of guardians is at least equal to the threshold.

Resolution

Fixed by reverting if the number of guardians will go bellow the threshold

6.7 Unfair module choosing when some modules are empty

FileFix commitTypeStatus
PufferProtocol.sol—LowAcknowledged

The function provisionNode(...) calls getNextValidatorToProvision(...) to identify the next validator for provisioning. This function loops from the current moduleSelectIndex to find the nearest non-empty module.

while (moduleSelectionIndex < moduleEndIndex) {
// Read the index for that moduleName
uint256 pufferModuleIndex = $.nextToBeProvisioned[moduleName];

// If we find it, return it
if ($.validators[moduleName][pufferModuleIndex].status == Status.PENDING) {
return (moduleName, pufferModuleIndex);
}
unchecked {
// If not, try the next module
++moduleSelectionIndex;
}
moduleName = $.moduleWeights[moduleSelectionIndex % moduleWeightsLength];
}

However, after this, the moduleSelectIndex variable only increases by 1. This does not align with the logic of getNextValidatorToProvision(...) and allows a module to be selected more than once in a row.

// @audit Skip empty module
(bytes32 moduleName, uint256 index) = getNextValidatorToProvision();
...
// @audit Not match the logic in getNextValidatorToProvision()
unchecked {
// Increment module selection index
++$.moduleSelectIndex;
}

Consider this scenario:

1. Let’s say we have 4 modules [mod_1, mod_2, mod_3, mod_4] and the number of validators in each module are [0, 0, 3, 3] (the first and second modules do not have any validator); 2. Assume moduleSelectIndex = 0, the getNextValidatorToProvision(...) function will choose mod_3 for provision. After that moduleSelectIndex = 1 is updated; 3. The next call to provisionNode(...), the function getNextValidatorToProvision(...) will still choose mod_3 for provision. After that moduleSelectIndex = 2 is updated; 4. Again, the third time function provisionNode(...) is called, the function getNextValidatorToProvision(...) will still choose mod_3 for provision;

As demonstrated, validators in mod_3 are chosen three times in a row.

Recommendation

Consider updating moduleSelectIndex according to the chosen index after the function getNextValidatorToProvision(...).

Resolution

Given that in addition to the order, each module has a weight associated with it, the weights should be set accordingly setModuleWeights to prevent the discussed issue.

Update:

  • In the warm phase, we’ll have a very even distribution in the modules, specially as the validators have control over which module to register their keys to;
  • In the case we add new modules that are more popular, (e.g. ABCD are empty and we introduce E) we may use setModuleWeights([E]) to save the gas costs and prioritizes E module selection;
  • Also in the scenario when mod1 is empty, a validator can go to the empty mod to get provisions faster without any queue;
  • In addition to that, the DAO can set setValidatorLimitPerModule(bytes32 moduleName, uint128 limit) to prevent new registrations on any module that is over populated;

6.8 numberOfActiveValidators variable is not updated when skipProvisioning(...) is called

FileFix commitTypeStatus
PufferProtocol.sol—LowFixed

During the validator’s registration, the variable numberOfActiveValidators is increased by one for the module the validator registers. This variable contains a number of active validators the module manages.

But, to make a validator active, it is necessary to call the provisionNode(...) function with a signed message from guardians. However, guardians can also skip provisioning to skip the pending validator. This is done in the function skipProvisioning(...).

During the execution of skipProvisioning(...), the numberOfActiveValidators is not decreased, leading to inconsistency between the number of active validators and the number stored in that variable.

Recommendation

Decrease numberOfActiveValidators during a calll of skipProvisioning(...).

Resolution

Added the logic to decrease the number of active validators in skip provisioning.

6.9 Changing the daily withdrawal limit resets daily withdrawals

FileFix commitTypeStatus
PufferVaultV2.sol—InfoAcknowledged

In PufferVaultV2, a daily withdrawal limit is set by the DAO. Users cannot exceed this limit within a day. The daily withdrawn amount will be reset when a new day begins.

When the DAO uses setDailyWithdrawalLimit(...), it also resets daily withdrawals by invoking _resetDailyWithdrawals(...). This action resets the withdrawn amount even before the day ends.

Consider the scenario

1. The current withdrawal limit is 10 ETH and the assets withdrawn today total 5 ETH; 2. The DAO then uses setDailyWithdrawalLimit(...) to lower the withdrawal limit to 5 ETH; 3. Users should not be able to withdraw more assets since the new limit (5 ETH) has been reached. However, because setDailyWithdrawalLimit(...) also resets the daily withdrawal amount, users can withdraw an additional 5 ETH;

Recommendation

Consider avoiding the use of _resetDailyWithdrawals(...) during setDailyWithdrawalLimit(...).

Resolution

This is the expected behaviour. The recommendation is similar to the the original implementation, however after the priori audit, the daily limit is restarted after the update.

6.10 Disabling function depositToEigenLayer(...) in PufferVaultV2

FileFix commitTypeStatus
PufferVaultV2.sol—InfoFixed

In the new version of PufferVault, the protocol is transitioning to native staking. The team plans to convert all stETH to ETH for node provisioning within the Puffer protocol. Therefore, the function depositToEigenLayer(...) is no longer necessary as it deposits stETH to EigenLayer rather than converting them to ETH.

Recommendation

Disable the function depositToEigenLayer(...) by overriding it in PufferVaultV2.

Resolution

Override the function to disable the code

6.11 Duplicate code

FileFix commitTypeStatus
GuardianModule.sol
PufferProtocol.sol
—InfoFixed

Certain functions in the codebase contain duplicated code.

  • In the constructor, the first if condition is repeated:;
constructor(IEnclaveVerifier verifier, address[] memory guardians, uint256 threshold, address pufferAuthority)
payable
AccessManaged(pufferAuthority)
{
// @audit - This `if` is repeated twice
if (address(verifier) == address(0)) {
revert InvalidAddress();
}
if (address(verifier) == address(0)) {
revert InvalidAddress();
}
...
}
  • In batchHandleWithdrawals(...), the function _getVTBurnAmount(...) is called three times with the same input parameters to calculate the same value for each validator;
burnAmounts.vt += _getVTBurnAmount(validatorInfos[I]);
...
emit ValidatorExited({
vtBurnAmount: _getVTBurnAmount(validatorInfos[I])
});
...
$.nodeOperatorInfo[validator.node].vtBalance -= SafeCast.toUint96(_getVTBurnAmount(validatorInfos[i]));

Recommendation

Refactoring is suggested to eliminate duplicate code.

Resolution

Removed the duplicate code

6.12 Function addGuardian(...) does not check if the address to be added as a Guardian is an EOA

FileFix commitTypeStatus
GuardianModule.sol—InfoAcknowledged

The Guardians must be EOA but the addGuardian(...) function does not validate if the address to be added is a contract address or zero address, before adding it as a Guardian.

function addGuardian(address newGuardian) external restricted {
splitGuardianFunds();
_addGuardian(newGuardian);
}

This could be an issue in a scenario where the contract added as Guardian is unable or its administrator is unwilling to perform its duties as a Guardian. Additionally, it could receive funds that would potentially be locked into the contract forever.

Recommendation

Consider implementing checks to confirm the guardian address is an EOA. For instance, require the guardian to sign a message and validate the signature during the addition process.

Resolution

Given that the guardians are permissioned, we will add this check to the off-chain components to make sure the addresses are EOA before adding them, and if we ever want to support multisig/smartcontract guardians we can check accordingly.

6.13 Inappropriate names for functions and variables

FileFix commitTypeStatus
ProtocolStorage.sol
PufferModule.sol
—InfoFixed

Some functions and variables have potentially misleading names.

  • The parameter name numberOfActiveValidators in the ModuleLimit struct is confusing. It only increments in the _storeValidatorInformation(...) function of the PufferProtocol contract when registerValidatorKey(...) is called. However, registering a validator only adds a pending validator to the module, rather than activating a validator. Thus, this parameter should be named numberOfValidators or numberOfRegisteredValidators. When renaming the variable, it’s essential to ensure that the following event tied to this variable is also updated accordingly;
event NumberOfActiveValidatorsChanged(bytes32 indexed moduleName, uint256 newNumberOfActiveValidators);
  • The function _getPufferProtocolStorage(...) in PufferModule would be more accurately named _getPufferModuleStorage(...);

Recommendation

Consider renaming these functions and variables to the suggested names.

Resolution

Renamed to reflect accurate functionality

6.14 Invariant violation in function setValidatorLimitPerModule(...)

FileFix commitTypeStatus
PufferProtocol.sol—InfoFixed

In the function setValidatorLimitPerModule(...) that calls the internal function _setValidatorLimitPerModule(...), the maximum allowed limit of validators per module is set without verifying that the new limit is not less than the current number of validators. This could break the internal coherence of the system.

function _setValidatorLimitPerModule(bytes32 moduleName, uint128 limit) internal {
ProtocolStorage storage $ = _getPufferProtocolStorage();
emit ValidatorLimitPerModuleChanged($.moduleLimits[moduleName].allowedLimit, limit);
$.moduleLimits[moduleName].allowedLimit = limit;
}

Recommendation

Consider adding a validation before setting the new limit, to prevent it from being set to a value lower than the current number of validators.

Resolution

Added the check to revert if limit is reached

6.15 Lack of slippage protection when purchasing validator ticket

FileFix commitTypeStatus
ValidatorTicket.sol—InfoAcknowledged

The price of the validator ticket can be changed in PUFFER_ORACLE. However, the function purchaseValidatorTicket(...) does not have slippage protection, potentially leading to purchases at unfavorable prices.

function purchaseValidatorTicket(address recipient) // @audit No slippage protection
...
{
ValidatorTicket storage $ = _getValidatorTicketStorage();

uint256 mintPrice = PUFFER_ORACLE.getValidatorTicketPrice();
...
}

Recommendation

Consider allowing the caller to specify a minimum number of validator tickets he/she wants to receive for this purchase.

Resolution

Acknowledged

6.16 Missing input validations

FileFix commitTypeStatus
PufferProtocol.sol
EnclaveVerifier.sol
—InfoFixed

Several parts of the code do not implement proper input validations. It is good practice to perform input validation to mitigate human errors and other issues.

  • There is no validation in the PufferProtocol constructor for type address and contract parameters before setting their value. This parameter could be set to an External Owned Account (EOA) address or a zero address. The impact is mitigated by the fact that the execution corresponds to the deployer role. Consider adding a condition to check the input value of these address parameters;
  • In the initialize(...) function of the PufferProtocol contract, accessManager is not validated. It can be set to a zero address;
  • node address in the depositValidatorTickets(...) function can be any address, even zero. In this case, the vtBalance can be updated to an invalid node address;
  • In the constructor of the EnclaveVerifier contract, accessManager isn’t checked for a zero address and freshnessBlocks isn’t checked for a valid number;
  • In the changeMinimumVTAmount(...) function, there are no checks on the value of the newMinimumVTAmount parameter, which could allow it to be set by mistake to zero or a very low value that could impact the behaviour of the protocol, for example, allowing the registration of validators without validator tickets. The impact is mitigated by the fact that the function must be called only by the guardians of the DAO. Consider adding a validation on the minimum value to set. Additionally, consider adding validation to ensure the new value differs from the old one so it is not written to storage unless necessary;
  • In the _setVTPenalty(...) function, there is no upper bound for the newPenaltyAmount. It should be checked to be less than the minimum VT amount;

Recommendation

Consider validating the inputs according to the above recommendations.

Resolution

Not 100% resolved because of the compiler issues. PR #224

6.17 Module is not validated to have a name different than NO_VALIDATORS

FileFix commitTypeStatus
PufferProtocol.sol—InfoFixed

The name NO_VALIDATORS is specifically reserved to return when no available validator is found in the function getNextValidatorToProvision(...). However, when a new module is created, there is no verification to ensure its name isn’t NO_VALIDATORS.

// No validators found
return (bytes32("NO_VALIDATORS"), type(uint256).max);

Recommendation

Consider adding a check to the function _createPufferModule(...) to ensure the moduleName isn’t NO_VALIDATORS.

Resolution

PR #224

6.18 Slasher is not implemented in the upgraded version of EigenLayer contracts

FileFix commitTypeStatus
RestakingOperator.sol—InfoAcknowledged

The Puffer protocol strongly depends on the external protocol EigenLayer. Therefore, it is necessary to monitor all changes within EigenLayer’s codebase. The first version of EigenLayer contracts is currently deployed on the Ethereum mainnet. However, a new upgraded version has already been deployed on the testnet, highlighting the coming upgrade.

A Puffer protocol already uses the functionality of the upgraded contracts. But there are still some notes to consider:

  • The upgraded version of EigenLayer contracts does not implement Slasher;

- From EigenLayer documentation: _ The Slasher contract is under active development and its interface expected to change. We recommend writing slashing logic without integrating with the Slasher at this point in time. Although the Slasher is deployed, it will remain completely paused/unusable during M2. No contracts interact with it, and its design is not finalized. _ [ 1]

  • PufferVault.sol, inherited by PufferVaultV2.sol, uses functionality from the currently deployed version and will not work after the upgrade;

Recommendation

Monitor all changes of EigenLayer contracts and upgrade Puffer contracts if necessary.

Resolution

Acknowledged

6.19 Unnecessary usage of _disableInitializers() in the constructor of PufferDepositorV2

FileFix commitTypeStatus
PufferDepositorV2—InfoFixed

The _disableInitializers() method is invoked within the constructor of the PufferDepositorV2 contract, despite the contract lacking any initialize(...) functions.

constructor(PufferVaultV2 pufferVault, IStETH stETH) payable {
PUFFER_VAULT = pufferVault;
_ST_ETH = stETH;
_disableInitializers();
}

Recommendation

Consider removing the _disableInitializers() call from the constructor, or alternatively, consider adding an initialize function if necessary.

Resolution

Removed unnecessary _disableInitializers

6.20 Incorrect comments about ValidatorTicket fee

FileFix commitTypeStatus
ValidatorTicket.sol—Best PracticesFixed

The _BASIS_POINT_SCALE for the ValidatorTicket fee is 1e4, but the comment incorrectly refers to 100% = 1e18.

uint256 private constant _BASIS_POINT_SCALE = 1e4;
...
toSend = amount.mulDiv(rate, _BASIS_POINT_SCALE, Math.Rounding.Ceil);


struct ValidatorTicket {
/**
* @dev Protocol fee rate, can be updated by governance (1e20 = 100%, 1e18 = 1%)
* Slot 0
*/
uint128 protocolFeeRate;
/**
* @dev Guardians fee rate, can be updated by governance (1e20 = 100%, 1e18 = 1%)
* Slot 0
*/
uint128 guardiansFeeRate;
}

Recommendation

Correct the comment about the ValidatorTicket fee.

Resolution

Fixed the comments

6.21 Lack of _disableInitializers() in some upgradable contracts

FileFix commitTypeStatus
RestakingOperator.sol
PufferModuleManager.sol
—Best PracticesFixed

The RestakingOperator and PufferModuleManager contracts are designed to be upgradable and utilize the OpenZeppelin Initializable and UUPSUpgradeable APIs. However, they failed to lock the implementation contract after deployment. This oversight allows for the possibility that an attacker could frontrun the initialize function, potentially seizing control of the implementation contract.

Recommendation

In the context of upgradable contracts, OpenZeppelin advises calling the specific function within the constructor as a best practice. It’s recommended to include a call to _disableInitializers() in the constructors of both contracts.

Resolution

Added _disableInitializer() to both contracts.

6.22 Unnecessary cast to uint56 when setting price

FileFix commitTypeStatus
PufferOracleV2.sol—Best PracticesFixed

The data type of _validatorTicketPrice is uint256. Nevertheless, the value is always cast to uint56 before it’s set. This is unnecessary and may result in slightly higher gas consumption.

uint256 internal _validatorTicketPrice;

_setMintPrice(uint56(0.01 ether));

Recommendation

Consider eliminating the value casting when setting the price.

Resolution

Leftover from old code, fixed by removing the unnecessary casting

6.23 Unnecessary external call to get deposit data root

FileFix commitTypeStatus
PufferProtocol.sol—Best PracticesFixed

The function _validateSignaturesAndProvisionValidator(...) makes an external call to a function of the PufferProtocol contract to get the deposit data root. However, this is unnecessary and results in wasted gas.

bytes32 depositDataRoot = this.getDepositDataRoot({ // @audit No need external call
pubKey: validatorPubKey,
signature: validatorSignature,
withdrawalCredentials: withdrawalCredentials
});

Recommendation

Consider using LibBeaconchainContract directly to get the deposit data root.

Resolution

Using internal call to LibBeaconchainContract.getDepositDataRoot instead of an external call.

f8f4ffc

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 Puffer team has provided comprehensive documentation about their protocol. This includes their Protocol docs, comments throughout the codebase and /docs folder in the repository. These documents detail the overall architecture of Puffer contracts and each component. Additionally, the Puffer team was available to address any questions or concerns from the Nethermind auditors.

8.1.1 PufferPool

8.1.2 pufETH

8.2.1 PufferPool

8.2.2 pufETH

Remarks about Puffer test suite

The Puffer team has diligently crafted test suites that encapsulate the fundamental workflows for interacting with the protocol. It is worth acknowledging that the test suite is currently not comprehensive enough to encompass certain edge cases and functionalities, as evidenced by some noticeable issues that should be easily caught by unit tests. These areas may seem straightforward in terms of the application’s behaviour, yet it remains a best practice to include them for a robust test suite.

Test suite
166Tests passed0Failed

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.