Target is hidden
This information is not publicly available.
Impact: Any user bridging from the hub to a fresh satellite can have their source-chain tokens burned while the destination-chain credit reverts. This permanently locks bridged funds until the contracts are upgraded or a manual recovery path is introduced. In practice, it also shuts down the core hub-to-satellite bridge path for the protocol.
Description: OverlayerWrapCore tracks totalBridgedOut as if debits and credits happen on the same contract instance. On the source chain, _debit() burns tokens and increments totalBridgedOut. On the destination chain, _credit() always decrements totalBridgedOut. In an OFT deployment, those two functions execute on different chain instances. That means any destination instance can only process inbound credits up to the amount it has previously debited itself. A fresh satellite starts with totalBridgedOut == 0, so the first inbound credit from the hub executes totalBridgedOut -= amountReceivedLD and underflows, reverting the LayerZero delivery. More generally, any inbound transfer where amountReceivedLD > destination.totalBridgedOut() reverts. The bug is in the core accounting itself, not in a deploy script. Evidence:
contracts/overlayer/OverlayerWrapCore.sol: _debit() unconditionally increments totalBridgedOut and _credit() unconditionally decrements it.contracts/overlayer/OverlayerWrapFactory.sol: the token is designed to be deployed as an OFT with a configurable hubChainId.scripts/utils/deployAllSepolia.ts: the project explicitly uses pre-deployed OFT instances, confirming multi-chain operation is intended.test/OverlayerWrap.ts: the bridge tests only call testDebit() and testCredit() on the same contract instance, so they never exercise the real two-instance cross-chain path where the underflow appears.PoC Scenario:
OverlayerWrap on the hub chain with hubChainId = HUB_CHAIN_ID and normal backing.OverlayerWrap OFT peer on a satellite chain, also configured with the same hubChainId = HUB_CHAIN_ID.100e18 OverlayerWrap on the hub through the normal collateralized mint flow.10e18 from the hub instance to the satellite instance._debit() executes successfully, burns 10e18, and sets hub.totalBridgedOut += 10e18._credit().satellite.totalBridgedOut == 0._credit() executes satellite.totalBridgedOut -= 10e18, which underflows in Solidity 0.8 and reverts.Runnable PoC: A self-contained two-instance Hardhat PoC was added to this workspace:
project/repo/test/PoC.BridgeCreditUnderflow.tsproject/repo/hardhat.poc.config.jsproject/repo/poc-contracts/MockLayerZeroEndpointV2.solproject/repo/poc-contracts/PoCImports.solThe test deploys:
OverlayerWrapMock instance as the hub,OverlayerWrapMock instance as the satellite.It then:
100e18 OverlayerWrap on the hub for alice,hub.testDebit(alice, 10e18, 10e18, 30101) so the hub burns 10e18 and records hub.totalBridgedOut == 10e18,satellite.testCredit(alice, 10e18, 30101),0x11 because satellite.totalBridgedOut == 0 and _credit() executes totalBridgedOut -= amountReceivedLD.Command used:
node ./node_modules/hardhat/internal/cli/bootstrap.js test --config hardhat.poc.config.js test/PoC.BridgeCreditUnderflow.ts
Observed result:
PoC: bridge credit underflow
✔ burns on the source instance and reverts on the first credit to a fresh peer (2444ms)
1 passing (2s)
The test also asserts that after the revert:
- the hub-side user balance is reduced by `10e18`,
- `hub.totalBridgedOut == 10e18`,
- the satellite user balance is still `0`,
- the satellite total supply is still `0`.
This demonstrates actual source-side loss of spendable balance combined with destination-side failure.
totalBridgedOut only on the hub instance, because only the hub needs the value for collateral-backing accounting. A minimal fix is: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;
}
}
Attachments are hidden
This information is not publicly available.
Comments are hidden
This information is not publicly available.