Introduction
We express our gratitude to the LeechProtocol team for the collaborative engagement that enabled the execution of this Smart Contract Security Assessment.
Leech Protocol allows users to easily farm on multiple chains. They deposit their liquidity into Leech Protocol, which then performs operations that the user would normally do manually. Leech has incorporated protocols like Curve, PancakeSwap, Uniswap, etc. with specific liquidity pairs that are monitored.
title | content |
---|---|
Platform | BNB Chain, Avalanche, Optimism |
Language | Solidity |
Tags | ERC20 token, Yield Aggregator |
Timeline | 15/07/2023 - 17/08/2023 |
Methodology | https://hackenio.cc/sc_methodology→ |
Review Scope | |
---|---|
Repository | https://github.com/Leech-Protocol/leech-contracts/tree/feature/dev-aud→ |
Commit | f1019667115308f0945d38120d9af9c88c853501 |
Review Scope
- Commit
- f1019667115308f0945d38120d9af9c88c853501
Audit Summary
10/10
100%
10/10
10/10
The system users should acknowledge all the risks summed up in the risks section of the report
Document Information
This report may contain confidential information about IT systems and the intellectual property of the Customer, as well as information about potential vulnerabilities and methods of their exploitation.
The report can be disclosed publicly after prior consent by another Party. Any subsequent publication of this report shall be without mandatory consent.
Document | |
---|---|
Name | Smart Contract Code Review and Security Analysis Report for LeechProtocol |
Audited By | Hacken |
Changelog | 31/07/2023 – Initial Review |
09/08/2023 - Second Review | |
17/08/2023 - Third Review |
Document
- Name
- Smart Contract Code Review and Security Analysis Report for LeechProtocol
- Audited By
- Hacken
- Changelog
- 31/07/2023 – Initial Review
- 09/08/2023 - Second Review
- 17/08/2023 - Third Review
System Overview
Leech Protocol is a cross-chain yield aggregator. It allows users to deposit funds into different pools with underlying yield-generating strategies. It has the following contracts:
LeechRouterOptimism — a contract that users use to make deposits and withdrawals to preferred pools.
LeechRouterBase — The Router is the main protocol contract, for user interactions and protocol automatizations.
StrategyVelodrome — FarmLeech Protocol farming strategy for Velodrome.
BaseFarmStrategy — Base farming strategy.
Helpers — Leech Protocol helpers and utilities.
Privileged roles
BaseFarmStrategy and StrategyVelodromeFarm are using OwnableUpgradeable to restrict access. Contract owner can:
Sets paths for token swap.
Sets fee taken by the Leech protocol.
Sets the treasury address.
Sets the controller address.
Sets slippage tolerance.
LeechRouterBase and LeechRouterOptimism are using AccessControlUpgradeable to restrict access. Addresses with ADMIN_ROLE
can:
Move liquidity to the new strategy.
Move liquidity to another blockchain.
Change strategy.
Change address of validator, finalizer, transporter and treasury.
Set a new pool, strategy and router.
Set withdrawal delay.
Unpause contract.
Change Uniswap based router.
Ban and unban given address.
Set deposit token and minimal value that should be deposited.
Addresses with PAUSER_ROLE
can pause a contract.
Executive Summary
Documentation quality
The total Documentation quality score is 10 out of 10.
Functional requirements are provided.
Technical description is provided.
Code quality
The total Code quality score is 10 out of 10.
The code follows style guides and best practices.
The development environment is configured.
Test coverage
Code coverage of the project is 100% (branch coverage).
Security score
Upon auditing, the code was found to contain 1 critical, 1 high, 4 medium, and 4 low severity issues. Out of these, 8 issues have been addressed and resolved, leading to a security score of 10 out of 10.
All identified issues are detailed in the “Findings” section of this report.
Summary
The comprehensive audit of the customer's smart contract yields an overall score of 10. This score reflects the combined evaluation of documentation, code quality, test coverage, and security aspects of the project.
Risks
Iterating over a dynamic array populated with custom tokenId can lead to Gas limit denial of service if the number of tokenId goes out of control.
The multisig ADMIN role can perform migrations at any time without restrictions. This is part of the business logic of the protocol.
Findings
Code ― | Title | Status | Severity | |
---|---|---|---|---|
F-2023-1269 | Signed Message Replay Attack | mitigated | Critical | |
F-2023-127 | Front-Running; Sandwich Attack | fixed | High | |
F-2023-127 | Highly Permissive Admin Access | mitigated | Medium | |
F-2023-1274 | Uninitialized Implementation | fixed | Medium | |
F-2023-127 | Redundant Modifier | fixed | Medium | |
F-2023-127 | Missing Validation | fixed | Medium | |
F-2023-1279 | Funds Lock | fixed | Low | |
F-2023-1278 | Missing Events | fixed | Low | |
F-2023-127 | Redundant Import | fixed | Low | |
F-2023-1276 | Missing Zero Address Validation | fixed | Low |
Identify vulnerabilities in your smart contracts.
Appendix 1. Severity Definitions
When auditing smart contracts, Hacken is using a risk-based approach that considers Likelihood, Impact, Exploitability and Complexity metrics to evaluate findings and score severities.
Reference on how risk scoring is done is available through the repository in our Github organization:
Severity | Description |
---|---|
Critical | Critical vulnerabilities are usually straightforward to exploit and can lead to the loss of user funds or contract state manipulation. |
High | High vulnerabilities are usually harder to exploit, requiring specific conditions, or have a more limited scope, but can still lead to the loss of user funds or contract state manipulation. |
Medium | Medium vulnerabilities are usually limited to state manipulations and, in most cases, cannot lead to asset loss. Contradictions and requirements violations. Major deviations from best practices are also in this category. |
Low | Major deviations from best practices or major Gas inefficiency. These issues will not have a significant impact on code execution, do not affect security score but can affect code quality score. |
Severity
- Critical
Description
- Critical vulnerabilities are usually straightforward to exploit and can lead to the loss of user funds or contract state manipulation.
Severity
- High
Description
- High vulnerabilities are usually harder to exploit, requiring specific conditions, or have a more limited scope, but can still lead to the loss of user funds or contract state manipulation.
Severity
- Medium
Description
- Medium vulnerabilities are usually limited to state manipulations and, in most cases, cannot lead to asset loss. Contradictions and requirements violations. Major deviations from best practices are also in this category.
Severity
- Low
Description
- Major deviations from best practices or major Gas inefficiency. These issues will not have a significant impact on code execution, do not affect security score but can affect code quality score.
Appendix 2. Scope
The scope of the project includes the following smart contracts from the provided repository:
Scope Details | |
---|---|
Repository | https://github.com/Leech-Protocol/leech-contracts/tree/feature/dev-aud→ |
Commit | f1019667115308f0945d38120d9af9c88c853501 |
Whitepaper | Provided→ |
Requirements | Provided |
Technical Requirements | Provided |
Scope Details
- Commit
- f1019667115308f0945d38120d9af9c88c853501
- Whitepaper
- Provided→
- Requirements
- Provided
- Technical Requirements
- Provided