Status DataClose notification

Overlayer Disclosed Report

Audit Report

OverlayerWrapCore._credit() has an arithmetic underflow that permanently destroys all tokens bridged to non-hub chains

Target

Target is hidden

This information is not publicly available.

Vulnerability details

OverlayerWrapCore overrides LayerZero's _credit() to track bridged amounts via totalBridgedOut. The problem is it decrements that counter on every chain, not just the hub. On non-hub chains totalBridgedOut starts at 0 and can't ever be incremented because minting is restricted to the hub chain via the onlyHubChain modifier. The first _credit() call on any non-hub chain hits a Solidity 0.8.x arithmetic underflow and reverts.

This isn't a conditional edge case. It's a guaranteed revert on 100% of cross-chain bridge operations to any non-hub chain. Every token bridged is permanently destroyed, the source chain burns them, the destination chain can't mint them, and LayerZero's recovery functions don't help.

Root cause

The bug is at 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; // underflow: totalBridgedOut == 0 on non-hub
}

The contract's own NatSpec at L530-532 says this tracks "tokens returning to the hub chain from cross-chain transfers." But the code applies it unconditionally on all chains. That's the mismatch.

The standard LayerZero OFT _credit() just mints tokens. Overlayer added the totalBridgedOut decrement for AaveHandler.supply() calculations on the hub chain, where owTotalSupp = totalSupply() + totalBridgedOut() (L239-241). That accounting has zero utility on non-hub chains since there's no AaveHandler there.

There's no guard on the subtraction: no if (block.chainid == hubChainId) check, no if (totalBridgedOut >= amount) check, no unchecked block, no admin setter to initialize the counter. It's a complete deadlock, you can't credit without a prior debit, can't debit without tokens, can't get tokens without a credit.

Attack path

This doesn't even need an attacker. Any normal user bridging tokens triggers permanent fund loss:

User calls send() on the hub chain to bridge tokens to Arbitrum _debit() burns the tokens from the user's balance and increments totalBridgedOut on the hub. This is final LayerZero delivers the message to the Arbitrum deployment _credit() tries totalBridgedOut -= amount. Since totalBridgedOut is 0 on Arbitrum, this reverts with panic 0x11 The message gets stored as failed. Every retry triggers the same underflow LayerZero v2's recovery functions (clear(), skip(), nilify(), burn()) only manage the message queue. None of them mint tokens on the destination. The source burn is already done

Impact

Cross-chain bridging is the core feature, the contract inherits from LayerZero OFT specifically for this. hubChainId as constructor parameter and onlyHubChain modifier confirms multichain is by design

The issue is that every token bridged to any non-hub chain is irreversibly destroyed creating permanent loss of funds. Even 1 wei triggers it

This scales linearly with bridged volume, the more users bridge, the more is lost, is just a matter of users/time. Also there are no recovery path. The contract isn't upgradeable (no proxy, no UUPS). Fixing requires full redeployment + balance migration

Side notes: Live deployments on Optimism Sepolia (0xfd0E0c5132B1C0C59A413e52f97BC421592Ba460) and Arbitrum Sepolia (0xE885D037099B3FaCf2f80f3D1c14C7086de520b3)

Validation steps

Step 1 -- Identify the vulnerable line

Open OverlayerWrapCore.sol#L543. Note totalBridgedOut -= amountReceivedLD with no chain-id guard. On non-hub chains, totalBridgedOut is always 0.

Step 2 -- Confirm non-hub chains can't increment totalBridgedOut

Search for all writes to totalBridgedOut:

  • _debit() at L527: totalBridgedOut += amountSentLD -- but _debit() also has no chain guard, so technically it can increment on non-hub. However, on non-hub chains there are no tokens to debit (minting is hub-only via onlyHubChain at L358). Deadlock.

Step 3 -- Confirm minting is hub-only

Open OverlayerWrapCore.sol#L358. The mint() function has onlyHubChain modifier. No tokens can ever exist on non-hub chains except through _credit() -- which reverts.

Step 4 -- Confirm no upgrade path

Check for proxy patterns: no UUPSUpgradeable, no TransparentUpgradeableProxy, no delegatecall. The contract is immutable once deployed.

Step 5 -- Run the PoC

git clone https://github.com/Overlayerfi/contracts.git && cd contracts
npm install && forge install
# Paste the PoC file into test/PoC_CreditUnderflow.t.sol
forge test --match-contract PoC_CreditUnderflow --skip "contracts/uniswap/*" -vvv

Expected output:

[PASS] test_credit_underflow_non_hub() (gas: 82027)
[PASS] test_even_one_wei_reverts() (gas: 68497)
[PASS] test_deadlock_no_mint_on_non_hub() (gas: 26627)
[PASS] test_credit_works_only_after_debit_on_hub() (gas: 226072)
Suite result: ok. 4 passed; 0 failed; 0 skipped

Step 6 -- Verify the fix

Gate totalBridgedOut tracking behind if (block.chainid == hubChainId) in both _debit() and _credit(). The counter is only consumed by AaveHandler.supply() on the hub chain anyway.

Attachments

Attachments are hidden

This information is not publicly available.

Comments are hidden

This information is not publicly available.