Status DataClose notification

Overlayer Disclosed Report

Audit Report

Incorrect Per-Chain `totalBridgedOut` Accounting Causes `_credit` Underflow and Reverts Inbound Bridging

Target

Target is hidden

This information is not publicly available.

Vulnerability details

Summary

contracts/overlayer/OverlayerWrapCore.sol uses totalBridgedOut as backing accounting for bridging, but it updates this counter on every chain instance. This is wrong because each deployment has its own storage, while the accounting is described as hub-only. As a result, _credit(...) on a spoke can subtract amountReceivedLD from a local totalBridgedOut that was never increased there. In Solidity 0.8+, this causes an underflow and revert, which can break inbound bridging and strand user funds after the source-side burn has already succeeded.

Root Cause

The main issue is in contracts/overlayer/OverlayerWrapCore.sol, where totalBridgedOut is treated as if it were shared across chains, even though each chain deployment keeps its own independent storage.

  • In OverlayerWrapCore._debit(...), the contract always executes totalBridgedOut += amountSentLD; after super._debit(...). This increments the local totalBridgedOut on whatever chain called _debit(...).

  • In OverlayerWrapCore._credit(...), the contract always executes totalBridgedOut -= amountReceivedLD; after super._credit(...). This decrements the local totalBridgedOut on the destination chain, even if that chain never previously increased its own counter.

  • The finding states that totalBridgedOut is documented or used as hub-chain accounting to preserve backing relative to totalSupply() + totalBridgedOut. But because spoke and satellite deployments do not share the hub's storage, a destination chain may run _credit(...) with totalBridgedOut < amountReceivedLD.

  • On fresh spoke deployments, the local totalBridgedOut can be 0. In that case, OverlayerWrapCore._credit(...) performs totalBridgedOut -= amountReceivedLD;, which underflows and reverts under Solidity 0.8+.

This makes inbound bridging depend on whether the destination chain itself has previously bridged out enough tokens to build up its own local totalBridgedOut. The input explicitly states that this is not a valid assumption for normal operation.

Impact

Inbound bridging to a spoke or satellite can fail if that destination chain does not have enough local totalBridgedOut to cover amountReceivedLD.

In the described LayerZero flow, super._debit(...) on the source chain succeeds before the destination executes _credit(...). Because of that:

  • the user's tokens may already be burned on the source chain,
  • the destination receive can revert due to underflow in totalBridgedOut -= amountReceivedLD,
  • the bridge message can become permanently unexecutable under the current code path,
  • funds can be locked or stranded across chains.

A practical result is that fresh spoke deployments may be unable to receive tokens at all, and first-time hub-to-spoke transfers can fail.

Scenario

  • First hub-to-spoke transfer on a fresh spoke

    • A hub instance and a spoke instance are deployed.
    • The spoke has never processed an outbound bridge, so its local totalBridgedOut == 0.
    • A user bridges tokens from the hub to the spoke.
    • On the hub, OverlayerWrapCore._debit(...) calls super._debit(...) and then increments the hub's local totalBridgedOut with totalBridgedOut += amountSentLD.
    • On the spoke, OverlayerWrapCore._credit(...) calls super._credit(...) and then executes totalBridgedOut -= amountReceivedLD.
    • Because the spoke's own local counter is still 0, the subtraction underflows and the receive reverts.
  • Inbound transfer to a chain with insufficient local outbound history

    • A destination chain has previously bridged out some amount, but its local totalBridgedOut is still less than the new amountReceivedLD.
    • When an inbound bridge reaches that chain, _credit(...) tries to subtract amountReceivedLD from that smaller local value.
    • The transaction reverts for the same reason, meaning a chain can only receive up to the amount it has previously bridged out locally.

Validation steps

Affected Code:

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

Recommendation:

Restrict totalBridgedOut accounting to the hub chain only, in line with the intended backing model. Do not update this variable on spoke or satellite deployments, since each chain maintains independent storage and cannot safely rely on another chain’s counter.

Ensure _debit(...) increases totalBridgedOut only where outbound bridged supply must be tracked for backing, and ensure _credit(...) decreases it only on the same chain where that accounting is maintained. If inbound transfers to non-hub chains should not consume local backing, their credit path should bypass any subtraction from a local totalBridgedOut.

As part of the fix, define clear chain-specific invariants for mint, burn, debit, and credit flows so that no destination chain can execute _credit(...) against an uninitialized or insufficient local counter. Additionally, review the bridge receive path to ensure inbound messages remain executable and cannot strand funds due to local accounting underflow.

Attachments

Attachments are hidden

This information is not publicly available.

Comments are hidden

This information is not publicly available.