Status DataClose notification

Overlayer Disclosed Report

Audit Report

Permanent Cross-Chain Fund Lock via Arithmetic Underflow in OverlayerWrapCore (+ 1 Medium)

Target

Target is hidden

This information is not publicly available.

Vulnerability details

Summary

Two confirmed vulnerabilities were identified in the OverlayerWrapCore contract. One is Critical severity (permanent fund lockup via arithmetic underflow) and one is Medium severity (permissionless reserve drain). Both have been validated with reproducible Proof-of-Concept tests passing on both in-memory Hardhat and mainnet-forked localhost nodes.


BUG-1 — Critical: _credit() Arithmetic Underflow (Permanent Cross-Chain Fund Lock)

Location

File: contracts/overlayer/OverlayerWrapCore.sol

// Line 537-544
function _credit(
    address to_,
    uint256 amountLD_,
    uint32 srcEid_
) internal virtual override returns (uint256 amountReceivedLD) {
    amountReceivedLD = super._credit(to_, amountLD_, srcEid_);
    totalBridgedOut -= amountReceivedLD;  // <== LINE 543: UNDERFLOW
}

Related code — _debit() increments the counter:

contracts/overlayer/OverlayerWrapCore.sol

// Line 510-527
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;  // Line 527
}

Root Cause

totalBridgedOut is a uint256 state variable that tracks tokens sent outbound via LayerZero bridges. The _credit() function, called when tokens arrive inbound from a remote chain, unconditionally subtracts the received amount:

totalBridgedOut -= amountReceivedLD;

Solidity has checked arithmetic by default. When totalBridgedOut is zero (fresh deploy) or smaller than amountReceivedLD (partial mismatch), this subtraction triggers Panic(0x11) — an irrecoverable revert.

Attack Scenario

  1. User bridges 10 OW+ from Chain A → Hub Chain via LayerZero send().
  2. Tokens are burned on Chain A (user loses them permanently).
  3. LayerZero delivers the message to the Hub Chain, calling lzReceive() → _credit().
  4. _credit() executes totalBridgedOut -= 10e18 but totalBridgedOut == 0 → Panic(0x11).
  5. The LayerZero message reverts. The user's 10 OW+ are permanently locked — they were already burned on Chain A and can never be minted on the Hub Chain.

This is not a one-time issue. It affects every incoming bridge transfer when:

  • No prior outbound debit has occurred on the hub chain.
  • The cumulative inbound credits exceed cumulative outbound debits.

Impact

  • Permanent loss of user funds — bridged tokens are burned on source chain but can never arrive.
  • Complete DoS of inbound cross-chain transfers on the hub chain.
  • Requires zero attacker interaction — happens organically the first time anyone bridges tokens inbound.
  • Cannot be fixed post-deployment without a contract upgrade (the state variable is permanently stuck).

PoC Test Results

cyber@cyber-VMware-Virtual-Platform:~/hackenproof/contracts$  npx hardhat test test/CriticalAuditPoC.ts --network hardhat 2>&1

  Confirmed Vulnerability PoC — Overlayer Audit
    CRITICAL: _credit underflow blocks all incoming bridge transfers
[PRE]  totalBridgedOut: 0
[FAIL] _credit( 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 , 10.0 OW+ ) => REVERTED
[!]    User's 10 OW+ remain PERMANENTLY LOCKED on source chain
      ✔ reverts with Panic(0x11) when totalBridgedOut == 0 and _credit is called
[PRE]  totalBridgedOut after 5 OW+ debit: 5.0
[FAIL] _credit(alice, 10 OW+) reverts — only 5 was debited
[!]    10 OW+ permanently locked on source chain
      ✔ also reverts when totalBridgedOut > 0 but less than incoming amount
[OK]   Exact debit-credit pair succeeds. totalBridgedOut back to 0
      ✔ succeeds only when credit exactly matches prior debit (happy path proof)
    MEDIUM: permissionless supplyToBacking drains local reserves
[PRE]  OverlayerWrap USDT reserves: 200.0
[PRE]  Bob has COLLATERAL_MANAGER_ROLE? false
[POST] OverlayerWrap USDT reserves: 0.0
[!]    Bob drained ALL 200 USDT reserves without any role
      ✔ unprivileged Bob forces ALL collateral from OverlayerWrap to backing
[ROUND 1] Bob drained 50 USDT from reserves
[ROUND 2] Bob drained 100 USDT from reserves
[!]       Attacker can repeat indefinitely — no cost, no role needed
      ✔ griefing: Bob repeatedly drains reserves after each new mint

Recommendation

Replace the unchecked subtraction with safe handling that accounts for legitimate inbound-first scenarios:

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

Alternatively, if the protocol invariant requires strict debit-before-credit ordering, enforce it explicitly with a descriptive revert (not a raw Panic) and document the required operational flow.


BUG-2 — Medium: supplyToBacking() Is Fully Permissionless (Griefing Reserve Drain)

Location

File: contracts/overlayer/OverlayerWrapCore.sol

// Line 238-276
function supplyToBacking(
    uint256 amountCollateral_,
    uint256 amountACollateral_
) external nonReentrant whenNotPaused {     // <== NO ACCESS CONTROL
    if (approvedCollateralSpender == address(0)) {
        revert OverlayerWrapCoreInvalidZeroAddress();
    }
    uint256 collateralBal = IERC20(collateral.addr).balanceOf(address(this));
    uint256 aCollateralBal = IERC20(aCollateral.addr).balanceOf(address(this));
    uint256 amountToSupplyCollateral = amountCollateral_ == 0
        ? collateralBal       // <== 0 means "send EVERYTHING"
        : amountCollateral_;
    uint256 amountToSupplyACollateral = amountACollateral_ == 0
        ? aCollateralBal      // <== 0 means "send EVERYTHING"
        : amountACollateral_;
    // ... transfers all to backing
}

Root Cause

supplyToBacking() is an external function with only nonReentrant and whenNotPaused modifiers — no role-based access control. Any EOA or contract can call it.

Furthermore, passing (0, 0) as arguments triggers the "send all" code path, transferring the entire collateral and aCollateral balance from the OverlayerWrap contract to the backing contract.

Attack Scenario

  1. Alice mints 200 OW+ by depositing 200 USDT as collateral. The 200 USDT sits in the OverlayerWrap contract for instant-redeem liquidity.
  2. Bob (no roles, no tokens, no relationship to the protocol) calls overlayerWrap.supplyToBacking(0, 0).
  3. All 200 USDT are transferred from OverlayerWrap to the backing contract (Aave).
  4. Now OverlayerWrap has zero local reserves — instant redemptions may fail or be delayed.
  5. Bob repeats this after every new mint, permanently preventing the contract from holding any reserves.

Impact

  • Griefing attack with zero cost — attacker pays only gas, needs no tokens or roles.
  • Breaks instant-redeem liquidity — users who expect to redeem against local reserves cannot.
  • Repeatable indefinitely — attacker can automate a bot that front-runs every mint.
  • Funds are not stolen (they go to the legitimate backing), but the liquidity invariant the protocol relies on is permanently broken.

Recommendation

Add role-based access control to restrict supplyToBacking() to authorized callers:

function supplyToBacking(
    uint256 amountCollateral_,
    uint256 amountACollateral_
) external nonReentrant whenNotPaused onlyRole(COLLATERAL_MANAGER_ROLE) {
    // ... existing logic
}

This ensures only addresses with COLLATERAL_MANAGER_ROLE can move reserves to the backing, matching the protocol's existing access control pattern used elsewhere.


Files Used

File Purpose
test/CriticalAuditPoC.ts Hardhat test — 5 test cases covering both bugs
contracts/test/MockAuditHelpers.sol Mock contracts (MockAToken, MockAavePool, MockLzEndpoint)
contracts/test/OverlayerWrapMock.sol Existing mock exposing internal _debit() / _credit()

Validation steps

Proof Of Concept

How to Run

# On in-memory Hardhat network (no external node needed)
npx hardhat test test/CriticalAuditPoC.ts --network hardhat

# On external forked node (start `npx hardhat node` with mainnet fork first)
npx hardhat test test/CriticalAuditPoC.ts --network localhost

Expected Output

cyber@cyber-VMware-Virtual-Platform:~/hackenproof/contracts$ npx hardhat test test/CriticalAuditPoC.ts --network localhost


  Confirmed Vulnerability PoC — Overlayer Audit
    CRITICAL: _credit underflow blocks all incoming bridge transfers
[PRE]  totalBridgedOut: 0
[FAIL] _credit( 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 , 10.0 OW+ ) => REVERTED
[!]    User's 10 OW+ remain PERMANENTLY LOCKED on source chain
      ✔ reverts with Panic(0x11) when totalBridgedOut == 0 and _credit is called (7690033 gas)
[PRE]  totalBridgedOut after 5 OW+ debit: 5.0
[FAIL] _credit(alice, 10 OW+) reverts — only 5 was debited
[!]    10 OW+ permanently locked on source chain
      ✔ also reverts when totalBridgedOut > 0 but less than incoming amount (327957 gas)
[OK]   Exact debit-credit pair succeeds. totalBridgedOut back to 0
      ✔ succeeds only when credit exactly matches prior debit (happy path proof) (74002 gas)
    MEDIUM: permissionless supplyToBacking drains local reserves
[PRE]  OverlayerWrap USDT reserves: 200.0
[PRE]  Bob has COLLATERAL_MANAGER_ROLE? false
[POST] OverlayerWrap USDT reserves: 0.0
[!]    Bob drained ALL 200 USDT reserves without any role
      ✔ unprivileged Bob forces ALL collateral from OverlayerWrap to backing (14621923 gas)
[ROUND 1] Bob drained 50 USDT from reserves
[ROUND 2] Bob drained 100 USDT from reserves
[!]       Attacker can repeat indefinitely — no cost, no role needed
      ✔ griefing: Bob repeatedly drains reserves after each new mint (415408 gas)

  5 passing (42s)

cyber@cyber-VMware-Virtual-Platform:~/hackenproof/contracts$ 

eth_blockNumber
eth_sendTransaction
  Contract call:       <UnrecognizedContract>
  Transaction:         0x0cc91d077d326046879bd8d44d9ca23d7b76baba75c989de4e68b729ea00978f
  From:                0x90f79bf6eb2c4f870365e785982e1f101e93b906
  To:                  0x7ddba5379549fc746b28841d8b927ca0740072a7
  Value:               0 ETH
  Gas used:            180596 of 30000000
  Block #24787548:     0xa595f3baa9d7347691545398f89bb9ab7c88e066a171e7fdac344718c7a5199c

eth_getTransactionByHash
eth_call
  Contract call:       <UnrecognizedContract>
  From:                0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
  To:                  0xb10c5f52415c38e3c5c722656ceeff40317aa5af

eth_blockNumber
eth_sendTransaction
  Contract call:       <UnrecognizedContract>
  Transaction:         0x95f09a0cedc1624ca6e4956fc45cae371f316cbee9f4c3ad8155bc559e766f7a
  From:                0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc
  To:                  0x7ddba5379549fc746b28841d8b927ca0740072a7
  Value:               0 ETH
  Gas used:            118575 of 30000000
  Block #24787549:     0xc22239ff3de19b8a3d95c543a6a94d646397ec3811d1738c0ce05d00ade1019d

eth_getTransactionByHash
eth_call
  Contract call:       <UnrecognizedContract>
  From:                0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
  To:                  0xb10c5f52415c38e3c5c722656ceeff40317aa5af

eth_blockNumber
eth_sendTransaction
  Contract call:       <UnrecognizedContract>
  Transaction:         0x6e36ca3be770bcd64191d0d149efb9a6c69aac861a30be71c45ba87ac766f077
  From:                0x90f79bf6eb2c4f870365e785982e1f101e93b906
  To:                  0x7ddba5379549fc746b28841d8b927ca0740072a7
  Value:               0 ETH
  Gas used:            116237 of 30000000
  Block #24787550:     0x8ae0741a90a7c805e2ccd63307c886f7e30ddb1b2e48472c710cb1b0c7bf1bc0

eth_getTransactionByHash
eth_call
  Contract call:       <UnrecognizedContract>
  From:                0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
  To:                  0xb10c5f52415c38e3c5c722656ceeff40317aa5af

eth_getBlockByNumber (2)
eth_getTransactionReceipt
eth_getCode

Video File:

Video of PoC

Attachments

Attachments are hidden

This information is not publicly available.

Comments are hidden

This information is not publicly available.