Download audit report
This document presents the security review performed by Nethermind Security for the Canary staking vault contracts, which are designed to function as a restaking aggregator. The Canary team has developed two distinct vault contracts. The first vault manages ERC20 tokens, allowing administrators to deposit these assets into the Symbiotic protocol. The second vault focuses on managing ERC721 tokens.
This security review focused on the current version of the protocol, which is still under development. Notably, some features, such as the integration with Symbiotic, remain incomplete. Therefore, a follow-up audit is recommended once the protocol is fully developed and additional functionalities are introduced.
The audit was performed using (a) manual analysis of the codebase, (b) automated analysis tools, (c) simulation of the smart contract, and (d) creation of test cases.
| Audit assessment | |
| Audit Type | Security Review |
| Initial Report | Oct 17, 2024 |
| Final Report | Feb 04, 2025 |
| Repository | contracts |
| Commit (Audit) | 696df5b544 |
| Commit (Final) | a49e98aae1 |
| Documentation Assessment | Medium |
| Test Suite Assessment | Medium |
Findings by severity
| # | Contract | LoC | Comments | Ratio | Blank | Total |
| 1 | CanaryNFT.sol | 81 | 4 | 4.9% | 15 | 100 |
| 2 | clToken.sol | 18 | 3 | 16.7% | 6 | 27 |
| 3 | Vault.sol | 210 | 13 | 6.2% | 36 | 259 |
| 4 | VaultManager.sol | 100 | 6 | 6.0% | 18 | 124 |
| 5 | TokenFactory.sol | 44 | 14 | 31.8% | 16 | 74 |
| 6 | NFTVault.sol | 60 | 9 | 15.0% | 19 | 88 |
| 7 | NFTVaultManager.sol | 53 | 5 | 9.4% | 18 | 76 |
| 8 | NFTFactory.sol | 35 | 7 | 20.0% | 9 | 51 |
| Total | 601 | 61 | 10.1% | 137 | 799 |
| # | Finding | Severity | Update |
| 1 | Incorrect assignment of access control roles in Vault and NFTVault contracts | High | Fixed |
| 2 | Unnecessary safeApprove(...) call in withdrawFromSymbiotic(...) function | Info | Fixed |
| 3 | Ensure the correct number of clTokens in the Vault contract | Best Practices | Fixed |
| 4 | Integrate setWithdrawPeriod(...) functionality into initialize(...) function | Best Practices | Fixed |
Canary has implemented two types of vault contracts responsible for managing ERC20 and ERC721 assets. The primary function of the ERC20 vault is to act as a restaking aggregator, connecting with various restaking options, such as Symbiotic.
The reviewed contracts have been categorized into three main components: factories and management contracts, receipt tokens, and vaults, which will be detailed in the following sections.
The NFTFactory and TokenFactory contracts serve as factory contracts responsible for creating receipt tokens. Each receipt token is deployed via these factories as a proxy. The factory handles the proper initialization of these tokens and transfers the ownership of the proxy admin to the designated external owner.
The VaultManager and NFTVaultManager contracts operate similarly to the factories but are responsible for the complete initialization of vaults. Initially, they deploy all receipt tokens through the respective factories and subsequently deploy the vault itself, which is initialized by the manager. The vault is created as a proxy to enable upgradability. Furthermore, the MINTER role is assigned to the vault for all receipt tokens, ensuring that only the vault can mint these tokens.
Receipt tokens come in two variants based on the ERC standard: CanaryNFT, which is minted as a receipt for deposited NFTs in the NFTVault, and clToken, which is minted upon depositing ERC20 assets into the Vault contract.
Each receipt token has a designated withdrawal period, functioning as a notice period before withdrawing the underlying asset from the vault. Each Vault manages three distinct clToken types, each associated with different withdrawal periods: 7 days, 30 days, and 90 days. The NFTVault, however, issues only a single type of CanaryNFT with a 7-day withdrawal period.
All receipt tokens are also pausable, allowing the protocol to halt the transfer of these tokens if needed.
The vaults are categorized into two types: the Vault contract, responsible for managing ERC20 assets, and the NFTVault for handling ERC721 assets. Each vault is designed to manage only one underlying token.
The vault architecture is consistent across both types. Users can deposit the underlying assets via the stake(...) function. For the NFTVault, users specify the tokenId, and in return, they receive a receipt token corresponding to the same tokenId. In the case of the Vault, users specify the amount of ERC20 tokens they wish to deposit along with the index of the clToken they want to receive as receive.
// NFTVault.sol function:
function stake(uint256 tokenId) external;
// Vault.sol function:
function stake(uint256 underlyingAmount, uint256 index) external; When a user decides to withdraw their underlying asset, they must call the requestWithdraw(...) function, which initiates a withdrawal request and burns the user's receipt token. Once the withdrawal period associated with the receipt token has elapsed, the user can finalize the process by calling the claimWithdraw(...) function to retrieve their asset.
// NFTVault.sol functions:
function requestWithdraw(uint256 tokenId) external;
function claimWithdraw(uint256 tokenId) external;
// Vault.sol functions:
function requestWithdraw(uint256 amount, uint256 index) external;
function claimWithdraw(uint256 index) external; The Vault contract is designed to function as a restaking aggregator, meaning it has the capability to interact with restaking protocols. To facilitate this, the vault introduces two functions that allow administrators with the SYMBIOTIC_ROLE to deposit and withdraw assets from the Symbiotic vault.
function depositIntoSymbiotic(uint256 amount) public onlyRole(SYMBIOTIC_ROLE)
function withdrawFromSymbiotic(uint256 amount) public onlyRole(SYMBIOTIC_ROLE)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.
Vault and NFTVault contracts| File | Fix commit | Type | Status |
Vault.solNFTVault.sol | a49e98a | High | Fixed |
The Vault and NFTVault contracts inherit from AccessControlEnumerableUpgradeable, which implements a role-based access control model. Critical roles, including DEFAULT_ADMIN_ROLE for both contracts and SYMBIOTIC_ROLE in the Vault contract, are assigned during the initialize(...) function. These roles are automatically granted to the msg.sender.
However, because the vaults are instantiated and initialized by a manager contract, the msg.sender at the time of the initialize(...) call is the manager contract itself. As a result, the privileged roles are inadvertently assigned to the manager contract, rather than an external account. This misconfiguration prevents privileged accounts from accessing or using certain privileged functions (e.g., depositIntoSymbiotic(...)).
Recommendation
Ensure that privileged roles are correctly assigned to external accounts.
safeApprove(...) call in withdrawFromSymbiotic(...) functionIn the withdrawFromSymbiotic(...) function, the Vault withdraws its underlying assets from the Symbiotic vault. The current implementation includes safeApprove(...) call before invoking the withdraw(...) function:
function withdrawFromSymbiotic(uint256 amount) public onlyRole(SYMBIOTIC_ROLE) {
// ...
// Approve symbioticVault to spend the vault's shares
symbioticVault_.safeApprove(address(symbioticVault_), amount); // @audit can be deleted
symbioticVault_.withdraw(address(this), amount);
// ...
}The withdraw(...) function in the Symbiotic vault contract (Default Collateral Contract) does not require approval. It burns the user's shares directly via its internal _burn(...) function, making the safeApprove(...) call redundant.
Recommendation
Remove the unnecessary safeApprove(...) call to avoid redundant operations.
clTokens in the Vault contractThe Vault contracts are designed to maintain exactly three clTokens with different withdrawal periods: 7 days, 30 days, and 90 days. However, the current check in the initialize(...) function only verifies that at least one token is provided:
if (_clTokens.length == 0) {
revert AtLeastOneCLTokenAddressMustBeProvided();
}This check does not enforce the intended requirement of having exactly three tokens.
Recommendation
Update the check in the initialize(...) function to ensure that exactly three clTokens are provided during initialization.
setWithdrawPeriod(...) functionality into initialize(...) function| File | Fix commit | Type | Status |
CanaryNFT.solclToken.sol | a49e98a | Best Practices | Fixed |
The setWithdrawPeriod(...) function is designed to set the withdrawPeriod during the deployment process, and it is called only once in factory contracts. Since this value is only set once, it would be more efficient to handle the assignment directly within the initialize(...) function.
In its current design, the setWithdrawPeriod(...) function can still be called on the implementation contract. While this doesn’t introduce a security risk, it creates conflicts with the intent of the _disableInitializers() function, which is meant to prevent initialization.
Recommendation
Consider removing the setWithdrawPeriod(...) function and incorporating the assignment of the withdrawPeriod within the initialize(...) function.
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 Canary contracts lack comprehensive documentation and NatSpec comments in some parts of the code, which made certain sections challenging to understand. However, the Canary team effectively addressed the concerns and questions raised by the Nethermind Security team during regular calls.
Remarks about Canary test suite
The Canary team has developed a testing suite that covers the basic flows of the protocol, including deposits, withdrawals, and various privileged actions. However, the protocol should always ensure that user impersonation is properly handled in the tests, as incorrect implementation of these tests led to a severe issue within the protocol.
| 48Tests 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