Axie Infinity - Audit

CertiKFiles named in the report

CertiK reviewed AxieInfinity (Axie Infinity - Audit) on 21 Jun 2022: 19 findings, 0 critical; 5 marked fixed, 2 acknowledged, 12 open.

No open critical findings
Open the reportOpen AxieInfinity’s security record

Report hosted on skynet.certik.com.

Trustblock does not review code.

Findings19

Statuses are the security firm’s own, from its report.

SeverityOpenAcknowledgedFixed
Critical000
High020
Medium401
Low804
MediumExternal dependenciesOpen

The Ronin bridge relies on external parties to function correctly. For instance, for the bridge to work, some servers must exist, that will be in charge of capturing events, and triggering actions associated with private keys (cf Bridge Workers/Relayers). In particular, Ronin Network relies on : - A Frontend server : So users can ask for the bridge of their assets; - Bridge relayers : Servers to relay proposals on other chains; - Ronin Validators : Who also validate deposits and withdrawals; - Potentially, some other servers : Who listen events, and trigger actions upon event reception; - Ronin Ethereum Sidechain ecosystem. Those elements are critical to Ronin Bridge's functioning and security, and need to be audited. Some other smart contracts dependancies exist: - `ECDSA`, `AccessControlEnumerable`, `IQuorum`, `IWeightedValidator` for the `GovernanceAdmin` contract; - `Initializable`, `Strings`, `StorageSlot` for the `RoninValidator` contract; - `Strings` for the `GatewayGovernance` contract; - `Strings`, `SignatureConsumer` for the `Governance` contract; - `Pausable`, `IQuorum`, `IWeightedValidator` for the `GatewayV2` contract; - `StorageSlot` for the `HasProxyAdmin` contract; - `TransparentUpgradeableProxy` for the `TransparentUpgradeableProxyV2` contract; - `ECDSA` for the `GlobalProposal` contract; - `Address` for the `Proposal` contract; - `IERC20`, `IERC721`, `Strings`, `IWETH` for the `Token` contract; - `ECDSA`, `IERC20`, `Strings` for the `Transfer` contract; - `AccessControlEnumerable`, `Initializable` for the `MainchainGatewayV2` contract; - `Ownable`, `IERC20` for the `BridgeMigration` contract; - `AccessControlEnumerable`, `Initializable`, `IERC20Mintable`, `IERC721Mintable` for the `RoninGatewayV2` contract. The above contract dependencies are considered secure in the context of the current audit.

MediumNo storage gap in Logical contractsOpen

Ronin has implemented proxyfiable contracts. Those contracts inherit from the following contracts (Interfaces are not mentionned) : - `RoninValidator` : Inherits from `Initializable`, `HasProxyAdmin`. - `RoninGatewayV2` : Inherits from `GatewayV2`, `GatewayGovernance`, `Initializable`, `MinimumWithdrawal`, `AccessControlEnumerable`; - `MainchainGatewayV2` : Inherits from `WithdrawalLimitation`, `Initializable`, `AccessControlEnumerable`. Some of those contracts do not implement a storage gap: - `HasProxyAdmin`; - `GatewayV2`; - `MinimumWithdrawal`; - `AccessControlEnumerable`; - `WithdrawalLimitation`. Because of this, if the logical contract is upgraded to a new version, and if variables are added in the dependencies, storage conflict could occur in the proxyfiable contracts, causing negative consequences over the functioning of the `VolumeWars` contract.

MediumPotential Lack of LiquidityOpen

Both the `MainchainGatewayV2` and `RoninGatewayV2` contracts, upon Deposits and Withdrawals, use the `handleAssetTransfer()` to forward the funds to the final user. The transfers might fail if there is not enough tokens in the contract. For instance, if there is not enough `_wrappedNativeToken` in the contract, the transaction will revert in the `transfer()` function: ```solidity=111 function transfer( Info memory _info, address _to, address _token ) internal { bool _success; if (_info.erc == Standard.ERC20) { _success = tryTransferERC20(_token, _to, _info.quantity); } else if (_info.erc == Standard.ERC721) { _success = tryTransferERC721(_token, _to, _info.id); } if (!_success) { revert( string( abi.encodePacked( "Token: could not transfer ", toString(_info), " to ", Strings.toHexString(uint160(_to), 20), " token ", Strings.toHexString(uint160(_token), 20) ) ) ); } } ``` However, no event is emitted, so the Ronin network might not be alerted of this problem. Additionally, if the `submitWithdrawal()` function on the Mainchain side reverted, there is no function on the Ronin Chain side to withdraw the locked funds in the Ronin Gateway contract. Therefore, the user might lose their funds forever.

MediumValidators could be too powerfulOpen

The function `submitWithdrawal()` verifies the signatures from validators. When all signatures are verified and when the threshold is met, assets will be transferred to the user specified in the `_receipt` parameter. ```solidity=122 function submitWithdrawal(Transfer.Receipt calldata _receipt, Signature[] calldata _signatures) external virtual whenNotPaused returns (bool _locked) { return _submitWithdrawal(_receipt, _signatures); } ``` The concern is, if the attacker exploited the private keys of the validators, the attacker can spoof the `receipt` and signatures, thus stealing the funds within the contract. As the validator's logic is unknown, we propose a potential workaround to add a restriction on the caller of `submitWithdrawal()` and separate the caller with validators. The caller could be a server that calls `submitWithdrawal()` after having received the deposit events (`DepositRequested`). In this way, by adding another layer of verification, even if the validators' private keys are compromised, the attacker cannot steal funds because the attacker needs to spoof a deposit event on the other chain.

Low`_minimumVoteWeight()` can be set to a low valueOpen

When a withdrawal or a deposit operation is submitted, validators agree to validate an operation. For example, in `_submitWithdrawal()` function, when enough validators have validated the operation with their signatures, tokens are sent to users. File `MainchainGatewayV2` ```solidity=278 (...) _weight += _validatorContract.getValidatorWeight(_signer); if (_weight >= _minimumVoteWeight) { _passed = true; break; } } require(_passed, "MainchainGatewayV2: query for insufficient vote weight"); withdrawalHash[_id] = _receiptHash; } (...) _recordWithdrawal(_tokenAddr, _quantity); _receipt.info.handleAssetTransfer(payable(_receipt.mainchain.addr), _tokenAddr, wrappedNativeToken); emit Withdrew(_receiptHash, _receipt); ``` This is intended in order to ensure that multiple validators vote on the same proposal, and one validator should usually not be able to pass a vote on his own. The `_minimumVoteWeight` mentioned above is computed as follows: ```solidity (...) function _computeMinVoteWeight( Token.Standard _erc, address _token, uint256 _quantity, IWeightedValidator _validatorContract ) internal virtual returns (uint256 _weight, bool _locked) { uint256 _totalWeights = _validatorContract.totalWeights(); _weight = _minimumVoteWeight(_totalWeights); (...) ``` The `_weight` is computed as follows: ```solidity=164 function _minimumVoteWeight(uint256 _totalWeight) internal view virtual returns (uint256) { return (_num * _totalWeight + _denom - 1) / _denom; } ``` However, when `_num` and `_denom` are configured, the only restriction is : ```solidity=188 function _setThreshold(uint256 _numerator, uint256 _denominator) internal virtual returns (uint256 _previousNum, uint256 _previousDenom) { require(_numerator <= _denominator, "GatewayV2: invalid threshold"); ``` `_denom` can be very large compared to `_num`. To take a concrete example, imagine that: - 9 validators exist, - Each validator has a weight of 100 (`_totalWeights` = 900), - `_num` is 1, - `_denom` is 1*10e18. This kind of configuration would put `minimumVoteWeight()` to: \ $$minimumVoteWeight()=(\_num * \_totalWeights + \_denom - 1) / \_denom$$\ $$minimumVoteWeight()=(900 + 1*10e18 ) / (1*10e18)$$\ $$minimumVoteWeight()=1$$ This means that **any validator could validate any proposal**. The value `1` has been validated with the following PoC: ```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract numDenom { uint256 public _num; uint256 public _denom; uint256 public _totalWeights; constructor(){ _denom = 1 ether; _num=1; _totalWeights=900; } function _minimumVoteWeight() public view virtual returns (uint256) { return (_num * _totalWeights + _denom - 1) / _denom; } } ```

LowDesign violationOpen

The `TransparentUpgradeableProxy` is designed as follows: - When `users` call the proxy, calls are forwarded to the implementation contract with `delegatecall`; - When an `admin` calls the proxy, the call is executed on the proxy contract. This design is meant to prevent [`Proxy selector clashing` attacks](https://medium.com/nomic-foundation-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357). The `TransparentUpgradeableProxyV2` contract implemented by Ronin violates this design, by allowing administrators to call the implementation contract, with the addition of the `functionDelegateCall()` function.

LowInappropriate Upper Limits for FeesOpen

The fee is calculated via the function `_computeFeePercentage()`: ```solidity=220 function _computeFeePercentage(uint256 _amount, uint256 _percentage) internal view virtual returns (uint256) { return (_amount * _percentage) / _MAX_PERCENTAGE; } ``` The percentage of the fee is set via function `_setUnlockFeePercentages()`. However, when setting the fee percentage, the fee percentage can be set as `_MAX_PERCENTAGE`, meaning all the transferred asset will be collected as fee. ```solidity=151 function _setUnlockFeePercentages(address[] calldata _tokens, uint256[] calldata _percentages) internal virtual { require(_tokens.length == _percentages.length, "WithdrawalLimitation: invalid array length"); for (uint256 _i; _i < _tokens.length; _i++) { require(_percentages[_i] <= _MAX_PERCENTAGE, "WithdrawalLimitation: invalid percentage"); unlockFeePercentages[_tokens[_i]] = _percentages[_i]; } emit UnlockFeePercentagesUpdated(_tokens, _percentages); } ```

LowIncompatibility With Deflationary TokensOpen

When transferring standard ERC20 deflationary tokens, the input amount may not be equal to the received amount due to the charged transaction fee. As a result, an inconsistency in the amount will occur and the transaction may fail due to the validation checks. For example, if a user deposit deflationary tokens (with a 10% transaction fee) into mainchain gateway contract, only 90 tokens actually arrive in the contract. However, the user can still withdraw 100 tokens (before fees) from the contract of the ronin side, which causes a lose 10 tokens in such a transaction. Reference: https://thoreum-finance.medium.com/what-exploit-happened-today-for-gocerberus-and-garuda-also-for-lokum-ybear-piggy-caramelswap-3943ee23a39f

LowPotential re-entrancy on `handleAssetTransfer()`Open

In the `handleAssetTransfer()` function of the `Token` contract, if the `_token` is a `Token.Standard.ERC20`, the flow is as following to send the tokens: ```solidity } else if (_info.erc == Token.Standard.ERC20) { uint256 _balance = IERC20(_token).balanceOf(address(this)); if (_balance < _info.quantity) { // bytes4(keccak256("mint(address,uint256)")) (_success, ) = _token.call(abi.encodeWithSelector(0x40c10f19, address(this), _info.quantity - _balance)); require(_success, "Token: ERC20 minting failed"); } transfer(_info, _to, _token); ``` After analysis, it does not seem that a practical scenario is possible, in which Ronin Network funds would be at risk. The scenario below intends to describe where the issue lies. \ In the hypothetical case that `_token` is a proxified and valuable ERC20 token controlled by an attacker, a re-entrancy could occur by abusing the `balanceOf()` function. The flow is as following : 1. Attacker modifies the implementation of `_token` to modify the `balanceOf()` function, to call `handleAssetTransfer()`. 2. Attacker calls `handleAssetTransfer()`; 3. When the contract will call `IERC20(_token).balanceOf(address(this))`, the call will go to `handleAssetTransfer()`, performing the re-entrancy. It is after the re-entrancy that the `transfer()` call is actually performed to send the tokens, making the attack possible.

LowQuestions about Tiers modelOpen

The auditors do not see how the Tiers model is implemented through the code, especially : - Tiers 2: All signatures from validators are required; - Tiers 3: All signatures from validators are required, one additional human review to unlock the fund The documentation states: "There will be another constraint on the number of token that can be withdraw in a day. We propose to cap the value at $50M. Since withdrawal of Tier 3 already requires human review, it will not be counted in daily withdrawal limit.". However, within the `_setDailyWithdrawalLimits()` function, there is no validation that this limit cannot be pushed beyond 50M: ```solidity=250 function _setDailyWithdrawalLimits(address[] calldata _tokens, uint256[] calldata _limits) internal virtual { require(_tokens.length == _limits.length, "WithdrawalLimitation: invalid array length"); for (uint256 _i; _i < _tokens.length; _i++) { dailyWithdrawalLimit[_tokens[_i]] = _limits[_i]; } emit DailyWithdrawalLimitsUpdated(_tokens, _limits); } ```

Show 2 more
LowUnlocked PragmaOpen

Contracts should be deployed using the same compiler version/flags with which they have been tested. Locking the pragma (e.g. by not using ^ in pragma solidity 0.8.0) ensures that contracts do not accidentally get deployed using an older compiler version with unfixed bugs. Reference: [SWC-103] https://swcregistry.io/docs/SWC-103

LowUsing of Default ValueOpen

When request a deposit with a fallback function, the `info` varaible was filled with default values, meaning `info.erc` is `ERC20` and `info.id` is 0. ```solidity function _fallback() internal virtual whenNotPaused { if (msg.sender != address(wrappedNativeToken)) { Transfer.Request memory _request; _request.recipientAddr = msg.sender; _request.info.quantity = msg.value; _requestDepositFor(_request, _request.recipientAddr); } } ```

Contracts in scope

No deployed address is recorded for this audit.

The report names a repository or files. Open the report to see its scope.

Repository and files the report names (4)

  • GlobalProposalGovernance.sol
  • ProposalGovernance.sol
  • Governance.sol
  • GatewayGovernance.sol

Part of AxieInfinity’s security record

AxieInfinity
Audits1 audit by 1 firmLast audit Jun 2022, by CertiK.
Critical findingsNo open critical findingsIn 1 report.
Open AxieInfinity’s security record

Security firm

CertiK

1,045 projects reviewed · 1,376 reports · latest May 2025

See CertiK’s audits

Something wrong on this page? A missing report, a wrong date, a finding that was fixed since. Tell us and we check it against its source.

Tell us