Target is hidden
This information is not publicly available.
An arithmetic underflow in OverlayerWrapCore._credit() (line 543) causes all incoming cross-chain transfers to revert on any chain where totalBridgedOut == 0.
Vulnerable code:
function _credit(
address to_,
uint256 amountLD_,
uint32 srcEid_
) internal virtual override returns (uint256 amountReceivedLD) {
amountReceivedLD = super._credit(to_, amountLD_, srcEid_);
totalBridgedOut -= amountReceivedLD; // line 543 - underflows here
}
totalBridgedOut is a per-chain storage variable that defaults to 0. It's incremented in _debit() (line 527) when tokens bridge OUT from a chain. But _credit() runs on the DESTINATION chain when tokens arrive — and that chain may have never called _debit().
In Solidity ^0.8.20, 0 - amountReceivedLD triggers Panic(0x11). Since _debit() already burned tokens on the source chain before the cross-chain message, the user loses funds: burned on source, never minted on destination.
Note on developer intent: The NatDoc comments describe _credit() as "tracking tokens returning to the hub chain," but LayerZero's OFT architecture calls _credit() on ANY destination chain, not just the hub. This architectural misunderstanding is the root cause.
totalBridgedOut is local to each chain's contract deployment_debit() increments it on the source chain, _credit() decrements it on the destination chaintotalBridgedOut == 0_credit() reverts with underflowStep 1: Deploy OverlayerWrap on a new spoke chain (e.g., Arbitrum). Result: totalBridgedOut == 0.
Step 2: On hub chain (Ethereum), user calls OFTCore.send() to bridge 100 OVA. Hub chain executes _debit() which burns user's 100 OVA and increments totalBridgedOut to 100e18. LayerZero message committed.
Step 3: LayerZero delivers message to spoke chain. Call flow: lzReceive() → _lzReceive() → _credit(alice, 100e18, hubEid). The super._credit() mints 100 OVA (succeeds), then totalBridgedOut -= 100e18 attempts 0 - 100e18 and panics with code 0x11. Entire transaction reverts, including the mint.
Step 4: User loses funds. 100 OVA burned on Ethereum (irreversible), 0 OVA minted on Arbitrum (reverted). LayerZero stores message as failed; retries hit same underflow. No escape hatch exists: no admin function sets totalBridgedOut, and _debit() can't be called without tokens that only arrive via _credit() — a circular dependency.
PoC files are attached:
forge-tests/CriticalCrossChainUnderflow.t.sol — unit testsforge-tests/CriticalCrossChainFork.t.sol — mainnet fork testsRun with any Ethereum RPC:
MAINNET_RPC=https://rpc.mevblocker.io forge test \
--match-path "forge-tests/CriticalCrossChainFork.t.sol" -vvv
Verified passing:
[PASS] test_Fork_FreshDeploymentHasZeroTotalBridgedOut()
[PASS] test_Fork_RealLzReceive_RevertsWithUnderflow() -- Panic(0x11)
[PASS] test_Fork_FundLoss_1000OVA()
[PASS] test_Fork_RetryAlwaysFails() -- 3 retries, all revert
[PASS] test_Fork_LzReceive_SucceedsWhenTotalBridgedOutIsSufficient() -- negative test
The fork test uses the production endpoint at 0x1a44076050125825900e736c501f859c50fE728c, real USDC/aUSDC from mainnet, and delivers OFT messages through the actual lzReceive() path.
Guard the decrement to only execute on the hub chain:
function _credit(...) internal virtual override returns (uint256 amountReceivedLD) {
amountReceivedLD = super._credit(to_, amountLD_, srcEid_);
if (block.chainid == hubChainId) {
totalBridgedOut -= amountReceivedLD;
}
}
Add the same guard to _debit() for consistency — totalBridgedOut is only consumed by AaveHandler.supply() on the hub chain.
Check OverlayerWrapCore.sol line 63:
uint256 public totalBridgedOut;
The default value is 0. No constructor or initializer modifies it.
grep -rn "totalBridgedOut" contracts/
Results: only declaration (line 63), increment in _debit (line 527), decrement in _credit (line 543), and read in AaveHandler.sol (line 241). No setter exists.
Trace the call flow in LayerZero OFT:
LZ executor → endpoint calls oapp.lzReceive() on DESTINATION chain
→ _lzReceive() [OFTCore:277]
→ _credit(toAddress, amountLD, srcEid) on DESTINATION chain
_credit executes on whichever chain receives the message, not only the hub.
Read OverlayerWrapCore.sol lines 537-544. The subtraction totalBridgedOut -= amountReceivedLD is not wrapped in unchecked{}. With pragma solidity ^0.8.20, underflow produces Panic(0x11).
To make totalBridgedOut > 0 on a spoke chain:
_debit() must execute first (line 527)_debit() calls _burn() which requires tokens_credit()_credit() reverts because totalBridgedOut == 0This is an unbreakable circular dependency.
Copy the attached PoC files into the repository:
forge-tests/CriticalCrossChainUnderflow.t.solforge-tests/CriticalCrossChainFork.t.solRun with any mainnet RPC:
MAINNET_RPC=https://rpc.mevblocker.io forge test \
--match-path "forge-tests/CriticalCrossChainFork.t.sol" -vvv
Expected output:
[PASS] test_Fork_FreshDeploymentHasZeroTotalBridgedOut() -- totalBridgedOut == 0
[PASS] test_Fork_RealLzReceive_RevertsWithUnderflow() -- Panic(0x11) via real LZ endpoint
[PASS] test_Fork_FundLoss_1000OVA() -- 1000 OVA burned, 0 minted
[PASS] test_Fork_RetryAlwaysFails() -- 3 retries, all revert
[PASS] test_Fork_LzReceive_SucceedsWhenTotalBridgedOutIsSufficient() -- negative test
The fork test uses the production endpoint at 0x1a44076050125825900e736c501f859c50fE728c and delivers OFT messages through the actual lzReceive() path.
After the spoke chain revert:
_burn() in OFT._debit() — irreversiblelzReceive reverted — no tokens minted, no state changetotalBridgedOutResult: permanent, irrecoverable loss of user funds.
Attachments are hidden
This information is not publicly available.
Comments are hidden
This information is not publicly available.