Download audit report
This document presents the security review conducted by Nethermind for the ClayStack ETH Staking Contracts. ClayStack is a platform that enables ETH staking on the Ethereum blockchain. It allows users to participate in the staking process by delegating their stake to validators on the Ethereum Beacon chain. This staking process involves users locking up their ETH in exchange for a token called csETH. This csETH token represents their staked amount and is minted on the Ethereum network. The validator pool on ClayStack is managed by the platform, and those who operate and manage the validators are rewarded for their efforts. These operators can either be direct nodes or operators using a DVT based approach. In the audited version of ClayStack, validators are trusted/controlled entities that are not likely to be malicious.
This assessment focuses on the recent update to the ClayStack protocol that implements integration with the EigenLayer protocol, enabling the restaking of native ETH. Notably, registered validators can designate a withdrawal address pointing to the EigenPod contract linked with ClayStack’s NodeManager. The contract has been modified to incorporate new functions that enable the withdrawal and claiming processes directly from the EigenPod. Additionally, when oracles report the exit of a validator associated with the EigenPod, a claiming process is initiated to claim expired withdrawal requests. The claimed amount is then reflected in the validator’s balance. The node is considered exited only if all withdrawal requests have been claimed. Otherwise, it will be subtracted from the total number of exited nodes.
The audit was performed using: (a) manual analysis of the codebase, (b) automated analysis tools, and (c) simulation of the smart contracts.
| Audit assessment | |
| Audit Type | Security Review |
| Initial Report | Jan 25, 2024 |
| Final Report | Jan 25, 2024 |
| Methods | Manual Review, Automated Analysis |
| Repository | claystack-ethereum |
| Commit Hash | 0de890799f |
| Commit Hash | 184f9a9e8c |
| Documentation | Docs |
| Documentation Assessment | High |
| Test Suite Assessment | High |
Findings by severity
| # | Contract | LoC | Comments | Ratio | Blank | Total |
| 1 | src/ClayMain.sol | 571 | 170 | 29.8% | 148 | 889 |
| 2 | src/NodeManager.sol | 431 | 152 | 35.3% | 111 | 694 |
| Total | 1002 | 322 | 32.1% | 259 | 1583 |
| # | Finding | Severity | Update |
| 1 | Claiming withdrawals on EigenLayer can be done without updating internal accounting | Critical | Fixed |
| 2 | Updating Eigen Layer addresses could result in erroneous accounting | Info | Acknowledged |
No system overview is included in this report.
The risk rating methodology used by Nethermind Security follows the principles established by the OWASP Foundation. The severity of each finding is determined by two factors: Likelihood and Impact.
Likelihood measures how likely the finding is to be uncovered and exploited by an attacker. This factor will be one of the following values:
When defining the likelihood of a finding, other factors are also considered. These can include but are not limited to motive, opportunity, exploit accessibility, ease of discovery, and ease of exploit.
Impact is a measure of the damage that may be caused if an attacker exploits the finding. This factor will be one of the following values:
When defining the impact of a finding, other factors are also considered. These can include but are not limited to data and state integrity, loss of availability, financial loss, and reputation damage. After defining the likelihood and impact of an issue, the severity is determined according to the table below.
| Impact / Likelihood | Low | Medium | High |
| High | Medium | High | Critical |
| Medium | Low | Medium | High |
| Low | Info / Best Practices | Low | Medium |
| Undetermined | Undetermined | Undetermined | Undetermined |
To address issues that do not fit a High, Medium or Low severity, Nethermind Security also uses three more finding severities: Informational, Best Practices, and Undetermined.
| File | Fix commit | Type | Status |
NodeManager.sol | 184f9a9 | Critical | Fixed |
The claimEigenLayer(...) function shown below is claiming withdrawals within EigenLayer and updating the accounting in eigenLayerWithdraws variable.
function claimEigenLayer(uint256 maxNumberOfWithdrawalsToClaim) public {
uint256 balanceBefore = address(this).balance;
// @audit call to EigenLayer to claim withdrawals
eigenDelayedWithdrawalRouter.claimDelayedWithdrawals(maxNumberOfWithdrawalsToClaim);
uint256 balanceAfter = address(this).balance;
if (balanceAfter > balanceBefore) {
uint256 claimedAmount = balanceAfter - balanceBefore;
// @audit update of the internal accounting
eigenLayerWithdraws -= claimedAmount;
emit LogClaimEigenLayer(claimedAmount);
}
}However, anyone can bypass this function and execute the claim directly on EigenLayer side, by calling the claimDelayedWithdrawals(. . . ) function. This function allows the caller to claim withdrawals on behalf of a specified recipient, with the recipient address provided as an input. If the NodeManager contract address is utilized as the recipient, the claim is made on its behalf.
Consequently, the eigenLayerWithdraws variable won’t be updated, resulting in wrong accounting within the contract. Despite funds being claimed and nodes considered exited, they are still accounted for in the active validators’ balance, resulting in higher rewards.
Recommendation
Consider modifying the way the contract handles claims in EigenLayer, by moving the accounting for claimed amounts to the receive function, and filtering the funds received from the eigenDelayedWithdrawalRouter contract only.
Resolution
updated with commit: 184f9a9e8c90d19021640340a485edb8e4b68b48
| File | Fix commit | Type | Status |
NodeManager.sol | — | Info | Acknowledged |
The setEigenLayer(...) function allows updating EigenLayer related addresses. This update carries a risk of affecting the balances accounting within NodeManager contract. That is possible because, after the update, the contract loses access to the queue of pending and completed withdrawals of the current validators, in addition to the current balance of the EigenPod.
Recommendation
Before updating EigenLayer addresses in the contract, consider reviewing the status of validators and withdrawal claims in the previous router contract. Confirm that all withdrawals have been successfully claimed and all nodes are exited.
Resolution
-
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 ClayStack contracts’ documentation is presented through inline comments within the code, providing explanations for the objectives and operations of various functions and formulas. Additionally, the README file, accessible at this link, outlines the deposit and withdrawal processes and delineates different roles within the system. Furthermore, the ClayStack team remained available to address any inquiries or concerns raised by the Nethermind auditors.
The relevant output is presented below.
| 281Tests 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