Download audit report
This document presents the security review performed by Nethermind Security for Lagoon factory contract. Lagoon Protocol is a decentralized asset management platform that enables asset managers to create Lagoon Vaults. These Vaults provide efficient, non-custodial, and risk-managed asset management solutions.
Built on a foundation of smart contract standards, Lagoon Protocol leverages the power of Gnosis Safe, Zodiac Roles Modifier, and other key components to create highly customizable and secure vaults for managing digital assets.
The audit focuses on the PR #200 which introduces new features like synchronous deposits and a burn functionality. The audit was performed using (a) manual analysis of the codebase, (b) automated analysis tools, and (c) creation of test cases.
| Audit assessment | |
| Audit Type | Security Review |
| Initial Report | May 9, 2025 |
| Final Report | May 13, 2025 |
| Repository | lagoon-v0 |
| Commit | 84e43bf30c |
| Final Commit | ca04ed2b51 |
| Documentation Assessment | Medium |
| Test Suite Assessment | Medium |
Findings by severity
| # | Contract | LoC | Comments | Ratio | Blank | Total |
| 1 | src/v0.5.0/Roles.sol | 70 | 36 | 51.4% | 13 | 119 |
| 2 | src/v0.5.0/Whitelistable.sol | 61 | 23 | 37.7% | 11 | 95 |
| 3 | src/v0.5.0/Silo.sol | 14 | 4 | 28.6% | 5 | 23 |
| 4 | src/v0.5.0/FeeManager.sol | 146 | 73 | 50.0% | 43 | 262 |
| 5 | src/v0.5.0/ERC7540.sol | 447 | 170 | 38.0% | 129 | 746 |
| 6 | src/v0.5.0/Vault.sol | 313 | 137 | 43.8% | 62 | 512 |
| 7 | src/v0.5.0/primitives/Errors.sol | 22 | 33 | 150.0% | 26 | 81 |
| 8 | src/v0.5.0/primitives/Events.sol | 34 | 50 | 147.1% | 22 | 106 |
| 9 | src/v0.5.0/primitives/Enums.sol | 6 | 2 | 33.3% | 3 | 11 |
| 10 | src/v0.5.0/primitives/Struct.sol | 16 | 12 | 75.0% | 4 | 32 |
| 11 | src/v0.5.0/interfaces/IERC7540.sol | 9 | 2 | 22.2% | 5 | 16 |
| 12 | src/v0.5.0/interfaces/IWETH9.sol | 8 | 4 | 50.0% | 3 | 15 |
| 13 | src/v0.5.0/interfaces/IERC7540Deposit.sol | 16 | 8 | 50.0% | 7 | 31 |
| 14 | src/v0.5.0/interfaces/IERC7540Redeem.sol | 10 | 1 | 10.0% | 5 | 16 |
| 15 | src/v0.5.0/interfaces/IERC7575.sol | 5 | 2 | 40.0% | 2 | 9 |
| Total | 1177 | 557 | 47.3% | 340 | 2074 |
*Only features introduced in PR #200.
The recent protocol modifications introduce notable changes to existing vault processes and enable new avenues for user interaction. Key updates include:
totalAssetsLifespan state variable; synchronous deposits are enabled immediately following a NAV settlement and remain permissible for the duration specified by totalAssetsLifespan. This mechanism allows users to deposit assets at the prevailing share price and receive their corresponding shares without delay. Upon a synchronous deposit, the contributed assets are transferred into the safe, and the vault's totalAssets variable is increased to reflect this addition.totalAssetsLifespan post-settlement), requestDeposit(...) will now preferentially execute an immediate synchronous deposit rather than creating an asynchronous deposit request.totalSupply of shares in circulation.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 |
src/v0.5.0/Vault.sol | — | High | Fixed |
The requestDeposit(...) function is designed to handle deposits, including those made with native tokens (e.g., ETH). A recent modification causes requestDeposit(...) to fallback to an internal synchronous deposit mechanism, _syncDeposit(...), if synchronous deposits are enabled in the vault.
The vulnerability arises because _syncDeposit(...) is exclusively designed to handle ERC20 token deposits and does not account for msg.value if the initial call to requestDeposit(...) was made with native tokens.
The relevant internal _syncDeposit(...) logic is:
function _syncDeposit(...) internal onlyOpen returns (uint256 shares) {
ERC7540Storage storage $ = _getERC7540Storage();
shares = _convertToShares(assets, Math.Rounding.Floor);
$.totalAssets += assets;
SafeERC20.safeTransferFrom(IERC20(asset()), owner, safe(), assets);
_mint(receiver, shares);
emit DepositSync(msg.sender, receiver, assets, shares);
}If a user tries to execute a native token deposit through requestDeposit(...) and synchronous deposits are available the native tokens sent wont be taken into account through the deposit operation.
Recommendation
Consider modifying _syncDeposit(...) to manage native token deposits.
Resolution
We added the native token deposit to the syncDeposit(...) function.
Update from Nethermind Security
The issue is fixed in commit 85ab53.
NAV proposals may disregard increases to totalAssets from synchronous deposits| File | Fix commit | Type | Status |
src/v0.5.0/ERC7540.sol | — | Medium | Mitigated |
The totalAssets variable within the ERC7540 contract, which is critical for share price calculation, is updated through two distinct mechanisms:
totalAssets variable is set to the newTotalAssets value proposed by the NAV committee based on their off-chain valuation;totalAssets to be incremented directly upon a successful deposit, reflecting the immediate inflow of new assets;A race condition vulnerability exists due to the potential timing mismatch between these two update paths. If the NAV committee performs a valuation and submits a newTotalAssets proposal before recent synchronous deposits are made (or before they are aware of them), this proposed value will not reflect the assets added by those deposits.
When a settlement subsequently occurs, the totalAssets variable will be overwritten with the NAV committee's proposed (and now outdated) value. This action effectively negates the totalAssets increments from any synchronous deposits that occurred between the NAV committee's valuation time and the settlement execution. While the shares minted from these synchronous deposits remain valid, the totalAssets backing them is temporarily unrepresented in the contract's state, leading to a deflated share price.
Recommendation
To address this vulnerability, it is crucial to ensure that any proposed new valuation accurately incorporates the impact of all synchronous deposits made up to the valuation point. Two primary approaches can be considered:
totalAssets is updated during NAV settlements. Instead of overwriting totalAssets with an absolute value proposed by the NAV committee, the system could be designed to apply a delta (i.e., the change in value of the managed assets, excluding synchronous deposits already accounted for on-chain). This approach would ensure that increases to totalAssets from synchronous deposits are preserved, as the NAV committee's reported change would be added to the already updated totalAssets figure, thus preventing the inadvertent exclusion of these deposited assets.Resolution
In order to solve this issue, we opted for a solution close to the operationnal safeguards. We offer the vault.safe() role (curator) the capacity to expire totalAssets. By doing so he will disable the capacity to do synchronous deposit until next complete totalAssets update, offering the ValuationManager and himself the liberty to update the valuation without risks.
Update from Nethermind Security
The issue is mitigated at commit ca04ed.
| File | Fix commit | Type | Status |
src/v0.5.0/Vault.sol | — | Low | Fixed |
The vault's share price is implicitly determined by the ratio totalAssets / totalSupply. TThe interaction between the two recently introduced features allow users to inflate the share's price:
totalAssets value and mints a corresponding number of shares to the depositor;burn(...) function allows users to destroy a specified amount of their own shares, thereby decreasing totalSupply;A malicious (whitelisted) user can exploit this by performing the following sequence:
X) into the vault. This increases totalAssets by X and mints Y shares for the attacker;burn(...) function to destroy all or a significant portion of the Y shares they just received;The consequence is that the X assets contributed by the attacker remain within the vault (increasing totalAssets, but the corresponding shares that claim those assets are removed from circulation (decreasing totalSupply). This effectively acts as a "donation" of the attacker's deposited assets to the remaining pool, concentrating the vault's total asset value over fewer shares and thereby inflating the price of each remaining share.
Artificially inflating the share price can lead to several adverse consequences. Malicious actors could exploit this vulnerability, particularly early in the vault's operation or when total share supply is low, to conduct "first deposit attacks"; this would cause subsequent legitimate depositors to receive disproportionately fewer shares for their assets, unfairly benefiting the attacker. Furthermore, if the vault's share price is utilized as an oracle by other DeFi protocols for functions like collateral valuation, this manipulation could be leveraged to deceive or exploit those external systems for an attacker's gain. Such potential for manipulation can also undermine user confidence and deter legitimate participation in the vault.
Recommendation
Reconsider the addition of the shares burning feature. The removal of this feature would remove the current possibility of donations through synchronous deposits and burn.
Resolution
We removed the capacity to burn shares.
Update from Nethermind Security
Fixed in commit d05006.
requestDeposit(...) function is inconsistent depending on the executed branch| File | Fix commit | Type | Status |
src/v0.5.0/Vault.sol | — | Info | Fixed |
The requestDeposit(...) function has been modified to serve a dual purpose: it initiates an asynchronous deposit request or, if synchronous deposits are currently available, it falls back to executing a synchronous deposit directly. This conditional branching within a single function leads to several inconsistencies in its behavior and outputs, making it more difficult for developers and integrating systems to reliably predict and handle its execution.
The observed inconsistencies include:
requestDeposit(...) returns the unique request ID associated with the pending operation.Recommendation
Consider maintaining requestDeposit(...) exclusively for asynchronous deposit requests and syncDeposit(...) for synchronous deposits.
Resolution
We gave up the "overload" of the requests functions. They will remain as before, and synchronous deposits are only possible by calling the function syncDeposit(...).
Update from Nethermind Security
Fixed in commit d05006.
syncDeposit(...) function lacks operator and referral features present in asynchronous deposits| File | Fix commit | Type | Status |
src/v0.5.0/Vault.sol | — | Info | Fixed |
The recently introduced syncDeposit(...) function enables users to perform synchronous deposits when this operational mode is active. This provides an immediate deposit pathway, contrasting with the existing asynchronous requestDeposit(...) function.
However, syncDeposit() currently does not implement two features available in the asynchronous deposit flow:
requestDeposit(...) allows for an owner parameter, distinct from msg.sender. This enables an approved operator ( msg.sender) to initiate a deposit request on behalf of the owner of the assets. The syncDeposit(...) function lacks an owner parameter; assets are taken directly from msg.sender, meaning msg.sender is always the owner of the deposited assets. Thus, the pattern of an operator depositing assets on behalf of another distinct owner is not supported;requestDeposit(...) function includes a referral parameter, allowing for on-chain tracking and potential incentivization of referrals. This parameter is absent in the syncDeposit(...) function signature and its associated logic;This difference means that users and integrated systems cannot utilize operator-based deposits or referral tracking when using the synchronous deposit method.
syncDeposit(...) function, as currently implemented, appears to be primarily designed for ERC20 token deposits and lacks a clear mechanism or explicit handling for native token deposits;Recommendation
To promote consistency and broader utility, consider aligning the feature set of syncDeposit(...) more closely with requestDeposit(...).
Resolution
We added the referral system to the syncDeposit(...) function and use 0 as the requestId. We decided not to support the "operator" feature in synchronous deposits.
Update from Nethermind Security
The Lagoon team has added the desired features. The issue is fixed at commit ca04ed.
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 Lagoon team explained the use cases and expected behavior of the newly added features.
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