Introduction
We express our gratitude to the Hyperlane team for the collaborative engagement that enabled the execution of this Smart Contract Security Assessment.
Hyperlane is a modular interchain protocol.
title | content |
---|---|
Platform | Ethereum, Solana, Base, Arbitrum, Others |
Language | Solidity |
Tags | Interchain messaging |
Timeline | 21/01/2023 - 03/04/2023 |
Methodology | https://hackenio.cc/sc_methodology→ |
Review Scope | |
---|---|
Repository | https://github.com/hyperlane-xyz/hyperlane-monorepo/tree/audit-v2-remediation→ |
Commit | def40316e9e0fee6857ece40d60a6ddcf2247e90 |
Review Scope
- Commit
- def40316e9e0fee6857ece40d60a6ddcf2247e90
Audit Summary
8/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 Hyperlane |
Audited By | Hacken |
Website | https://hyperlane.xyz→ |
Changelog | 28/01/2023 – Initial Review |
03/04/2023 – Second Review |
Document
- Name
- Smart Contract Code Review and Security Analysis Report for Hyperlane
- Audited By
- Hacken
- Website
- https://hyperlane.xyz→
- Changelog
- 28/01/2023 – Initial Review
- 03/04/2023 – Second Review
System Overview
There are two different repositories in the project, the repository for the main protocol and the repository for the token standard.
1-Token repository - Warp API
Developers can use Hyperlane's Warp API to permissionlessly deploy "Warp Routes", contracts that allow ERC20 and ERC721 tokens to move effortlessly between chains. Unlike other token wrapping protocols, Warp Routes are secured by a sovereign consensus.
2-Hyperlane Monorepo
Hyperlane is a modular interchain protocol, with various parts:
Mailbox: Mailbox is the low-level part of the messaging protocol. It is the place where the message arrives and departs from. Relayers are watching the mailbox at all times to look for new messages to route to another chain. Relayers will invoke the Mailbox contract on the target chain to deliver an interchain message.
Router: The router is the high-level part of the messaging protocol. It is used to interact with the Mailbox contract, and can be extended to offer many capabilities like messaging, bridging tokens and making calls to another chain. The protocol offers Router implementations providing these functionalities: InterchainQueryRouter, InterchainAccountRouter, LiquidityLayerRouter. Routers are built according to a structure that allows them to be deployed to multiple chains without code changes. \-InterchainQueryRouter: used to query the state on remote chains via interchain view calls. \-IterchainAccountRouter: used to create an account on a remote chain, and use that account to call smart contracts. Remote accounts are owned by the protocol. \-LiquidityLayerRouter: used to wrap around several token bridges to allow developers to send tokens alongside their message.
HyperlaneConnectionClient: mix-in contract that maintains pointers to the three contracts Hyperlane developers may need to interact with: Mailbox (required), InterchainGasPaymaster (optional), InterchainSecurityModule (optional).
Validators: Validators create the
signMailbox
merkle roots and make their signatures available to relayers.ISM: Interchain security modules (ISMs) are smart contracts that define the security model for an application. They can be user defined or the protocol default ones can be used. At the moment the only ISM provided by the protocol is MultisigIsm, a t-of-n security module. ISMs must implement the
verify()
interface, which gets called by the Mailbox before delivering a message. Ifverify()
does not return true, the transaction will revert.Relayer: aggregates the off-chain metadata needed to deliver messages (e.g. validator signatures and merkle proofs) and submits them to Mailboxes by calling
Mailbox.process()
, which in turn will invokeIMessageRecipient.handle()
on the destination chain Router.Watch towers: observe the network for validator fraud. If detected, watchtowers submit evidence to the source chain, slashing the fraudulent validator(s). The slashing process is frictionless because each validator only validates on the chain they are staking on.
This is the execution flow of a general message between chains:
Privileged roles
Protocol deployer - onlyOwner: the owner of the protocol can set the mailbox, interchain gas payment and interchain security module in the hyperlane connect client, set the default interchain security module in the mailbox, and also pause and unpause the mailbox, enroll a new router in the router contract, enroll, unenroll and set thresholds for validators in the interchain security module, set a liquidity layer adapter in the liquidity layer router contract, and add a domain and add/remove a token in the adapter contract.
Mailbox - onlyMailbox: can call the handle function in the router.
Router - onlyRemoteRouter: can be the original sender of a message dispatched to the handle function in the router.
LiquidityLayerRouter - onlyLiquidityLayerRouter in CircleBridgeAdapter.sol: can send and receive tokens.
Executive Summary
Documentation quality
The total Documentation quality score is 10 out of 10.
The documentation is overall clear and complete.
Code quality
The total Code quality score is 10 out of 10.
The development environment is configured.
Test coverage
Code coverage of the project is 100% (branch coverage).
Deployment and basic user interactions are covered with tests.
Security score
Upon auditing, the code was found to contain 0 critical, 4 high, 7 medium, and 10 low severity issues. Out of these, 10 issues have been addressed and resolved, leading to a security score of 8 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 8.6. This score reflects the combined evaluation of documentation, code quality, test coverage, and security aspects of the project.
Risks
The Token repository makes use of the unaudited package @hyperlane-xyz.
Contracts are upgradable.
Part of the protocol is off-chain and out of the scope of this audit.
InterchainAccountRouter does not implement a callback functionality to inform the origin chain about state changing operations performed on the remote chain.
LiquidityLayerRouter can only send tokens to contracts implementing the receiveTokens()
function.
Findings
Code ― | Title | Status | Severity | |
---|---|---|---|---|
F-2023-1545 | Compilation Error | fixed | High | |
F-2023-154 | Data Inconsistency | mitigated | High | |
F-2023-154 | Upgradeability Errors | fixed | High | |
F-2023-1542 | Upgradeability Errors | fixed | High | |
F-2023-155 | Upgradeability Errors | mitigated | Medium | |
F-2023-155 | Best Practices | unfixed | Medium | |
F-2023-1550 | Data Consistency | unfixed | Medium | |
F-2023-154 | Copy of well-known contract | mitigated | Medium | |
F-2023-154 | Unfinalized code | fixed | Medium | |
F-2023-154 | Best Practice Violation | fixed | Medium |
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/hyperlane-xyz/hyperlane-monorepo/tree/audit-v2-remediation→ |
Commit | def40316e9e0fee6857ece40d60a6ddcf2247e90 |
Whitepaper | Provided→ |
Requirements | Provided→ |
Technical Requirements | Not provided |
Contracts in Scope
solidity/contracts/Call.sol
solidity/contracts/Create2Factory.sol
solidity/contracts/HyperlaneConnectionClient.sol
solidity/contracts/InterchainGasPaymaster.sol
solidity/contracts/isms/MultisigIsm.sol
solidity/contracts/libs/EnumerableMapExtended.sol
solidity/contracts/libs/Merkle.sol
solidity/contracts/libs/Message.sol
solidity/contracts/libs/MinimalProxy.sol
solidity/contracts/libs/MultisigIsmMetadata.sol
solidity/contracts/libs/TypeCasts.sol
solidity/contracts/Mailbox.sol
solidity/contracts/middleware/InterchainAccountRouter.sol
solidity/contracts/middleware/InterchainQueryRouter.sol
solidity/contracts/middleware/liquidity-layer/adapters/CircleBridgeAdapter.sol