Status DataClose notification

Overlayer Disclosed Report

Audit Report

Bridging Underflow on Spoke Chains Permanent Loss of Funds

Target

Target is hidden

This information is not publicly available.

Vulnerability details

Description

The Overlayer Protocol uses LayerZero's OFT (Omnichain Fungible Token) standard to bridge OVA tokens across multiple chains. The protocol tracks the total amount of tokens bridged out of the Hub Chain using a state variable called totalBridgedOut. This variable is critical for maintaining a 1:1 backing of the stablecoin, as it allows the AaveHandler to calculate the total global supply of OVA and ensure that sufficient collateral is held on the Hub.

The vulnerability exists in the way totalBridgedOut is updated during an incoming cross-chain transfer (_credit operation).

In OverlayerWrapCore.sol:

function _credit( address _to, uint256 _amountLD, uint32 /_srcEid/ ) internal virtual override returns (uint256 amountReceivedLD) { amountReceivedLD = super._credit(_to, _amountLD, 0); totalBridgedOut -= amountReceivedLD; // <--- @audit UNDERFLOW HERE }

Initialization: On any newly deployed chain (Spoke Chain), totalBridgedOut is initialized to 0.

Logical Flaw: While the Hub Chain correctly increments this value when tokens leave, any Spoke Chain receiving its first transfer will attempt to decrement 0 by the received amount.

Solidity 0.8+ Behavior: In Solidity 0.8.20 (the project's version), unchecked arithmetic operations result in a

Panic(0x11) and a full transaction revert.

Attack Vector (Step-by-Step)

This vulnerability does not require a malicious actor; it is triggered by legitimate user behavior:

User A has 1,000 OVA on the Hub Chain (e.g., Ethereum).

User A calls send() to bridge 1,000 OVA to a Spoke Chain (e.g., Arbitrum).

The Hub Chain successfully burns/locks the tokens and sends a LayerZero message.

The LayerZero Executor attempts to deliver the message to the Spoke Chain by calling lzReceive().

The Spoke Chain's _credit function is invoked.

totalBridgedOut (which is 0 on Arbitrum) is decremented by 1,000 (scaled for decimals).

The transaction reverts immediately.

The LayerZero message remains in a "Failing" state on the destination chain.

Impact

Permanent Fund Loss: Users who attempt to bridge tokens to any Spoke Chain will have their tokens burned on the source chain, but the destination chain will always revert during minting. Unless the protocol has a manual "force-resume" or "retry" with a fix, these funds are effectively lost in the cross-chain "limbo."

Complete Protocol Paralysis: The omnichain functionality is the core value proposition of Overlayer. This bug effectively renders all non-hub deployments useless.

Governance Risk: If the protocol tries to fix this by upgrading (if using proxies), it introduces significant delay and requires administrative intervention, during which time the protocol's reputation is severely damaged.

Recommendation

The totalBridgedOut accounting should only be active on the Hub Chain, as that is the only location where global collateral is balanced against the "bridged out" supply.

Modify OverlayerWrapCore._credit to check the chain ID:

function _credit(...) internal virtual override returns (uint256 amountReceivedLD) { amountReceivedLD = super._credit(_to, _amountLD, 0); // Only update bridged out accounting on the Hub if (block.chainid == hubChainId) { totalBridgedOut -= amountReceivedLD; } }

Validation steps

// SPDX-License-Identifier: MIT pragma solidity ^0.8.20;

import "forge-std/Test.sol"; import "../contracts/overlayer/OverlayerWrap.sol"; import "../contracts/overlayer/types/OverlayerWrapCoreTypes.sol";

// Mock LayerZero Endpoint V2

contract MockEndpointV2 { function setDelegate(address) external {} }

contract BridgingUnderflowPoC is Test { OverlayerWrap public spokeOFT; MockEndpointV2 public mockEndpoint; address public receiver = address(0xDEaD); function setUp() public { mockEndpoint = new MockEndpointV2();

    // Define Spoke Chain (Chain 2)
    vm.chainId(2); 
    
    // Initialize the Spoke OFT
    // Hub Chain ID is 1, so this is definitely a Spoke
    spokeOFT = new OverlayerWrap(
        OverlayerWrapCoreTypes.ConstructorParams({
            name: "Overlayer Spoke",
            symbol: "OVA",
            lzEndpoint: address(mockEndpoint),
            delegate: address(this),
            collateral: OverlayerWrapCoreTypes.StableCoin({addr: address(0), decimals: 6}),
            aCollateral: OverlayerWrapCoreTypes.StableCoin({addr: address(0), decimals: 6}),
            hubChainId: 1
        })
    );
}
function test_credit_Underflow() public {
    uint256 amountToReceive = 1000 * 1e18;
    
    // Simulate a LayerZero credit call (internal _credit via lzReceive counterpart)
    // We use the selector for lzReceive to simulate the actual LZ delivery path
    
    bytes32 guid = bytes32(uint256(1));
    bytes memory payload = abi.encodePacked(
        bytes32(uint256(uint160(receiver))), // 'to'
        uint64(1000 * 1e6)                   // amountSD (LZ uses shared decimals)
    );
    // This call will invoke _credit internally
    // It SHOULD pass, but it will CRASH due to 0 - 1000 underflow
    vm.expectRevert(); // In production, this means the user's funds are stuck
    
    // Simulating the exact struct and call path LayerZero takes
    vm.prank(address(mockEndpoint));
    spokeOFT.lzReceive(
        IOverlayerWrapCoreEvents.Origin({srcEid: 1, sender: bytes32(uint256(uint160(address(this)))), nonce: 1}),
        guid,
        payload,
        address(0),
        ""
    );
    
    console.log("If you see this, the underflow bug was not triggered.");
}

}

Attachments

Attachments are hidden

This information is not publicly available.

Comments are hidden

This information is not publicly available.