Status DataClose notification

Overlayer Disclosed Report

Audit Report

Non-Hub Bridge Credits Always Underflow `totalBridgedOut`, Locking Incoming Bridged Funds

Target

Target is hidden

This information is not publicly available.

Vulnerability details

Description

contracts/overlayer/OverlayerWrapCore.sol::_credit() unconditionally subtracts amountReceivedLD from totalBridgedOut.

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

totalBridgedOut is increased only on the source chain during _debit(). On a non-hub destination deployment that has never bridged tokens out before, totalBridgedOut == 0. The first inbound bridge message reaches super._credit(...), then immediately underflows on totalBridgedOut -= amountReceivedLD, which reverts the entire credit flow.

The vulnerable function is:

  • Contract: OverlayerWrapCore
  • Function: _credit(address,uint256,uint32)
  • Reachable from: the LayerZero/OFT inbound credit path

This is not a theoretical issue. The attached PoC simulates the following sequence:

  1. Alice mints 10 OW on the hub deployment.
  2. Alice bridges 5 OW out from the hub deployment through _debit().
  3. The satellite deployment attempts to credit 5 OW through _credit().
  4. The satellite credit reverts with an arithmetic underflow because satellite.totalBridgedOut == 0.

The source-side burn has already occurred in step 2, so Alice's bridged funds are no longer usable on the destination chain.

Root Cause

totalBridgedOut is hub-chain-specific accounting, but _credit() updates it on every deployment instead of restricting that accounting to the hub deployment, or at least validating that the local counter is large enough before decrementing it.

  • _debit() in OverlayerWrapCore:
function _debit(...) internal virtual override returns (...) {
    (amountSentLD, amountReceivedLD) = super._debit(...);
    totalBridgedOut += amountSentLD;
}
  • _credit() in OverlayerWrapCore:
function _credit(...) internal virtual override returns (uint256 amountReceivedLD) {
    amountReceivedLD = super._credit(to_, amountLD_, srcEid_);
    totalBridgedOut -= amountReceivedLD;
}

That subtraction assumes the current deployment previously increased the counter. That assumption is false for first-time destination credits and for any deployment that only receives bridged OW but has not previously bridged OW out.

Impact

Consider the following scenario:

  1. Alice deposits 10 units of collateral into the hub OverlayerWrap.mint(...) flow and receives 10 OW.
  2. Alice initiates a bridge of 5 OW from the hub deployment to a satellite deployment. The hub-side _debit() burns 5 OW and increases hub.totalBridgedOut by 5 OW.
  3. The satellite deployment receives the bridge message and enters _credit(alice, 5e18, srcEid).
  4. super._credit(...) is followed by totalBridgedOut -= 5e18, but satellite.totalBridgedOut == 0, so the credit path reverts.

In this situation, Alice has already lost 5 OW on the source chain, but the destination chain never credits her 5 OW. This creates a real lock of bridged user funds.

Impact summary:

  1. Actor: any user bridging OW to a deployment whose local totalBridgedOut is lower than the incoming credit amount
  2. Action: trigger the inbound _credit() path
  3. Asset: bridged OW balances
  4. Result: the source-side burn succeeds, but the destination-side credit reverts, locking the bridged amount
  5. Condition: the destination deployment has not previously accumulated enough local totalBridgedOut

"Any user can trigger an inbound credit that reverts, causing bridged OW to become locked when the destination deployment's totalBridgedOut counter is lower than the credited amount."

Remediation

Only update totalBridgedOut on the hub deployment, and never allow it to decrement below zero.

function _credit(
    address to_,
    uint256 amountLD_,
    uint32 srcEid_
) internal virtual override returns (uint256 amountReceivedLD) {
    amountReceivedLD = super._credit(to_, amountLD_, srcEid_);
-   totalBridgedOut -= amountReceivedLD;
+   if (block.chainid == hubChainId) {
+       if (amountReceivedLD > totalBridgedOut) revert OverlayerWrapCoreOverflow();
+       totalBridgedOut -= amountReceivedLD;
+   }
}

Alternatively, consider making totalBridgedOut a strictly hub-only accounting variable, because satellite deployments do not manage collateral backing and should not be required to maintain a non-zero bridge-out counter before they can accept inbound credits.

Validation steps

Create poc1.t.sol in audit-poc/poc1.t.sol, poc1.t.sol is in attachment.

  • poc1:
forge test --match-path audit-poc/poc1.t.sol -vv
  • result1:
Ran 1 test for audit-poc/poc1.t.sol:Poc1BridgeCreditLockTest
[PASS] test_satelliteCreditUnderflowsAndLocksBridgedFunds() (gas: 122954)
Suite result: ok. 1 passed; 0 failed

Attachments

Attachments are hidden

This information is not publicly available.

Comments are hidden

This information is not publicly available.