Status DataClose notification

Overlayer Disclosed Report

Audit Report

Tokens Transferred Cross Chain would be lost forever

Target

Target is hidden

This information is not publicly available.

Vulnerability details

Summary

The contract applies symmetric cross-chain accounting by incrementing totalBridgedOut during _debit() and decrementing it during _credit(). However, this logic works correctly on hub chain but would lead to arithmetic underflow on spoke chain due to the fact that, on spoke chains, initially totalBridgedOut would be decremented and since initial value is 0 any amount subtracted from that value will lead to arithmetic underflow. As a result, call to _credit function on spoke chain would always revert, and since the tokens got burned on hub chain during _debit function call and no mechanism has been implemented to recover the tokens in case of failed cross chain transaction the tokens would get lost forever.

Detailed Description

In Overlayercore contract, the OFT protocol has been implemented to bridge the tokens cross chain. User would make the send():OFTCore function call with the required parameters which would make a call to _send() function, which in turn calls _debit() function. The _debit() function has been overriden which increments totalBridgedOut variable with the amount of tokens to be bridged out. The problem starts when the message reaches to spoke chain where tokens need to be bridged. Here the _lzReceive() function would make call to _credit() function which has been overriden in OverlayerWrapCore contract.

    function _credit(
        address to_,
        uint256 amountLD_,
        uint32 srcEid_
    ) internal virtual override returns (uint256 amountReceivedLD) {
        amountReceivedLD = super._credit(to_, amountLD_, srcEid_);
        totalBridgedOut -= amountReceivedLD;
    }

Here it will try to decrement the totalBridgedOut variable. But since the spoke chains do not allow minting of tokens so no tokens would be bridged out of this contract which means totalBridgedOut value would be zero. This substraction will lead to arithmetic underflow, reverting the transcation on spoke chain. The failed message would be retried multiple times until it reaches threshold and will then be removed by the relayer admin.

Also since no mechanism have been implemented on hub chain to recover the tokens in case of cross chain message failure, the tokens would get lost forever.

Impact

  • Direct loss of user funds
  • Any bridge from hub → spoke will fail
  • No recovery mechanism exists
  • Breaks core protocol functionality (cross-chain transfers)

Recommended Mitigation

Instead of using shared variable on hub and spoke chain, make use of different varibles bridgedOutFromHub and bridgedIntoSpoke to track the amount of tokens.

Validation steps

Step 1: Environment Setup

Network: Hardhat local network (forked or standalone) Test Framework: Hardhat + Ethers v6 Prerequisites: Node.js v18+, npm packages installed

Step 2:Add Proof of Concept File

Copy the POC file to test/CrossChain.ts

Step 3 Execute the Test

Run the below command to execute the test

npx hardhat test test/CrossChain.ts

Step 4 Expected Output

Below is the desired output:

  🚨 Cross-chain desync vulnerability
    √ ❌ should revert on spoke _credit due to underflow (475ms)

Attachments

Attachments are hidden

This information is not publicly available.

Comments are hidden

This information is not publicly available.