Missing slippage protection in liquidation allows unexpected collateral loss
The liquidation function lacks a parameter for liquidators to specify a minimum acceptable collateral amount, so when slashable collateral is less than the calculated liquidation value, the transaction still succeeds and the liquidator receives less collateral than expected. This can cause unexpected losses for liquidators.
0xsh Follow with Drynooo, Tigerfrake and 4 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2025-07-cap-judging/issues/542
Found by
0xsh, Drynooo, Tigerfrake, dobrevaleri, farismaulana, silver_eth, valuevalk
Summary
Liquidators cannot specify a minimum amount of collateral to receive during liquidation, exposing them to potential losses when slashable collateral is less than expected.
Root Cause
In LiquidationLogic::liquidate(), the function lacks a parameter for liquidators to specify a minimum acceptable amount of collateral to receive. The function contains a safety check that caps the liquidation value to the total slashable collateral:
function liquidate(ILender.LenderStorage storage $, ILender.RepayParams memory params)
external
returns (uint256 liquidatedValue)
{
(uint256 totalDelegation, uint256 totalSlashableCollateral, uint256 totalDebt,,, uint256 health) =
ViewLogic.agent($, params.agent);
ValidationLogic.validateLiquidation(
health,
totalDelegation * $.emergencyLiquidationThreshold / totalDebt,
$.liquidationStart[params.agent],
$.grace,
$.expiry
);
(uint256 assetPrice,) = IOracle($.oracle).getPrice(params.asset);
uint256 bonus = ViewLogic.bonus($, params.agent);
uint256 maxLiquidation = ViewLogic.maxLiquidatable($, params.agent, params.asset);
uint256 liquidated = params.amount > maxLiquidation ? maxLiquidation : params.amount;
liquidated = BorrowLogic.repay(
$,
ILender.RepayParams({ agent: params.agent, asset: params.asset, amount: liquidated, caller: params.caller })
);
(,,,,, health) = ViewLogic.agent($, params.agent);
if (health >= 1e27) _closeLiquidation($, params.agent);
@> liquidatedValue =
(liquidated + (liquidated * bonus / 1e27)) * assetPrice / (10 ** $.reservesData[params.asset].decimals);
@> if (totalSlashableCollateral < liquidatedValue) liquidatedValue = totalSlashableCollateral;
if (liquidatedValue > 0) IDelegation($.delegation).slash(params.agent, params.caller, liquidatedValue);
emit Liquidate(params.agent, params.caller, params.asset, liquidated, liquidatedValue);
}
However, there's no corresponding check to ensure liquidators receive at least a specified minimum amount. This means liquidators are forced to accept whatever collateral is available, which could be significantly less than what they paid to repay the debt.
The function calculates the expected liquidation value based on the repaid debt amount, asset price, and bonus.
But when totalSlashableCollateral < liquidatedValue, the liquidator receives less value than calculated, with no option to revert the transaction.
The issue is viable, because the totalSlashableCollateral is calcualted based on the epoch, which is calculated based on the timestamp. So the epoch can change between the off-chain calculation and the transaction execution, which could lead to lesser collateral available for seizing. Moreover, another liquidation (for another asset) could be executed first, which will reduce the totalSlashableCollateral and there is no mechanism for protecting agains such scenarios.
Internal Pre-conditions
- Agent's position must have less slashable collateral than what would be expected based on their debt
- Liquidator needs to call
liquidate()with an amount parameter for an asset the agent has borrowed
External Pre-conditions
- Collateral value must have decreased since the agent's position was opened
Attack Path
- An agent's position becomes unhealthy
- Liquidator opens liquidation via
Lender::openLiquidation(agent) - After grace period, liquidator calls
Lender::liquidate(agent, asset, amount) - System calculates expected collateral to receive:
liquidatedValue - System checks if
totalSlashableCollateral < liquidatedValue - If true, liquidator receives
totalSlashableCollateralinstead ofliquidatedValue - Transaction completes successfully, but liquidator receives less collateral than expected
- Liquidator suffers unexpected losses
Impact
The liquidators can receive less than expected and there is no way to protect against such scenarios.
PoC
No response
Mitigation
Add a minimum collateral received parameter to the liquidate function, which will act as a guard.
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 liquidate function caps the collateral payout to the available slashable collateral without letting the caller specify a minimum acceptable amount, so the transaction cannot revert if the payout is too low.
Impact
Liquidators could receive less collateral than expected and have no way to protect against such scenarios.
What the attacker needed
Agent's position has less slashable collateral than expected; Liquidator calls liquidate() with an amount parameter; Collateral value decreased since position opened
The fix
Add a minimum collateral received parameter to the liquidate function to act as a guard.
How it was found
- An agent's position becomes unhealthy
- Liquidator opens liquidation via Lender::openLiquidation(agent)
- After grace period, liquidator calls Lender::liquidate(agent, asset, amount)
- System calculates expected collateral to receive: liquidatedValue
- System checks if totalSlashableCollateral < liquidatedValue
- If true, liquidator receives totalSlashableCollateral instead of liquidatedValue
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 a borrower's position becomes unhealthy, a liquidator can repay part of the debt and receive collateral at a discount. This report says the liquidator cannot set a minimum amount of collateral they are willing to accept, so they might get less than they bargained for and lose money.
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.