Status DataClose notification

Overlayer Disclosed Report

Audit Report

Incorrect destination-side `totalBridgedOut` accounting in `_credit()` can permanently lock bridged user funds

Target

Target is hidden

This information is not publicly available.

Vulnerability details

Overview

OverlayerWrapCore uses totalBridgedOut to account for OFT burns that reduce the hub chain supply. However, this accounting is currently performed in the shared _debit() / _credit() hooks on every chain instance, instead of being restricted to the hub chain. On a fresh destination non-hub chain, the local totalBridgedOut starts at zero. When it receives an inbound OFT transfer from the hub chain, the subtraction in _credit() underflows and reverts, causing the destination-side mint to fail. Because the source-side debit/burn has already succeeded, the destination-side failure can lock bridged user funds and break the destination bridge path.

Description

hubChainId is a core part of this design, and mint() / redeem() are only allowed on the hub chain. The deployment documentation also lists EURS+ deployments on Ethereum Sepolia, Optimism Sepolia, and Arbitrum Sepolia, showing that this OFT operates across multiple chain instances.

totalBridgedOut is local state maintained by each deployed instance. However, OverlayerWrapCore currently updates it unconditionally in both _debit() and _credit() on every chain:

OverlayerWrapCore.sol#L510-L528

    function _debit(
        address from_,
        uint256 amountLD_,
        uint256 minAmountLD_,
        uint32 dstEid_
    )
        internal
        virtual
        override
        returns (uint256 amountSentLD, uint256 amountReceivedLD)
    {
        (amountSentLD, amountReceivedLD) = super._debit(
            from_,
            amountLD_,
            minAmountLD_,
            dstEid_
        );
@>      totalBridgedOut += amountSentLD;
    }

OverlayerWrapCore.sol#L537-L544

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

As a result, when OFT assets are sent from the hub chain to a destination chain, the destination _credit() reads the destination instance's local totalBridgedOut, not the hub chain's value. On a fresh destination instance this value is zero, so the inbound credit path hits 0 - amountReceivedLD and reverts.

Attack path:

  1. A user mints the OverlayerWrap token ("OW") on the hub chain and holds the tokens there.
  2. The user calls OFT send() to bridge OW from the hub chain to a deployed destination non-hub chain.
  3. The source-side _debit() succeeds, the user's OW is burned on the source chain, and the source instance's local totalBridgedOut is increased.
  4. LayerZero delivers the message to the destination instance, which executes _credit().
  5. The destination _credit() tries to decrement the destination instance's local totalBridgedOut. Because this value is zero and smaller than amountReceivedLD, the subtraction underflows and reverts.
  6. The destination-side mint fails, but the source-side debit has already succeeded.

More importantly, this is not limited to the first inbound transfer. Any cross-chain transfer where destination.totalBridgedOut < amountReceivedLD will fail in the same way.

This issue directly breaks the multi-chain OFT receive path. The affected user has already been debited/burned on the source chain, while the destination chain fails to mint the bridged amount. According to LayerZero's documentation, the failed message can be retried, but retries do not recover the funds while this state accounting bug remains unchanged. They only hit the same revert again. As a result, bridged user funds can become permanently locked.

POC

The attached PoC.ts reproduces the issue.

This PoC uses two OverlayerWrapMock instances to simulate a hub instance and a fresh destination instance. It keeps only the minimum steps needed to demonstrate the issue: mint on the hub, call testDebit() on the hub, assert that the destination-local totalBridgedOut is still zero, and then call testCredit() on the destination and observe the revert.

Recommendation

Restrict totalBridgedOut to hub-chain-only accounting. The most direct fix is to update _debit() / _credit() only when block.chainid == hubChainId, so that totalBridgedOut is updated only when the hub chain acts as the source or destination. A non-hub chain should not maintain this state.

Validation steps

  1. Clone the repository:
    git clone https://github.com/Overlayerfi/contracts.git
  2. Enter the repository:
    cd contracts
  3. Checkout the in-scope commit:
    git checkout 519c9e92fd9d80d11e35e9868130f6334b88d676
  4. Install dependencies:
    npm i --force
  5. Save the attached PoC as test/PoC.ts.
  6. Run the PoC:
    npx hardhat test test/PoC.ts --network hardhat
  7. Observe that:
    • hub.testDebit(...) succeeds
    • destination.totalBridgedOut() remains 0
    • destination.testCredit(...) reverts

Attachments

Attachments are hidden

This information is not publicly available.

Comments are hidden

This information is not publicly available.