EnergyFi Bridge

Smart Contract Audit Report

Audit Summary

EnergyFi Bridge Audit Report EnergyFi Bridge is a new platform in which users can bridge supported tokens across chains.

For this audit, we reviewed EnergyFi's MintBurnable, Bridge, and Migrations contracts at commit 3c8722c94b5b719a3939e2b129b9455cc0467f2d on the team's private GitHub repository.

Audit Findings

Centralized aspects are present.
Date: August 26th, 2022.
Updated: September 2nd, 2022 to reflect changes from commit 02d528d19e102362ac82863847807f0604cca3b3 to commit 3c8722c94b5b719a3939e2b129b9455cc0467f2d.

Finding #1 - Bridge - Medium (Resolved)

Description: The addChain() and removeChain() functions are not owner-restricted, allowing any chain to be whitelisted by any user. In order to initiate or claim a bridge transfer to a chain, a supported token address would still have to have the unsupported chain listed as a supported destination, which can only be enabled by the contract's owner. Claims must also signed by Validators.
Risk/Impact: The owner cannot disable support for a chain by removing it from the whitelist; instead they must remove all tokens which include support for the given chain.
Recommendation: The addChain() and removeChain() functions should be owner-restricted.
Resolution: The team has implemented the above recommendation.

Finding #2 - Bridge - Informational

Description: The verifyValidatorAddresses() function checks for repeat addresses inefficiently and can result in high gas usage if the minimum required number of Validators is set to a large value.
Recommendation: In order to improve gas usage and reduce the risk of gas usage failure, signatures should be passed in ascending order. Each address can then be checked to be greater than to the address before it.

Contracts Overview

  • As the contracts are implemented with Solidity v0.8.x, they are safe from any possible overflows/underflows.
MintBurnable Contract:
  • MintBurnable tokens are used in order to facilitate bridges across multiple chains.
  • The Minter Role is granted to a specified address upon deployment. This address is intended to be the Bridge contract.
  • The Minter Role can mint any amount of tokens to any address at any time.
  • Users can burn their tokens at any time, reducing the total supply of the token.
  • The contract complies with the ERC-20 token standard.
Bridge Contract:
  • Users can initiate a bridge transfer of a specified token to a whitelisted chain at any time.
  • Only tokens supported by the contract on the specified destination chain are valid.
  • If the specified token is exempt from fees, no fees are taken. Otherwise, the contract's fee percentage is taken and transferred to the Fee Receiver address.
  • If the associated destination token address' "origin chain" is set as the current chain, then the tokens are transferred from the user to this contract.
  • Fee-on-transfer tokens are supported.
  • If the associated destination token address' origin chain is not the current chain, they are instead burned from the user.
  • When claiming, a user will input a message and a signature list for verification.
  • The number of passed signatures must be at least equal to the minimum number of required validators.
  • Each signature is verified with the message hash to ensure that each signer is a Validator.
  • The list will only be checked until the minimum number of required validators has been reached. If any checked signer is not a Validator, the claim will fail.
  • The claim information is then recovered from the passed message.
  • As signatures and passed claim messages are assembled off-chain, we are unable to provide an assessment with regards to their functionality.
  • If the source token's origin chain is the current chain, the user is transferred their tokens.
  • If the source token's origin chain is not the current chain, MintBurnable tokens are minted to the user.
  • This contract can be upgraded at any time if authorized by the owner.
  • The owner can add or remove a Validator at any time.
  • The owner can update the minimum number of required Validators at any time.
  • The owner can add or remove a chain ID from the chain whitelist at any time.
  • The owner can add a new supported token at any time with an associated chain, token address on that chain, and origin chain.
  • The owner can also remove a supported token at any time.
  • The owner can update the fee to any amount up to 100% at any time.
  • The owner can update the Fee Receiver address at any time.
  • The owner can add or remove any token from fee exemption at any time.

Audit Results

Vulnerability Category Notes Result
Arbitrary Jump/Storage Write N/A PASS
Centralization of Control
  • The owner, Minter, and Validator Role have the permissions described above.
  • A Validator has the ability to provide a signed message for any claim.
  • The owner can remove support for a token at any time.
  • The owner can update fees to any amounts up to 100% at any time.
  • WARNING
    Compiler Issues N/A PASS
    Delegate Call to Untrusted Contract N/A PASS
    Dependence on Predictable Variables N/A PASS
    Ether/Token Theft N/A PASS
    Flash Loans N/A PASS
    Front Running N/A PASS
    Improper Events N/A PASS
    Improper Authorization Scheme N/A PASS
    Integer Over/Underflow N/A PASS
    Logical Issues N/A PASS
    Oracle Issues N/A PASS
    Outdated Compiler Version N/A PASS
    Race Conditions N/A PASS
    Reentrancy N/A PASS
    Signature Issues N/A PASS
    Unbounded Loops N/A PASS
    Unused Code N/A PASS
    Overall Contract Safety   PASS

    MintBurnable Contract

    Smart Contract Audit - Inheritance

    Smart Contract Audit - Graph

    
     ($) = payable function
     # = non-constant function
     
     Int = Internal
     Ext = External
     Pub = Public
     
     + [Int] IERC20 
     - [Ext] totalSupply
     - [Ext] balanceOf
     - [Ext] transfer #
     - [Ext] allowance
     - [Ext] approve #
     - [Ext] transferFrom #
    
    + [Int] IERC20Metadata (IERC20)
     - [Ext] name
     - [Ext] symbol
     - [Ext] decimals
    
    +  Context 
     - [Int] _msgSender
     - [Int] _msgData
    
    +  ERC20 (Context, IERC20, IERC20Metadata)
     - [Pub]  #
     - [Pub] name
     - [Pub] symbol
     - [Pub] decimals
     - [Pub] totalSupply
     - [Pub] balanceOf
     - [Pub] transfer #
     - [Pub] allowance
     - [Pub] approve #
     - [Pub] transferFrom #
     - [Pub] increaseAllowance #
     - [Pub] decreaseAllowance #
     - [Int] _transfer #
     - [Int] _mint #
     - [Int] _burn #
     - [Int] _approve #
     - [Int] _spendAllowance #
     - [Int] _beforeTokenTransfer #
     - [Int] _afterTokenTransfer #
    
    +  ERC20Burnable (Context, ERC20)
     - [Pub] burn #
     - [Pub] burnFrom #
    
    + [Int] IAccessControl 
     - [Ext] hasRole
     - [Ext] getRoleAdmin
     - [Ext] grantRole #
     - [Ext] revokeRole #
     - [Ext] renounceRole #
    
    + [Lib] Strings 
     - [Int] toString
     - [Int] toHexString
     - [Int] toHexString
    
    + [Int] IERC165 
     - [Ext] supportsInterface
    
    +  ERC165 (IERC165)
     - [Pub] supportsInterface
    
    +  AccessControl (Context, IAccessControl, ERC165)
     - [Pub] supportsInterface
     - [Pub] hasRole
     - [Int] _checkRole
     - [Int] _checkRole
     - [Pub] getRoleAdmin
     - [Pub] grantRole #
        - modifiers: onlyRole
     - [Pub] revokeRole #
        - modifiers: onlyRole
     - [Pub] renounceRole #
     - [Int] _setupRole #
     - [Int] _setRoleAdmin #
     - [Int] _grantRole #
     - [Int] _revokeRole #
    
    +  MintBurnable (ERC20, ERC20Burnable, AccessControl)
     - [Pub]  #
        - modifiers: ERC20
     - [Pub] mint #
        - modifiers: onlyRole
    
    
    

    Bridge Contract

    Smart Contract Audit - Inheritance

    Smart Contract Audit - Graph

    
     ($) = payable function
     # = non-constant function
     
     Int = Internal
     Ext = External
     Pub = Public
     
    
     + [Lib] AddressUpgradeable 
     - [Int] isContract
     - [Int] sendValue #
     - [Int] functionCall #
     - [Int] functionCall #
     - [Int] functionCallWithValue #
     - [Int] functionCallWithValue #
     - [Int] functionStaticCall
     - [Int] functionStaticCall
     - [Int] verifyCallResult
    
    +  Initializable 
     - [Int] _disableInitializers #
     - [Prv] _setInitializedVersion #
    
    +  ContextUpgradeable (Initializable)
     - [Int] __Context_init #
        - modifiers: onlyInitializing
     - [Int] __Context_init_unchained #
        - modifiers: onlyInitializing
     - [Int] _msgSender
     - [Int] _msgData
    
    +  OwnableUpgradeable (Initializable, ContextUpgradeable)
     - [Int] __Ownable_init #
        - modifiers: onlyInitializing
     - [Int] __Ownable_init_unchained #
        - modifiers: onlyInitializing
     - [Pub] owner
     - [Pub] renounceOwnership #
        - modifiers: onlyOwner
     - [Pub] transferOwnership #
        - modifiers: onlyOwner
     - [Int] _transferOwnership #
    
    + [Int] IERC1822ProxiableUpgradeable 
     - [Ext] proxiableUUID
    
    + [Int] IBeaconUpgradeable 
     - [Ext] implementation
    
    + [Lib] StorageSlotUpgradeable 
     - [Int] getAddressSlot
     - [Int] getBooleanSlot
     - [Int] getBytes32Slot
     - [Int] getUint256Slot
    
    +  ERC1967UpgradeUpgradeable (Initializable)
     - [Int] __ERC1967Upgrade_init #
        - modifiers: onlyInitializing
     - [Int] __ERC1967Upgrade_init_unchained #
        - modifiers: onlyInitializing
     - [Int] _getImplementation
     - [Prv] _setImplementation #
     - [Int] _upgradeTo #
     - [Int] _upgradeToAndCall #
     - [Int] _upgradeToAndCallUUPS #
     - [Int] _getAdmin
     - [Prv] _setAdmin #
     - [Int] _changeAdmin #
     - [Int] _getBeacon
     - [Prv] _setBeacon #
     - [Int] _upgradeBeaconToAndCall #
     - [Prv] _functionDelegateCall #
    
    +  UUPSUpgradeable (Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable)
     - [Int] __UUPSUpgradeable_init #
        - modifiers: onlyInitializing
     - [Int] __UUPSUpgradeable_init_unchained #
        - modifiers: onlyInitializing
     - [Ext] proxiableUUID
        - modifiers: notDelegated
     - [Ext] upgradeTo #
        - modifiers: onlyProxy
     - [Ext] upgradeToAndCall ($)
        - modifiers: onlyProxy
     - [Int] _authorizeUpgrade #
    
    + [Int] IERC20 
     - [Ext] totalSupply
     - [Ext] balanceOf
     - [Ext] transfer #
     - [Ext] allowance
     - [Ext] approve #
     - [Ext] transferFrom #
    
    + [Int] IERC20Metadata (IERC20)
     - [Ext] name
     - [Ext] symbol
     - [Ext] decimals
    
    + [Int] IERC20MintBurnable (IERC20)
     - [Ext] mint #
     - [Ext] burnFrom #
    
    +  Bridge (Initializable, OwnableUpgradeable, UUPSUpgradeable)
     - [Ext] initialize #
        - modifiers: initializer
     - [Int] _authorizeUpgrade #
        - modifiers: onlyOwner
     - [Ext] version
     - [Ext] teleport #
     - [Ext] claim #
     - [Ext] addValidator #
        - modifiers: onlyOwner
     - [Ext] removeValidator #
        - modifiers: onlyOwner
     - [Ext] setMinRequiredValidators #
        - modifiers: onlyOwner
     - [Ext] addChain #
       - modifiers: onlyOwner
     - [Ext] removeChain #
       - modifiers: onlyOwner
     - [Ext] addToken #
        - modifiers: onlyOwner
     - [Ext] removeToken #
        - modifiers: onlyOwner
     - [Ext] setFee #
        - modifiers: onlyOwner
     - [Ext] setFeeReceiver #
        - modifiers: onlyOwner
     - [Ext] addToNoFeeList #
        - modifiers: onlyOwner
     - [Ext] removeFromNoFeeList #
        - modifiers: onlyOwner
     - [Prv] createClaimId #
     - [Prv] getChainId
     - [Prv] verifySignatures
     - [Prv] recoverAddresses
     - [Prv] parseSignature
     - [Prv] verifyValidatorAddresses
     - [Prv] decodeMessage
    
    
    

    Migrations Contract

    Smart Contract Audit - Inheritance

    Smart Contract Audit - Graph

    
     ($) = payable function
     # = non-constant function
     
     Int = Internal
     Ext = External
     Pub = Public
     
     +  Migrations 
     - [Pub] setCompleted #
        - modifiers: restricted
    
    

    About SourceHat

    SourceHat has quickly grown to have one of the most experienced and well-equipped smart contract auditing teams in the industry. Our team has conducted 1300+ solidity smart contract audits covering all major project types and protocols, securing a total of over $50 billion U.S. dollars in on-chain value across 1500 projects!.
    Our firm is well-reputed in the community and is trusted as a top smart contract auditing company for the review of solidity code, no matter how complex. Our team of experienced solidity smart contract auditors performs audits for tokens, NFTs, crowdsales, marketplaces, gambling games, financial protocols, and more!

    Contact us today to get a free quote for a smart contract audit of your project!

    What is a SourceHat Audit?

    Typically, a smart contract audit is a comprehensive review process designed to discover logical errors, security vulnerabilities, and optimization opportunities within code. A SourceHat Audit takes this a step further by verifying economic logic to ensure the stability of smart contracts and highlighting privileged functionality to create a report that is easy to understand for developers and community members alike.

    How Do I Interpret the Findings?

    Each of our Findings will be labeled with a Severity level. We always recommend the team resolve High, Medium, and Low severity findings prior to deploying the code to the mainnet. Here is a breakdown on what each Severity level means for the project:

    • High severity indicates that the issue puts a large number of users' funds at risk and has a high probability of exploitation, or the smart contract contains serious logical issues which can prevent the code from operating as intended.
    • Medium severity issues are those which place at least some users' funds at risk and has a medium to high probability of exploitation.
    • Low severity issues have a relatively minor risk association; these issues have a low probability of occurring or may have a minimal impact.
    • Informational issues pose no immediate risk, but inform the project team of opportunities for gas optimizations and following smart contract security best practices.