Status DataClose notification

Overlayer Disclosed Report

Audit Report

_credit() underflow on non-hub chains permanently burns bridged tokens

Target

Target is hidden

This information is not publicly available.

Vulnerability details

Summary

OverlayerWrapCore._credit() performs totalBridgedOut -= amountReceivedLD unconditionally on every chain. On non-hub chain deployments, totalBridgedOut is permanently stuck at 0 because mint() is gated by onlyHubChain, meaning _debit() is never called to increment it. Any inbound LayerZero OFT bridge message triggers 0 - amount, causing an arithmetic underflow revert (Solidity 0.8.20 checked math). Tokens are already burned on the hub chain before this revert, resulting in permanent, irrecoverable fund loss.

Root Cause

File: OverlayerWrapCore.sol, lines 537-544:

function credit( address to, uint256 amountLD_, uint32 srcEid_ ) internal virtual override returns (uint256 amountReceivedLD) { amountReceivedLD = super.credit(to, amountLD_, srcEid_); totalBridgedOut -= amountReceivedLD; // UNDERFLOW when totalBridgedOut == 0 } totalBridgedOut (line 63) is a uint256 initialized to 0. It is only incremented in _debit() (line 525):

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; } _debit() requires tokens to exist on-chain to burn them. On non-hub chains, mint() reverts with OverlayerWrapCoreNotHubChainId (line 358), so no tokens can ever exist, _debit() is never called, and totalBridgedOut stays at 0 forever.

Circular Deadlock

This creates an unbreakable deadlock on every non-hub chain:

Cannot receive tokens: _credit() underflows Cannot mint tokens: onlyHubChain blocks it Cannot increment totalBridgedOut: no tokens to _debit() No admin setter exists for totalBridgedOut Steps to Reproduce

Deploy OverlayerWrap on chain A (hub) and chain B (non-hub) with LayerZero OFT configured User mints OW tokens on hub chain via mint() User calls send() (OFT) on hub chain to bridge 100 OW to chain B Hub chain: _debit() burns 100 OW, sets totalBridgedOut = 100 — succeeds LayerZero relays the message to chain B Chain B: _credit() calls totalBridgedOut -= 100, which is 0 - 100 = REVERT (panic 0x11) super._credit() mint is rolled back — user receives nothing on chain B Result: 100 OW permanently destroyed. No recovery path exists. Impact

Loss per tx: 100% of bridged amount, no upper bound except user balance Trigger: ANY user bridging to ANY non-hub chain. No attacker needed, normal usage triggers it. Attacker cost: Zero (or just LayerZero gas if intentionally griefing others) Recovery: Impossible. Burned tokens cannot be re-minted without admin intervention, and no admin function exists to fix totalBridgedOut or compensate the loss. Scope: Every non-hub chain deployment is affected. The OFT architecture (hubChainId parameter, onlyHubChain modifier, _debit/_credit overrides, OverlayerWrapFactory) confirms multi-chain deployment is the intended design. Proof of Concept

See attached PoC file (poc_adv001.ts). Uses the project's own OverlayerWrapMock test contract which exposes testCredit(). Proves:

totalBridgedOut == 0 on non-hub deployment mint() is blocked by onlyHubChain _credit() reverts with panic code 0x11 (arithmetic underflow) Run command: npx hardhat test .audit/exploits/poc_adv001.ts --network hardhat

Recommended Fix

Guard totalBridgedOut tracking to hub chain only, since it is only consumed by AaveHandler.supply() on hub:

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; } }

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; } }

Validation steps

Step 1: Verify totalBridgedOut is 0 on non-hub chain

Deploy OverlayerWrap with hubChainId set to a value different from the current chain's block.chainid. Call totalBridgedOut() — it returns 0.

Step 2: Verify mint() is blocked on non-hub chain

Call mint() with any valid order. It reverts with OverlayerWrapCoreNotHubChainId because block.chainid != hubChainId. This confirms no tokens can ever be minted on non-hub chains, and therefore _debit() can never be called to increment totalBridgedOut.

Step 3: Trigger the underflow

Call _credit() (via testCredit in the mock contract) with any non-zero amount. The function executes totalBridgedOut -= amountReceivedLD, which is 0 - amount. Solidity 0.8.20 checked arithmetic causes panic revert with code 0x11 (arithmetic underflow).

Step 4: Confirm permanent fund loss

On the hub chain, _debit() already burned the user's tokens and incremented totalBridgedOut. This happened in a separate transaction before LayerZero delivered the message to the non-hub chain. Since _credit() reverts on the destination, super._credit() (which mints tokens to the recipient) is rolled back. The user's tokens are burned on hub, never minted on destination. No admin function exists to recover them.

How to run the PoC:

npx hardhat test .audit/exploits/poc_adv001.ts --network hardhat

The PoC uses the project's existing OverlayerWrapMock and SixDecimalsUsd test contracts. No external dependencies needed beyond what the project already has.

Attachments

Attachments are hidden

This information is not publicly available.

Comments are hidden

This information is not publicly available.