Status DataClose notification

Overlayer Disclosed Report

Audit Report

Permanent user-fund lockout on every fresh OverlayerWrap spoke deployment via `_credit` `totalBridgedOut` underflow

Target

Target is hidden

This information is not publicly available.

Vulnerability details

1. Summary

OverlayerWrapCore._credit performs an unguarded totalBridgedOut -= amountReceivedLD under Solidity 0.8 checked arithmetic. The totalBridgedOut counter is only incremented by _debit (outbound OFT burn on the local chain) and decremented by _credit (inbound OFT mint on the local chain); there is no initializer, admin setter, rescue function, or migration routine that writes to it from any other path.

On any chain where block.chainid != hubChainId (i.e., every spoke-chain deployment), the protocol's own onlyHubChain modifier at OverlayerWrapCore.sol:358 and :377 forbids the local user-facing mint() and redeem() paths. A spoke therefore has no way to ever generate an outbound _debit before it has received an inbound _credit — spokes only exist to receive OVA from the hub.

As a consequence, on every freshly deployed spoke:

  1. totalBridgedOut begins at 0.
  2. The first inbound LayerZero OFT message invokes _credit(to, amount, srcEid).
  3. super._credit(...) mints amount OVA to the recipient via OFT._credit → _mint.
  4. totalBridgedOut -= amountReceivedLD executes on a zero counter, triggers Solidity 0.8's checked-arithmetic underflow, and reverts with Panic(0x11).
  5. LayerZero's executor cannot retry past a deterministic revert. The message is stuck in the delivery queue forever.
  6. The hub-side _debit already burned the user's OVA and credited totalBridgedOut on the hub. From the user's perspective the tokens are gone on the origin chain and will never land on the destination chain.

There is no on-chain recovery path. OverlayerWrap is not upgradeable; totalBridgedOut has no admin setter; no rescue routine exists. Unbricking a spoke requires either deploying a new contract, treasury-funded out-of-band compensation, or a proxy upgrade that the protocol does not support.

100% of the cross-chain value that any user bridges to any fresh spoke is permanently locked until an off-protocol remediation is performed.


2. Impact and Hackenproof qualification

High impact ✔

  • Permanent lockout of end-user funds. Every bridged amount is 100% lost on the destination side. This is the prototypical "permanent lockout" case the program rules enumerate.
  • Exceeds 2% of TVL. On any spoke deployment that the protocol intends for live use, the impact is 100% of the spoke's expected cross-chain inbound flow. The Overlayer protocol's own hubChainId constructor parameter and its onlyHubChain gating pattern make spoke deployment a documented operating mode.
  • Exceeds 1% of a user's deposit. The victim's entire bridged amount is lost, not 1%.

High likelihood ✔

  • No privileged role required. Any end user triggering an OFT send() from the hub to a fresh spoke is sufficient. The victim's own transaction hands the spoke its first inbound message.
  • No significant token balance required. Per the determinism test below, even a 1-wei credit reverts.
  • No significant computation. A single cross-chain message.
  • Very few preconditions. Only one: the spoke has not yet received a prior credit. This is the default state for every fresh spoke deployment.
  • Not a rogue-admin scenario. The failure is triggered by natural user behavior, not by any privileged action. Program rules about "rogue privileged users" do not apply.

3. Root-cause walk-through

3.1 The vulnerable function

contracts/overlayer/OverlayerWrapCore.sol:537–544:

/// @dev Mints tokens on the destination chain; this override decrements totalBridgedOut
///      to mirror the hub-side _debit increment. Used exclusively by LayerZero OFT delivery.
function _credit(
    address to_,
    uint256 amountLD_,
    uint32 srcEid_
) internal virtual override returns (uint256 amountReceivedLD) {
    amountReceivedLD = super._credit(to_, amountLD_, srcEid_);
    totalBridgedOut -= amountReceivedLD;   //  <-- UNGUARDED, underflows on any fresh spoke
}

super._credit routes through OFT._credit in @layerzerolabs/oft-evm/contracts/OFT.sol, which mints amountLD_ tokens to to_. The subtraction on the next line then executes unconditionally.

3.2 Why totalBridgedOut is always zero on a fresh spoke

The only writers of totalBridgedOut across the entire in-scope codebase are:

// contracts/overlayer/OverlayerWrapCore.sol:527 — _debit (outbound OFT send)
totalBridgedOut += amountSentLD;

// contracts/overlayer/OverlayerWrapCore.sol:543 — _credit (inbound OFT receive)
totalBridgedOut -= amountReceivedLD;

Grepping the tree at commit 519c9e9:

$ git grep -n totalBridgedOut contracts/
contracts/overlayer/OverlayerWrapCore.sol:63:    uint256 public totalBridgedOut;
contracts/overlayer/OverlayerWrapCore.sol:527:        totalBridgedOut += amountSentLD;
contracts/overlayer/OverlayerWrapCore.sol:543:        totalBridgedOut -= amountReceivedLD;
contracts/overlayerbacking/AaveHandler.sol:241: (read only, in supply accounting)

No setter, no initializer assignment, no rescue function. The counter has exactly two writers and both live inside OFT delivery hooks.

3.3 Why the spoke cannot bootstrap its own counter

contracts/overlayer/OverlayerWrapCore.sol:77–82:

modifier onlyHubChain(uint256 chainId_) {
    if (chainId_ != hubChainId) {
        revert OverlayerWrapCoreNotHubChainId();
    }
    _;
}

Applied at :358 (_managerMint) and :377 (_managerRedeem):

function _managerMint(Order memory order_)
    internal
    onlyHubChain(block.chainid)
    belowMaxMintPerBlock(order_.overlayerWrapAmount)
{ ... }

function _managerRedeem(Order memory order_)
    internal
    onlyHubChain(block.chainid)
    returns (uint256 checkedBurnAmount, uint256 actualCollateralAmount)
{ ... }

A spoke (where block.chainid != hubChainId) cannot locally mint — so it cannot hold OVA until someone bridges OVA in. It therefore cannot produce an outbound _debit to seed totalBridgedOut. The very first operation any spoke will ever see is an inbound _credit, which underflows.

3.4 The deterministic revert

Solidity ^0.8.20 applies checked arithmetic by default. uint256(0) - uint256(1) reverts with Panic(0x11) (arithmetic underflow). LayerZero's executor, which invokes lzReceive on the destination contract, cannot succeed on a reverting message — the executor treats it as undeliverable. The message sits in the queue; retries hit the exact same deterministic Panic. There is no probabilistic recovery.


4. Proof of concept

Two Foundry tests, both passing against the real mainnet fork at block 22000000, demonstrate the bug end-to-end:

4.1 Setup (mainnet fork)

# audit-foundry/.env
MAINNET_RPC_URL=https://eth.drpc.org
FORK_BLOCK_NUMBER=22000000
# audit-foundry/foundry.toml excerpt
[profile.default]
evm_version = "shanghai"
fs_permissions = [{ access = "read", path = "../target-repo" }]
allow_paths = ["../target-repo"]

remappings = [
  "@openzeppelin/=../target-repo/node_modules/@openzeppelin/",
  "@aave/=../target-repo/node_modules/@aave/",
  "@layerzerolabs/=../target-repo/node_modules/@layerzerolabs/",
  "forge-std/=lib/forge-std/src/",
  "overlayer/=../target-repo/contracts/",
]

4.2 End-to-end exploit — alice loses 10,000 USDT

audit-foundry/test/fork/D1_R2H1_Critical_Exploit.t.sol (attached verbatim). Key steps:

  1. Deploy the full production hub stack on the fork against the real Aave V3 pool + real LayerZero V2 endpoint. Uses OverlayerWrapMock (which inherits OverlayerWrap and exposes the internal _debit / _credit hooks as external testDebit / testCredit for harness access — the hook bodies are unchanged from production).
  2. Deploy a second OverlayerWrapMock with hubChainId = 999. Because this fork's block.chainid == 1, this second instance is a spoke by construction.
  3. Impersonate the Binance 8 USDT whale and transfer 10,000 USDT to alice.
  4. Alice calls hub.mint(...) with 10,000 USDT collateral, receives 10,000 OVA on the hub.
  5. Alice calls hub.testDebit(alice, 10,000e18, 10,000e18, 0) — this is the production OFT outbound path. Hub burns her 10,000 OVA; hub.totalBridgedOut becomes 10,000e18.
  6. LayerZero "delivers" to the spoke. We simulate the delivery by calling spoke.testCredit(alice, 10,000e18, 1) — this invokes the exact same overridden _credit function that LayerZero's executor would call through OFTCore._lzReceive.
  7. Panic(0x11) — the call reverts.
  8. Final state: alice holds 0 USDT, 0 hub OVA, 0 spoke OVA. 10,000 USDT of user capital is permanently locked.

4.3 Test runner output

$ cd audit-foundry
$ source .env
$ forge test --fork-url "$MAINNET_RPC_URL" --fork-block-number "$FORK_BLOCK_NUMBER" \
    --match-path test/fork/D1_R2H1_Critical_Exploit.t.sol -vv

Ran 3 tests for test/fork/D1_R2H1_Critical_Exploit.t.sol:D1_R2H1_CriticalExploit
[PASS] test_CRITICAL_R2H1_alice_loses_10000_USDT_permanently_on_first_spoke_receive() (gas: 260948)
Logs:
  ======================================================================
  R2-H1 LIVE-FORK EXPLOIT -- permanent user-fund lockout
  Fork: Ethereum mainnet @ block 22000000
  Hub OverlayerWrap      0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f
  Spoke OverlayerWrap    0xc7183455a4C133Ae270771860664b6B7ec320bB1
  Alice                  0xEb9F452b269dA9ca2aab546018abF0A0615476ea
  ======================================================================
  [STEP 1] Alice starts with 10000000000 USDT (6dp)
  [STEP 1] Alice minted 10000000000000000000000 OVA on hub (18dp)
  [STEP 2] Alice bridged 10000000000000000000000 OVA out of hub (testDebit)
  [STEP 2] hub.balanceOf(alice)    = 0
  [STEP 2] hub.totalBridgedOut()   = 10000000000000000000000
  [STEP 3] Spoke.totalBridgedOut BEFORE delivery: 0
  [STEP 3] REVERT confirmed: Panic(0x11) on first spoke inbound credit
  ======================================================================
  LOSS QUANTIFICAT

Validation steps

Please follow POC section.

Attachments

Attachments are hidden

This information is not publicly available.

Comments are hidden

This information is not publicly available.