sendParam.minAmountLD slippage setting is too strict
The contract sets the minimum amount for a cross-chain transfer equal to the exact amount, leaving no slippage tolerance. An attacker could not exploit this directly, but legitimate transfers may revert when the received amount is slightly lower, blocking asset movement.
Submitted by ladboy233
Across the codebase, the minAmonutLD and amountLD is set to equal value:
if (data.collateralAmount > 0) {
address collateralWithdrawReceiver = data.withdrawCollateralParams.withdraw ? address(this) : data.user;
uint256 collateralShare = _yieldBox.toShare(_market.collateralId(), data.collateralAmount, false);
(Module[] memory modules, bytes[] memory calls) = IMarketHelper(data.marketHelper).removeCollateral(
data.user, collateralWithdrawReceiver, collateralShare
);
_market.execute(modules, calls, true);
//withdraw
if (data.withdrawCollateralParams.withdraw) {
uint256 collateralId = _market.collateralId();
if (data.withdrawCollateralParams.assetId != collateralId) revert Magnetar_WithdrawParamsMismatch();
// @dev re-calculate amount
if (collateralShare > 0) {
uint256 computedCollateral = _yieldBox.toAmount(collateralId, collateralShare, false);
if (computedCollateral == 0) revert Magnetar_WithdrawParamsMismatch();
data.withdrawCollateralParams.lzSendParams.sendParam.amountLD = computedCollateral;
data.withdrawCollateralParams.lzSendParams.sendParam.minAmountLD = computedCollateral;
_withdrawToChain(data.withdrawCollateralParams);
}
}
}
However, minAmonutLD served as a slippage control on layerzero v2 side, and 0% slippage is not always possible. The cross-chain transaction will always reverted in too strict slippage contract and block asset transfer.
function _debitView(
uint256 _amountLD,
uint256 _minAmountLD,
uint32 /*_dstEid*/
) internal view virtual returns (uint256 amountSentLD, uint256 amountReceivedLD) {
// @dev Remove the dust so nothing is lost on the conversion between chains with different decimals for the token.
amountSentLD = _removeDust(_amountLD);
// @dev The amount to send is the same as amount received in the default implementation.
amountReceivedLD = amountSentLD;
// @dev Check for slippage.
if (amountReceivedLD < _minAmountLD) {
revert SlippageExceeded(amountReceivedLD, _minAmountLD);
}
}
Recommended Mitigation Steps
Let user input a percentage and compute minAmountLD based on a percentage of slippage user is willing to take risk of.
Assessed type
Token-Transfer
cryptotechmaker (Tapioca) confirmed, but disagreed with severity and commented:
Slippage is only for EVM to Non-EVM transfers. We’re good for now.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The code sets the minimum received amount equal to the computed amount, providing zero slippage tolerance.
Impact
Cross-chain transfers could always revert when the received amount is even slightly less than the sent amount, blocking asset transfers; the project noted this only affects EVM to non-EVM transfers.
What the attacker needed
Cross-chain transfer to non-EVM chain
The fix
The code should let the user specify a slippage percentage and compute the minimum amount from that percentage.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When sending tokens across blockchains, the amount that arrives can be slightly less than what was sent due to fees or rounding. A 'slippage' setting lets you accept a small difference. Here the code required the exact same amount, so any tiny difference caused the transfer to fail.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.