Q1 2025 Web3 Security ReportAccess control failures led to $1.63 billion in losses
Discover report insights
  • Hacken
  • Audits
  • leechprotocol
  • [SCA] Leech Protocol / ERC20 / Aug2023

LeechProtocol

Audit name:

[SCA] Leech Protocol / ERC20 / Aug2023

Date:

Aug 18, 2023

Table of Content

Introduction
Audit Summary
Document Information
System Overview
Executive Summary
Risks
Findings
Appendix 1. Severity Definitions
Appendix 2. Scope
Disclaimer

Want a comprehensive audit report like this?

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.

titlecontent
PlatformBNB Chain, Avalanche, Optimism
LanguageSolidity
TagsERC20 token, Yield Aggregator
Timeline15/07/2023 - 17/08/2023
Methodologyhttps://hackenio.cc/sc_methodology

    Review Scope

    Repositoryhttps://github.com/Leech-Protocol/leech-contracts/tree/feature/dev-aud
    Commitf1019667115308f0945d38120d9af9c88c853501

    Audit Summary

    Total10/10
    Security Score

    10/10

    Test Coverage

    100%

    Code Quality Score

    10/10

    Documentation Quality Score

    10/10

    17Total Findings
    13Resolved
    0Accepted
    2Mitigated

    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

    NameSmart Contract Code Review and Security Analysis Report for LeechProtocol
    Audited ByHacken
    Changelog31/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-1269Signed Message Replay Attack
    mitigated

    Critical
    F-2023-127 Front-Running; Sandwich Attack
    fixed

    High
    F-2023-127Highly Permissive Admin Access
    mitigated

    Medium
    F-2023-1274Uninitialized Implementation
    fixed

    Medium
    F-2023-127Redundant Modifier
    fixed

    Medium
    F-2023-127Missing Validation
    fixed

    Medium
    F-2023-1279Funds Lock
    fixed

    Low
    F-2023-1278Missing Events
    fixed

    Low
    F-2023-127Redundant Import
    fixed

    Low
    F-2023-1276 Missing Zero Address Validation
    fixed

    Low
    1-10 of 17 findings

    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

    Repositoryhttps://github.com/Leech-Protocol/leech-contracts/tree/feature/dev-aud
    Commitf1019667115308f0945d38120d9af9c88c853501
    WhitepaperProvided
    RequirementsProvided
    Technical RequirementsProvided

    Contracts in Scope

    interfaces
    ILeechRouter.sol - interfaces/ILeechRouter.sol
    ILeechTransporter.sol - interfaces/ILeechTransporter.sol
    IRouterVelodrome.sol - interfaces/IRouterVelodrome.sol
    IStrategyMasterchefFarmV2.sol - interfaces/IStrategyMasterchefFarmV2.sol
    libraries
    Helpers.sol - libraries/Helpers.sol
    router
    ILeechRouter.sol - router/ILeechRouter.sol
    LeechRouterBase.sol - router/LeechRouterBase.sol
    LeechRouterOptimism.sol - router/LeechRouterOptimism.sol
    strategies
    VelodromeFarm
    IGauge.sol - strategies/VelodromeFarm/IGauge.sol
    IVelodromePair.sol - strategies/VelodromeFarm/IVelodromePair.sol
    StrategyVelodromeFarm.sol - strategies/VelodromeFarm/StrategyVelodromeFarm.sol
    BaseFarmStrategy.sol - strategies/BaseFarmStrategy.sol

    Disclaimer