Target is hidden
This information is not publicly available.
OverlayerWrapCore._credit() unconditionally decrements totalBridgedOut on every chain (line 543). On a non-hub chain deployment where totalBridgedOut == 0 (no tokens have ever been bridged OUT from that chain), the first incoming bridge triggers an arithmetic underflow (0 - amount), reverting the transaction under Solidity 0.8.20's checked arithmetic.
Since LayerZero OFT's _debit() burns tokens on the source chain BEFORE sending the cross-chain message (see OFTCore._send() at line 206 which calls _debit() first, then _lzSend()), and _credit() reverts on the destination, user tokens are burned on the source but never minted on the destination. The funds are permanently destroyed.
File: contracts/overlayer/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_); // mints tokens via OFT._credit → _mint()
totalBridgedOut -= amountReceivedLD; // LINE 543: UNDERFLOWS on non-hub chains
}
The totalBridgedOut variable is a uint256 (line 63) initialized to 0. The decrement at line 543 is unconditional -- it executes on ALL chains, not just the hub chain. On a non-hub chain where no _debit() has ever been called, totalBridgedOut remains 0 and the subtraction underflows.
The super._credit() call (OFT.sol lines 78-88) executes _mint(_to, _amountLD) BEFORE returning. However, the underflow at line 543 triggers a revert that rolls back the entire transaction including the mint — so no tokens are ever created on the destination.
Compare with _debit() (lines 510-528) which also unconditionally increments totalBridgedOut:
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_); // burns via OFT._debit → _burn()
totalBridgedOut += amountSentLD; // LINE 527
}
The developer's intent is clear from the NatSpec:
The totalBridgedOut tracking was designed for the hub chain only, but the block.chainid == hubChainId check was never implemented.
Line 302 (_initialize): if (hubChainId_ == block.chainid) -- the contract explicitly handles non-hub chain deployment with different initialization logic. The same contract IS intended for multi-chain deployment.
Line 358 (_managerMint): onlyHubChain modifier gates minting to hub only. This confirms non-hub chains exist where minting/redemption is disabled and tokens arrive exclusively via bridge.
Line 63: uint256 public totalBridgedOut; -- the variable exists as global state on ALL deployments, including non-hub chains where it serves no purpose but causes the underflow.
SOURCE CHAIN (hub):
User calls send()
→ OFTCore._send() [OFTCore.sol line 198]
→ _debit(msg.sender, amountLD, minAmountLD, dstEid) [line 206]
→ OFT._debit(): _burn(from, amountSentLD) [OFT.sol line 68] ← TOKENS BURNED
→ OverlayerWrapCore._debit(): totalBridgedOut += amountSentLD [line 527]
→ _lzSend(dstEid, message, options, fee, refund) [line 217] ← MESSAGE SENT
✓ Transaction committed. Tokens permanently burned on source.
DESTINATION CHAIN (non-hub):
LayerZero endpoint calls lzReceive()
→ OFTCore._lzReceive() [OFTCore.sol line 266]
→ _credit(toAddress, amountLD, srcEid) [line 277]
→ OFT._credit(): _mint(to, amountLD) [OFT.sol line 85] ← TOKENS WOULD BE MINTED
→ OverlayerWrapCore._credit(): totalBridgedOut -= amountReceivedLD [line 543]
← 0 - amountReceivedLD = UNDERFLOW → REVERT (panic 0x11)
✗ Transaction reverted. Mint rolled back. Zero tokens created.
RESULT: Tokens burned on source, never minted on destination.
LayerZero stores failed message for retry, but retries are
deterministic and always fail (totalBridgedOut is still 0).
Contract is not upgradeable. No recovery mechanism exists.
No attacker is needed -- any legitimate user bridging tokens triggers the bug:
1. User holds 100 OVA tokens on Ethereum (hub chain, hubChainId = 1)
2. User bridges 100 OVA to Arbitrum via LayerZero OFT:
- Hub chain _debit() at line 527: burns 100 OVA, totalBridgedOut += 100
- LayerZero sends cross-chain message to Arbitrum
3. On Arbitrum (non-hub), _credit() executes:
- Line 542: super._credit() mints 100 OVA to user (pending)
- Line 543: totalBridgedOut -= 100 → 0 - 100 = UNDERFLOW → REVERT
- The revert rolls back the mint — zero tokens created
4. Result:
- Hub chain: 100 OVA tokens BURNED (irreversible, committed in prior tx)
- Arbitrum: 0 OVA tokens minted (reverted)
- User permanently lost 100 OVA tokens
5. LayerZero v2 stores the failed message for retry, but retries
hit the same deterministic revert (totalBridgedOut is still 0).
The contract is not upgradeable. Funds are permanently lost.
For _credit to work on a non-hub chain, totalBridgedOut must be > 0, which requires a prior _debit call. But _debit burns tokens from the caller -- tokens that can only arrive via _credit (since _managerMint is hub-only via onlyHubChain modifier at line 358). The non-hub chain is permanently bricked from inception: no tokens can ever arrive, and no tokens can ever leave.
Make the totalBridgedOut tracking conditional on being the hub chain:
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 -= amountReceivedLD;
}
}
This scopes totalBridgedOut to the hub chain where it has meaning (tracking tokens outstanding on other chains for collateral-backing calculations via totalSupply() + totalBridgedOut() in AaveHandler.supply() at line 240), and eliminates the underflow on non-hub chains where the variable serves no purpose. The fix mirrors the existing hub-vs-non-hub branching pattern already used in _initialize() at line 302 and the onlyHubChain modifier at line 77.
Attachments are hidden
This information is not publicly available.
Comments are hidden
This information is not publicly available.