Status DataClose notification

Overlayer Disclosed Report

Audit Report

Cross-Chain Credits Underflow and Permanently Brick Hub-to-Satellite Transfers

Target

Target is hidden

This information is not publicly available.

Vulnerability details

  • Impact: Any user bridging from the hub to a fresh satellite can have their source-chain tokens burned while the destination-chain credit reverts. This permanently locks bridged funds until the contracts are upgraded or a manual recovery path is introduced. In practice, it also shuts down the core hub-to-satellite bridge path for the protocol.

  • Description: OverlayerWrapCore tracks totalBridgedOut as if debits and credits happen on the same contract instance. On the source chain, _debit() burns tokens and increments totalBridgedOut. On the destination chain, _credit() always decrements totalBridgedOut. In an OFT deployment, those two functions execute on different chain instances. That means any destination instance can only process inbound credits up to the amount it has previously debited itself. A fresh satellite starts with totalBridgedOut == 0, so the first inbound credit from the hub executes totalBridgedOut -= amountReceivedLD and underflows, reverting the LayerZero delivery. More generally, any inbound transfer where amountReceivedLD > destination.totalBridgedOut() reverts. The bug is in the core accounting itself, not in a deploy script. Evidence:

    • contracts/overlayer/OverlayerWrapCore.sol: _debit() unconditionally increments totalBridgedOut and _credit() unconditionally decrements it.
    • contracts/overlayer/OverlayerWrapFactory.sol: the token is designed to be deployed as an OFT with a configurable hubChainId.
    • scripts/utils/deployAllSepolia.ts: the project explicitly uses pre-deployed OFT instances, confirming multi-chain operation is intended.
    • test/OverlayerWrap.ts: the bridge tests only call testDebit() and testCredit() on the same contract instance, so they never exercise the real two-instance cross-chain path where the underflow appears.

Validation steps

  • PoC Scenario:

    1. Deploy OverlayerWrap on the hub chain with hubChainId = HUB_CHAIN_ID and normal backing.
    2. Deploy a second OverlayerWrap OFT peer on a satellite chain, also configured with the same hubChainId = HUB_CHAIN_ID.
    3. Mint 100e18 OverlayerWrap on the hub through the normal collateralized mint flow.
    4. Initiate a LayerZero OFT send of 10e18 from the hub instance to the satellite instance.
    5. On the hub, _debit() executes successfully, burns 10e18, and sets hub.totalBridgedOut += 10e18.
    6. LayerZero delivers the message to the satellite. The satellite instance executes _credit().
    7. Because this satellite has never debited tokens before, satellite.totalBridgedOut == 0.
    8. _credit() executes satellite.totalBridgedOut -= 10e18, which underflows in Solidity 0.8 and reverts.
    9. Result: the destination mint never happens, the source-side burn already happened, and the user’s bridged balance is stuck in a failed message state. Every first inbound transfer to a fresh satellite instance fails the same way.
  • Runnable PoC: A self-contained two-instance Hardhat PoC was added to this workspace:

    • project/repo/test/PoC.BridgeCreditUnderflow.ts
    • project/repo/hardhat.poc.config.js
    • project/repo/poc-contracts/MockLayerZeroEndpointV2.sol
    • project/repo/poc-contracts/PoCImports.sol

    The test deploys:

    1. a mock LayerZero endpoint,
    2. a mock 6-decimal collateral token,
    3. a mock 6-decimal aCollateral token,
    4. one OverlayerWrapMock instance as the hub,
    5. one separate OverlayerWrapMock instance as the satellite.

    It then:

    1. mints 100e18 OverlayerWrap on the hub for alice,
    2. calls hub.testDebit(alice, 10e18, 10e18, 30101) so the hub burns 10e18 and records hub.totalBridgedOut == 10e18,
    3. calls satellite.testCredit(alice, 10e18, 30101),
    4. observes a Solidity panic 0x11 because satellite.totalBridgedOut == 0 and _credit() executes totalBridgedOut -= amountReceivedLD.

    Command used:

node ./node_modules/hardhat/internal/cli/bootstrap.js test --config hardhat.poc.config.js test/PoC.BridgeCreditUnderflow.ts
Observed result:
    PoC: bridge credit underflow
        ✔ burns on the source instance and reverts on the first credit to a fresh peer (2444ms)


    1 passing (2s)
The test also asserts that after the revert:
- the hub-side user balance is reduced by `10e18`,
- `hub.totalBridgedOut == 10e18`,
- the satellite user balance is still `0`,
- the satellite total supply is still `0`.
This demonstrates actual source-side loss of spendable balance combined with destination-side failure.
  • Recommended Fix: Track totalBridgedOut only on the hub instance, because only the hub needs the value for collateral-backing accounting. A minimal fix is:
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_
    );

    if (block.chainid == hubChainId) {
        totalBridgedOut += amountSentLD;
    }
}

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

    if (block.chainid == hubChainId) {
        totalBridgedOut -= amountReceivedLD;
    }
}

Attachments

Attachments are hidden

This information is not publicly available.

Comments are hidden

This information is not publicly available.