Q2 2026 Security & Compliance Report67 incidents, $764M in losses, 88% from operational failures.
Get the report →

Audit name:

[SCA] Bitlayer | System Contracts | Mar2024

Date:

Apr 4, 2024

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 Bitlayer team for the collaborative engagement that enabled the execution of this Smart Contract Security Assessment.

Bitlayer is the layer 2 based on BitVM. It consists an EVM compatible chain/sequencer that can map BTC ecological assets and facilitate the entry of BTC users.

titlecontent
PlatformEVM
LanguageSolidity
TagsERC20, Layer2, Staking, Token Factory, MultiSig
Timeline06/03/2024 - 01/04/2024
Methodologyhttps://hackenio.cc/sc_methodology→

    Review Scope

    Repositoryhttps://github.com/bitlayer-org/bitlayer-contracts→
    Commit751c34b1072b7539c1a063b38522cf7606c9268a

    Audit Summary

    Total7.8/10
    Security Score

    10/10

    Test Coverage

    62.5%

    Code Quality Score

    8/10

    Documentation Quality Score

    7/10

    18Total Findings
    11Resolved
    7Accepted
    0Mitigated

    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 Bitlayer
    Audited ByNiccolò Pozzolini, Kornel Światłowski
    Approved ByPrzemyslaw Swiatowiec
    Websitehttps://www.bitlayer.org/→
    Changelog21/03/2024 - Preliminary Report
    01/04/2024 - Final Report
    • Document

      Name
      Smart Contract Code Review and Security Analysis Report for Bitlayer
      Audited By
      Niccolò Pozzolini, Kornel Światłowski
      Approved By
      Przemyslaw Swiatowiec
      Changelog
      21/03/2024 - Preliminary Report
      01/04/2024 - Final Report

    System Overview

    The project revolves around a blockchain framework, focusing on staking mechanisms and validator management to achieve consensus. Central components include a suite of smart contracts for staking (Staking.sol, Validator.sol), token management (BRC.sol, TokenFactory.sol), and security features (LockingContract.sol, MultiSigWallet.sol). The system allows for validator registration under a permission-based approach, transitioning to permission-less to enhance inclusivity. Validators compete for network consensus roles based on the amount of BRC tokens staked, with mechanisms for reward distribution, delegation, and penalties for non-compliance embedded within the protocol.

    Privileged roles

    • TokenFactory.AdminRole: can create and mint ERC20 tokens

    • TokenFactory.OwnerRole: admin of the role AdminRole

    • Vault.AdminRole: can add/remove to/from whitelist, release ERC20/native tokens

    • Vault.OwnerRole: admin of the role AdminRole

    • Validator.owner is the staking contract. Most user action on Validator need to pass by the Staking contract

    • Staking.admin: can make validators registration permissionless, and change the foundation pool address

    Executive Summary

    Documentation quality

    The total Documentation Quality score is 7 out of 10.

    • Functional requirements are present, but only at a high-level.

    • Technical description is not complete.

    Code quality

    The total Code Quality score is 8 out of 10.

    • The code duplicates commonly known contracts instead of reusing them.

    • Best practice violations.

    Test coverage

    Code coverage of the project is 62.5% (branch coverage).

    Security score

    Upon auditing, the code was found to contain 0 critical, 0 high, 0 medium, and 1 low severity issues, 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 7.8. This score reflects the combined evaluation of documentation, code quality, test coverage, and security aspects of the project.

    Risks

    No additional risks were identified.

    Findings

    F-2024-1549ReStaking() and reDelegation() lead to ERC20 token lock
    Status
    fixed
    Severity

    High
    F-2024-1566Coarse grained access control in Vault contract leads to redundant whitelist feature
    Status
    accepted
    Severity

    Low
    F-2024-1554Missing address validation for _foundationPool in Staking contract's initialise function
    Status
    fixed
    Severity

    Low
    F-2024-1335Missing validation of beneficiary address can lead to token locked
    Status
    fixed
    Severity

    Low
    F-2024-1562CEI violation in validatorClaimAny function in Validator.sol contract
    Status
    fixed
    Severity

    Observation
    F-2024-1558Public function should be external
    Status
    fixed
    Severity

    Observation
    F-2024-1557The LazyPunishRecord struct in Staking.sol contract can be optimized
    Status
    accepted
    Severity

    Observation
    F-2024-1556The updateActiveValidatorSet function in Staking.sol contract can be optimised
    Status
    fixed
    Severity

    Observation
    F-2024-1552Missing decimal check for brcToken in the Staking contract
    Status
    accepted
    Severity

    Observation
    F-2024-1550Add supply cap feature to CustomERC20 contract for enhanced security
    Status
    accepted
    Severity

    Observation
    Code
    ―
    Title
    Status
    Severity
    F-2024-1549ReStaking() and reDelegation() lead to ERC20 token lock
    fixed

    High
    F-2024-1566Coarse grained access control in Vault contract leads to redundant whitelist feature
    accepted

    Low
    F-2024-1554Missing address validation for _foundationPool in Staking contract's initialise function
    fixed

    Low
    F-2024-1335Missing validation of beneficiary address can lead to token locked
    fixed

    Low
    F-2024-1562CEI violation in validatorClaimAny function in Validator.sol contract
    fixed

    Observation
    F-2024-1558Public function should be external
    fixed

    Observation
    F-2024-1557The LazyPunishRecord struct in Staking.sol contract can be optimized
    accepted

    Observation
    F-2024-1556The updateActiveValidatorSet function in Staking.sol contract can be optimised
    fixed

    Observation
    F-2024-1552Missing decimal check for brcToken in the Staking contract
    accepted

    Observation
    F-2024-1550Add supply cap feature to CustomERC20 contract for enhanced security
    accepted

    Observation
    1-10 of 18 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/bitlayer-org/bitlayer-contracts→
    Commit751c34b1072b7539c1a063b38522cf7606c9268a
    Whitepaper-
    RequirementsFile name: Audit content description.pdf; SHA3: 8b659ffa690b7fa2733a7d9ab557b8d41892fd82fb96fa514f771ba6a7e64b40
    Technical RequirementsFile name: Audit content description.pdf; SHA3: 8b659ffa690b7fa2733a7d9ab557b8d41892fd82fb96fa514f771ba6a7e64b40
    • Scope Details

      Commit
      751c34b1072b7539c1a063b38522cf7606c9268a
      Whitepaper
      -
      Requirements
      File name: Audit content description.pdf; SHA3: 8b659ffa690b7fa2733a7d9ab557b8d41892fd82fb96fa514f771ba6a7e64b40
      Technical Requirements
      File name: Audit content description.pdf; SHA3: 8b659ffa690b7fa2733a7d9ab557b8d41892fd82fb96fa514f771ba6a7e64b40

    Contracts in Scope

    contracts
    builtin
    Staking.sol - contracts › builtin › Staking.sol
    Validator.sol - contracts › builtin › Validator.sol
    Params.sol - contracts › builtin › Params.sol
    library
    SortedList.sol - contracts › builtin › library › SortedList.sol
    SafeSend.sol - contracts › builtin › library › SafeSend.sol
    initializable.sol - contracts › builtin › library › initializable.sol
    ReentrancyGuard.sol - contracts › builtin › library › ReentrancyGuard.sol
    SafeERC20.sol - contracts › builtin › library › SafeERC20.sol
    WithAdmin.sol - contracts › builtin › WithAdmin.sol
    interfaces
    IValidator.sol - contracts › builtin › interfaces › IValidator.sol
    types.sol - contracts › builtin › interfaces › types.sol
    basic
    BRC.sol - contracts › basic › BRC.sol
    LockingContract.sol - contracts › basic › LockingContract.sol
    Vault.sol - contracts › basic › Vault.sol
    TokenFactory.sol - contracts › basic › TokenFactory.sol
    MultiSigWallet.sol - contracts › basic › MultiSigWallet.sol
    interfaces

    Disclaimer