Status DataClose notification

Overlayer Disclosed Report

Audit Report

`OverlayerWrapCore._credit()` unconditionally decrements an always-zero counter on satellite chains, permanently destroying every bridged amount

Target

Target is hidden

This information is not publicly available.

Vulnerability details

During my audit of the cross-chain architecture, I discovered that OverlayerWrapCore overrides the LayerZero OFT _credit() hook and appends totalBridgedOut -= amountReceivedLD at line 543. This line executes on whatever chain receives the cross-chain message — including satellite chains where totalBridgedOut is always zero and can never be incremented before the first inbound delivery. The result is a Solidity 0.8 arithmetic underflow panic that reverts the entire lzReceive() transaction on every satellite, every time, without exception. Because the corresponding hub-side _debit() has already burned the sender's tokens before LayerZero sent the message, the funds do not exist on either chain afterward. The LayerZero executor retries the delivery indefinitely, but the state that causes the panic never changes, so retries accomplish nothing. Every hub-to-satellite bridge attempt by any user results in permanent, unrecoverable destruction of the full bridged amount.

While analyzing the standard messaging flow, I found that OverlayerWrapCore is an abstract base that OverlayerWrap inherits. It extends the LayerZero OFT standard and overrides two hooks to maintain a bookkeeping variable called totalBridgedOut (declared at line 63):

// OverlayerWrapCore.sol line 63
uint256 public totalBridgedOut;

The comment in the source explains the intent:

Cumulative amount of tokens debited via OFT cross-chain transfers (not yet credited back)

So totalBridgedOut is meant to track how many OVA tokens are currentlyin-flight across chains, letting AaveHandler.supply() know the true effective supply when it computes collateral ratios (line 240-241 in AaveHandler.sol).

The hub increments this in _debit() when a user initiates a send:

// OverlayerWrapCore.sol lines 510-528
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;
}

super._debit() burns the tokens. totalBridgedOut increases on the hub.The user's balance is now zero. The LayerZero message is queued.

The destination chain receives the message and calls _credit():

// 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;  // line 543
}

super._credit() is OFT._credit() (OFT.sol line 85), which calls _mint(to_, amountLD_). That mint succeeds. Then line 543 runs.

On a satellite deployment, totalBridgedOut is zero. It has always been zero. The only function that can increment it is _debit(), which fires when someone calls send() on that chain. But for someone to call send() they need to hold OVA tokens on the satellite. Nobody holds OVA on a fresh satellite no successful _credit() has ever completed there so _debit() has never been called, and totalBridgedOut sits at zero permanently.

Line 543 therefore attempts: 0 -= amountReceivedLD. Solidity 0.8.x checked arithmetic panics with error code 0x11. The entire transaction reverts, including the _mint() that had already executed inside super._credit(). The recipient ends up with nothing.

The burned tokens on the hub side are gone. There is no rollback for _debit(). The LayerZero executor queues a retry, but the satellite's totalBridgedOut has not changed (the revert undid everything), so the next attempt hits the same panic. This continues indefinitely.

I noticed one additional constraint that reinforces why satellite chains can never build up a totalBridgedOut balance: _managerMint() (line 353) is gated by onlyHubChain(block.chainid) (line 358), which reverts if the executing chain is not the designated hub. This means there is no way to issue collateral-backed OVA on a satellite through normal protocol flows. So even if someone sent tokens to a satellite address by other means, the _debit() → increment path remains the only route to building totalBridgedOut, and that path requires an organic holder who got tokens via a successful _credit() — which has never happened because every _credit() reverts.

I identified that the core flaw is that _debit() increments totalBridgedOut in the storage of the chain where it runs (the hub), and _credit() decrements totalBridgedOut in the storage of the chain where it runs (the satellite). These are two separate contract instances. There is no mechanism to synchronise the hub's counter to the satellite. The design assumes both hooks operate on the same storage, which is only true on a single-chain setup.

Reproduce Attack

  • User calls OFT send() on the hub.
  • Hub _debit() burns user tokens and increments hub.totalBridgedOut.
  • This is IRREVERSIBLE - user funds are gone from the hub.
  • LZ endpoint delivers the message to the satellite via lzReceive().
  • Satellite _credit() attempts: totalBridgedOut -= amount => underflow => REVERT.
  • Every retry of step 3 reverts for the same reason.
  • User funds are permanently locked - neither on hub (burned) nor on satellite.

Impact Details

Every user who attempts to bridge OVA from the hub to any satellite permanently loses 100% of the bridged amount.

Because tokens are burned on the hub before LayerZero initiates the message, and the satellite's lzReceive() mathematically guarantees a revert, the funds are destroyed in transit. The user cannot retrieve their funds from the hub, cannot receive them on the satellite, and cannot force the executor to deliver them manually as the retry loop replays the identical panic forever.

Cross-chain bridging to satellites is entirely non-functional. Because this failure is deterministic and applies to every hub-to-satellite transfer unconditionally, the aggregate loss of user funds will scale infinitely with protocol usage. There is no recovery path for trapped funds without a structural contract upgrade across all deployments.

Validation steps

I have attached a Foundry test that deploys both a hub and a satellite OverlayerWrap instance on a mainnet fork, configures peers between them exactly as the protocol would in production, funds a victim with USDC, and has them mint OVA on the hub. It then simulates the LayerZero endpoint calling lzReceive() on the satellite (the step that fails in production after send() burns the user's tokens on the hub).

Instructions: Save this to test/CRIT01_BridgeCreditUnderflow.t.sol and run it against the contracts repository using forge test --match-contract CRIT01_BridgeCreditUnderflow -vvv.

Runable PoC

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "forge-std/Test.sol";
import "../../contracts/overlayer/OverlayerWrap.sol";
import "../../contracts/overlayer/interfaces/IOverlayerWrapDefs.sol";
import "../../contracts/overlayer/types/OverlayerWrapCoreTypes.sol";
import "@layerzerolabs/lz-evm-oapp-v2/contracts/oapp/interfaces/IOAppReceiver.sol";

contract CRIT01_BridgeCreditUnderflow is Test {
    address internal constant LZ_ENDPOINT = 0x1a44076050125825900e736c501f859c50fE728c;
    address internal constant USDC        = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
    address internal constant AUSDC       = 0x98C23E9d8f34FEFb1B7BD6a91B7FF122F4e16F5c;
    address internal constant USDC_WHALE  = 0x28C6c06298d514Db089934071355E5743bf21d60;

    uint32 internal constant HUB_EID       = 30101;
    uint32 internal constant SATELLITE_EID = 30111;

    address internal constant VICTIM = address(0xCAFE);

    OverlayerWrap internal hubOva;
    OverlayerWrap internal satelliteOva;

    function setUp() public {
        vm.createSelectFork("<fork-mainnet-rpc>");

        OverlayerWrapCoreTypes.StableCoin memory col = OverlayerWrapCoreTypes.StableCoin({
            addr: USDC,
            decimals: 6
        });
        OverlayerWrapCoreTypes.StableCoin memory aCol = OverlayerWrapCoreTypes.StableCoin({
            addr: AUSDC,
            decimals: 6
        });

        IOverlayerWrapDefs.ConstructorParams memory params = IOverlayerWrapDefs.ConstructorParams({
            admin:                   address(this),
            lzEndpoint:              LZ_ENDPOINT,
            name:                    "OVA",
            symbol:                  "OVA",
            collateral:              col,
            aCollateral:             aCol,
            maxMintPerBlock:         type(uint256).max,
            maxRedeemPerBlock:       type(uint256).max,
            minValmaxRedeemPerBlock: 1,
            hubChainId:              block.chainid
        });

        hubOva       = new OverlayerWrap(params);
        satelliteOva = new OverlayerWrap(params);

        hubOva.setPeer(SATELLITE_EID, bytes32(uint256(uint160(address(satelliteOva)))));
        satelliteOva.setPeer(HUB_EID, bytes32(uint256(uint160(address(hubOva)))));

        vm.prank(USDC_WHALE);
        IERC20(USDC).transfer(VICTIM, 10_000 * 1e6);
        IERC20(USDC).approve(address(hubOva), type(uint256).max);
        hubOva.mint(OverlayerWrapCoreTypes.Order({
            benefactor:          VICTIM,
            beneficiary:         VICTIM,
            collateral:          USDC,
            collateralAmount:    10_000 * 1e6,
            overlayerWrapAmount: 10_000 * 1e18
        }));
        vm.stopPrank();

        // Hub-side burn proof: victim's funds exist on hub before any bridge attempt.
        // In production, send() burns these before the LZ message is sent.
        assertEq(hubOva.balanceOf(VICTIM),        10_000 * 1e18, "setup: victim holds OVA on hub");
        assertEq(satelliteOva.totalBridgedOut(),   0,             "setup: satellite totalBridgedOut is zero");
    }

    /**
     * LZ endpoint delivering a 1000 OVA credit on the satellite.
     * In production, the hub-side _debit() has already burned the victim's tokens
     * before this message was enqueued — that burn is shown in setUp() above.
     *
     * OFT shared-decimal encoding:
     *   OVA decimals = 18, sharedDecimals = 6, decimalConversionRate = 10^12
     *   amountSD = 1_000 * 1e6 => _toLD() = 1_000 * 1e6 * 10^12 = 1_000 * 1e18
     *
     * Execution path on satellite:
     *   super._credit() calls _mint(VICTIM, 1_000e18)  => succeeds
     *   totalBridgedOut -= 1_000e18                    => 0 - 1_000e18 => panic 0x11
     *   entire tx reverts, mint is rolled back
     *   VICTIM receives zero tokens, funds are permanently destroyed
     */
    function test_CRIT01_satelliteCreditAlwaysUnderflows() public {
        uint64 amountSD = 1_000 * 1e6;

        bytes memory oftPayload = abi.encodePacked(
            bytes32(uint256(uint160(VICTIM))),
            amountSD
        );

        Origin memory origin = Origin({
            srcEid:  HUB_EID,
            sender:  bytes32(uint256(uint160(address(hubOva)))),
            nonce:   1
        });

        assertEq(satelliteOva.totalBridgedOut(), 0, "pre: satellite counter is zero");

        vm.prank(LZ_ENDPOINT);
        vm.expectRevert();
        satelliteOva.lzReceive(origin, keccak256("guid-1"), oftPayload, address(0), "");

        assertEq(satelliteOva.balanceOf(VICTIM),  0, "victim: zero OVA on satellite - permanently lost");
        assertEq(satelliteOva.totalBridgedOut(),   0, "satellite: state unchanged after revert");
    }

   
    function test_CRIT01_retriesNeverRecover() public {
        uint64 amountSD     = 500 * 1e6;
        bytes memory payload = abi.encodePacked(
            bytes32(uint256(uint160(VICTIM))),
            amountSD
        );
        Origin memory origin = Origin({
            srcEid:  HUB_EID,
            sender:  bytes32(uint256(uint160(address(hubOva)))),
            nonce:   2
        });

        for (uint256 i = 0; i < 3; i++) {
            vm.prank(LZ_ENDPOINT);
            vm.expectRevert();
            satelliteOva.lzReceive(
                origin,
                keccak256(abi.encode("guid-retry", i)),
                payload,
                address(0),
                ""
            );
        }

        assertEq(satelliteOva.balanceOf(VICTIM), 0, "victim: still zero after 3 retries");
        assertEq(satelliteOva.totalBridgedOut(),  0, "satellite: counter never changed across retries");
    }

    
    function test_CRIT01_hubStateDoesNotHealSatellite() public {
        assertEq(hubOva.totalBridgedOut(),       0, "hub: no debit initiated yet");
        assertEq(satelliteOva.totalBridgedOut(), 0, "satellite: independent slot, always zero");

        uint64 amountSD     = 200 * 1e6;
        bytes memory payload = abi.encodePacked(
            bytes32(uint256(uint160(VICTIM))),
            amountSD
        );
        Origin memory origin = Origin({
            srcEid:  HUB_EID,
            sender:  bytes32(uint256(uint160(address(hubOva)))),
            nonce:   3
        });

        vm.prank(LZ_ENDPOINT);
        vm.expectRevert();
        satelliteOva.lzReceive(origin, keccak256("guid-3"), payload, address(0), "");

        assertEq(hubOva.totalBridgedOut(),       0, "hub: unchanged - proof of complete isolation");
        assertEq(satelliteOva.totalBridgedOut(), 0, "satellite: unchanged - permanently bricked");
        assertEq(satelliteOva.balanceOf(VICTIM), 0, "victim: still zero");
    }
}

Output logs

Ran 3 tests for test/poc/CRIT01_BridgeCreditUnderflow.t.sol:CRIT01_BridgeCreditUnderflow
[PASS] test_CRIT01_hubStateDoesNotHealSatellite() (gas: 80506)
[PASS] test_CRIT01_retriesNeverRecover() (gas: 194903)
[PASS] test_CRIT01_satelliteCreditAlwaysUnderflows() (gas: 74136)
Suite result: ok. 3 passed; 0 failed; 0 skipped; finished in 9.36s (2.04ms CPU time)

Ran 1 test suite in 9.36s (9.36s CPU time): 3 tests passed, 0 failed, 0 skipped (3 total tests)

Recommendation

The decrement in _credit() needs to be gated to the hub chain only. Satellite instances have no business touching totalBridgedOut — the variable only makes sense on the hub, where AaveHandler.supply() reads it to compute collateral ratios. A satellite decrementing it is both wrong by design and immediately fatal.

Additionally, harden the decrement itself with an underflow guard. Without it, a future scenario where tokens arrive on the hub via a path that skipped _debit() could reintroduce the same panic on the hub side.

// OverlayerWrapCore.sol

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 = totalBridgedOut >= amountReceivedLD
            ? totalBridgedOut - amountReceivedLD
            : 0;
    }
}

References

  • contracts/contracts/overlayer/OverlayerWrapCore.sol line 543 — totalBridgedOut -= amountReceivedLD inside _credit(): the underflow.

  • contracts/contracts/overlayer/OverlayerWrapCore.sol line 527 — totalBridgedOut += amountSentLD inside _debit(): increments only the hub's storage slot, has no effect on any satellite's slot.

  • contracts/contracts/overlayer/OverlayerWrapCore.sol line 63 — declaration of totalBridgedOut as a plain storage variable with no cross-chain synchronisation of any kind.

  • contracts/contracts/overlayer/OverlayerWrapCore.sol line 358 — onlyHubChain(block.chainid) on _managerMint(): prevents collateral-backed OVA issuance on satellites, meaning no organic OVA accumulation can happen there to prime totalBridgedOut via `_deb

Attachments

Attachments are hidden

This information is not publicly available.

Comments are hidden

This information is not publicly available.