Download audit report
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 Type | Security Review |
| Initial Report | Apr 12, 2024 |
| Final Report | Apr 16, 2024 |
| Methods | Manual Review, Automated analysis |
| Repository | PufferPool & pufETH |
| Commit Hash (Initial Audit - PufferPool) | 0c60cef014 |
| Commit Hash (Initial Audit - pufETH) | 1b8ec764c1 |
| Final Commit Hash (PufferPool) | 2c25db3cc7 |
| Final Commit Hash (pufETH) | a510fd5924 |
| Documentation | Protocol docs |
| Documentation Assessment | High |
| Test Suite Assessment | Medium |
Findings by severity
| # | Contract | LoC | Comments | Ratio | Blank | Total |
| 1 | PufferVaultV2.sol | 275 | 174 | 63.3% | 71 | 520 |
| 2 | PufferDepositorV2.sol | 60 | 23 | 38.3% | 13 | 96 |
| Total | 335 | 197 | 58.8% | 84 | 616 |
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
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
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.
PufferPool is the core of the Puffer protocol, primarily handling interactions with node operators. The audit scope includes all contracts in this repository:
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.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.
provisionNode(...) to overwrite withdrawal credential| File | Fix commit | Type | Status |
PufferProtocol.sol | — | High | Fixed |
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
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.
| File | Fix commit | Type | Status |
LibGuardianMessages.sol | — | Medium | Acknowledged |
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;| File | Fix commit | Type | Status |
ValidatorTicket.sol | — | Medium | Fixed |
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
sharesWithdrawn| File | Fix commit | Type | Status |
PufferModuleManager.sol | — | Low | Fixed |
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
| File | Fix commit | Type | Status |
PufferProtocol.sol | — | Low | Fixed |
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.
| File | Fix commit | Type | Status |
GuardianModule.sol | — | Low | Fixed |
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
34162f9;| File | Fix commit | Type | Status |
PufferProtocol.sol | — | Low | Acknowledged |
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:
setModuleWeights([E]) to save the gas costs and prioritizes E module selection;setValidatorLimitPerModule(bytes32 moduleName, uint128 limit) to prevent new registrations on any module that is over populated;numberOfActiveValidators variable is not updated when skipProvisioning(...) is called| File | Fix commit | Type | Status |
PufferProtocol.sol | — | Low | Fixed |
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.
| File | Fix commit | Type | Status |
PufferVaultV2.sol | — | Info | Acknowledged |
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.
depositToEigenLayer(...) in PufferVaultV2| File | Fix commit | Type | Status |
PufferVaultV2.sol | — | Info | Fixed |
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
| File | Fix commit | Type | Status |
GuardianModule.solPufferProtocol.sol | — | Info | Fixed |
Certain functions in the codebase contain duplicated code.
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();
}
...
}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
addGuardian(...) does not check if the address to be added as a Guardian is an EOA| File | Fix commit | Type | Status |
GuardianModule.sol | — | Info | Acknowledged |
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.
| File | Fix commit | Type | Status |
ProtocolStorage.solPufferModule.sol | — | Info | Fixed |
Some functions and variables have potentially misleading names.
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);_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
setValidatorLimitPerModule(...)| File | Fix commit | Type | Status |
PufferProtocol.sol | — | Info | Fixed |
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
| File | Fix commit | Type | Status |
ValidatorTicket.sol | — | Info | Acknowledged |
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
| File | Fix commit | Type | Status |
PufferProtocol.solEnclaveVerifier.sol | — | Info | Fixed |
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.
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;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;EnclaveVerifier contract, accessManager isn’t checked for a zero address and freshnessBlocks isn’t checked for a valid number;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;_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
NO_VALIDATORS| File | Fix commit | Type | Status |
PufferProtocol.sol | — | Info | Fixed |
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
| File | Fix commit | Type | Status |
RestakingOperator.sol | — | Info | Acknowledged |
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:
- 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
_disableInitializers() in the constructor of PufferDepositorV2| File | Fix commit | Type | Status |
PufferDepositorV2 | — | Info | Fixed |
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
| File | Fix commit | Type | Status |
ValidatorTicket.sol | — | Best Practices | Fixed |
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
_disableInitializers() in some upgradable contracts| File | Fix commit | Type | Status |
RestakingOperator.solPufferModuleManager.sol | — | Best Practices | Fixed |
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.
uint56 when setting price| File | Fix commit | Type | Status |
PufferOracleV2.sol | — | Best Practices | Fixed |
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
| File | Fix commit | Type | Status |
PufferProtocol.sol | — | Best Practices | Fixed |
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.
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 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.
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.
| 166Tests 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