Critical
The destination credit path in OverlayerWrapCore unconditionally decrements totalBridgedOut:
On a fresh destination deployment, totalBridgedOut is zero before any local outbound bridging occurs. If the first cross-chain operation is an inbound credit, the subtraction underflows and reverts.
function _credit(
address to_,
uint256 amountLD_,
uint32 srcEid_
) internal virtual override returns (uint256 amountReceivedLD) {
amountReceivedLD = super._credit(to_, amountLD_, srcEid_);
totalBridgedOut -= amountReceivedLD;
}
_credit is called.totalBridgedOut == 0 (no prior local outbound bridge history).totalBridgedOut -= amountReceivedLD underflows and reverts._debit and _credit, for example mutate totalBridgedOut only when block.chainid == hubChainId.A runnable regression test has been added:
Should revert on first inbound credit when no prior local debit exists
The test calls testCredit on a fresh deployment before any testDebit, so totalBridgedOut is zero and the vulnerable subtraction is reached.
testCredit(...) reverts as expected.