Target is hidden
This information is not publicly available.
OverlayerWrapCore increments totalBridgedOut on _debit() but decrements it on every _credit() with no hub-only guard and no floor check. On a non-hub chain, a fresh inbound OFT credit can execute before any local debit exists, so _credit() subtracts from zero and reverts. Even when it does not revert immediately, leftover unmatched totalBridgedOut state can poison later supply normalization logic that depends on totalSupply() + totalBridgedOut().
Reproduction in clear steps:
totalBridgedOut == 0._debit() has occurred._credit() calls super._credit(...) and then executes totalBridgedOut -= amountReceivedLD.totalSupply() + totalBridgedOut() as the effective liability base.Exact vulnerable code:
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_
);
totalBridgedOut += amountSentLD;
}
function _credit(
address to_,
uint256 amountLD_,
uint32 srcEid_
) internal virtual override returns (uint256 amountReceivedLD) {
amountReceivedLD = super._credit(to_, amountLD_, srcEid_);
totalBridgedOut -= amountReceivedLD;
}
totalBridgedOut is zero._credit() path before any local _debit() has created an outbound liability._credit() tries to subtract the credited amount from zero and reverts.Passing result:
F-001 PoC
✔ reverts on a fresh non-hub credit-first path
✔ keeps only the unmatched amount bridged out after a partial return credit
✔ reverts on an extra unmatched credit after a balanced debit-credit round trip
3 passing
Exact passing PoC test code:
const HARDHAT_CHAIN_ID = 31337;
async function deployFixture(hubChainId: number) {
const [admin, alice] = await ethers.getSigners();
const block = await admin.provider.getBlock("latest");
const baseFee = block?.baseFeePerGas ?? 1n;
const defaultTransactionOptions = {
maxFeePerGas: baseFee * 10n
};
const Collateral = await ethers.getContractFactory("SixDecimalsUsd");
const collateral = await Collateral.deploy(
1000,
"COLLATERAL",
"COLLATERAL",
defaultTransactionOptions
);
const aCollateralFactory = await ethers.getContractFactory("SixDecimalsUsd");
const acollateral = await aCollateralFactory.deploy(
1000,
"aCOLLATERAL",
"aCOLLATERAL",
defaultTransactionOptions
);
const Endpoint = await ethers.getContractFactory("MockLayerZeroEndpointV2");
const endpoint = await Endpoint.deploy();
const OverlayerWrap = await ethers.getContractFactory("OverlayerWrapMock");
const overlayerWrap = await OverlayerWrap.deploy(
{
admin: await admin.getAddress(),
lzEndpoint: await endpoint.getAddress(),
name: "O",
symbol: "O+",
collateral: {
addr: await collateral.getAddress(),
decimals: await collateral.decimals()
},
aCollateral: {
addr: await acollateral.getAddress(),
decimals: await acollateral.decimals()
},
maxMintPerBlock: ethers.MaxUint256,
maxRedeemPerBlock: ethers.MaxUint256,
minValmaxRedeemPerBlock: 1n,
hubChainId
},
defaultTransactionOptions
);
await collateral.connect(admin).transfer(alice.address, ethers.parseUnits("100", await collateral.decimals()));
await collateral.connect(alice).approve(await overlayerWrap.getAddress(), ethers.MaxUint256);
return { alice, collateral, overlayerWrap };
}
async function deployNonHubFixture() {
return deployFixture(HARDHAT_CHAIN_ID + 1);
}
it("reverts on a fresh non-hub credit-first path", async function () {
const { overlayerWrap, alice } = await loadFixture(deployNonHubFixture);
const inboundAmount = ethers.parseEther("1");
await expect(
overlayerWrap.testCredit(alice.address, inboundAmount, 0)
).to.be.revertedWithPanic(0x11);
expect(await overlayerWrap.totalBridgedOut()).to.equal(0);
expect(await overlayerWrap.balanceOf(alice.address)).to.equal(0);
});
Attachments are hidden
This information is not publicly available.
Comments are hidden
This information is not publicly available.