本文へ移動
Contact

TECHFUND
Media

Hi AUDIT
2024/8/19

Ronin Network Bridge Hack Analysis 

August 6th, 2024, the Ronin Network Bridge (@Ronin_Network) was exploited, resulting in the loss of $12 million (comprising $2 million in USDC and 4,000 ETH). This breach was due to a vulnerability introduced during a recent contract upgrade, which was exploited by an MEV bot.

Hack Overview

Decoding the Hack

The root cause of the exploit was a faulty upgrade deployed by the Ronin team, which included an uninitialized variable in their bridge manager during the transition from version 2 to version 4.

In this latest upgrade, the totalWeight value, which was previously fetched from the MainchainBridgeManager contract, was moved to be stored directly in the contract’s storage under the variable _totalOperatorWeight.

function initializeV2(address bridgeManagerContract) external reinitializer(2) {
setContract(ContractType.BRIDGEMANAGER, bridgeManagerContract);
}
function initializeV3() external reinitializer(3) {

IBridgeManager mainchainBridgeManager = IBridgeManager(getContract(ContractType.BRIDGE_MANAGER));
(, address[] memory operators, uint96[] memory weights) = mainchainBridgeManager.getFullBridgeOperatorInfos();

uint96 totalWeight;
for (uint i; i < operators.length; i++) {
_operatorWeight[operators[i]] = weights[i];
totalWeight += weights[i];
}
_totalOperatorWeight = totalWeight;
}
function initializeV4(address payable wethUnwrapper_) external reinitializer(4) {
wethUnwrapper = WethUnwrapper(wethUnwrapper_);
} 

As part of this process, the team introduced a new implementation contract, MainchainGatewayV3. However, they neglected to call the initializeV3 function, which was critical for setting up the _totalOperatorWeight variable.

This oversight left the _totalOperatorWeight variable uninitialized, defaulting to zero. Consequently, the minimumVoteWeight parameter, a key security check for cross-chain verification, was effectively disabled, leaving the bridge vulnerable to unauthorized withdrawals.

uint256 minimumWeight;

(minimumWeight, locked) = _computeMinVoteWeight(receipt.info.erc, tokenAddr, quantity);
{
bool passed;
address signer;
address lastSigner;
Signature memory sig;
uint256 weight;
for (uint256 i; i < signatures.length; i++) {
sig = signatures[i];
signer = ecrecover(receiptDigest, sig.v, sig.r, sig.s);
if (lastSigner >= signer) revert ErrInvalidOrder(msg.sig);
lastSigner = signer;
weight += _getWeight(signer);
if (weight >= minimumWeight) {
passed = true;
break;

  }
}
}

An MEV bot detected the disabled minimumVoteWeight parameter and executed a withdrawal transaction, extracting 4,000 ETH and $2 million in USDC from the bridge.

Fortunately, the Ronin Bridge had a daily withdrawal limit of $12 million, a crucial safeguard that capped the maximum amount that could be withdrawn in a single transaction. This limit prevented the potential loss of an additional $72 million, which would have been at risk without this control.

The Ronin team was alerted to the exploit and managed to pause the bridge contract approximately 38 minutes after the first unauthorized transaction. The stolen ETH, valued at approximately $10 million, and the USDC were eventually returned.

Fix

- Implement a thorough testing process for all contract upgrades, with a specific focus on ensuring that all critical variables, such as _totalOperatorWeight, are properly initialized.


Read more About  Deep Analysis of the $230M WazirX Exploit Incident

Author : Piyush shukla

Hi AUDIT

Hi AUDIT is a high speed, high quality, best price security audit service, providing automated audit SaaS and consulting for web3 startups.
View More