Borrowers can DoS liquidations by repaying as little as 1 share.
A borrower can front-run a liquidation by repaying a tiny amount of shares, reducing the total borrow shares so that the liquidator's specified share amount exceeds the new maximum allowed, causing the liquidation transaction to revert. This denial-of-service could increase the risk of bad debt.
Submitted by 0xStalin, also found by Dup1337 and Jorgect
Liquidations can be DoSed which increments the risk of bad debt being generated on position.
Proof of Concept
When a liquidator is liquidating a position in WiseLending, the liquidator needs to specify the amount of shares to be repaid. The liquidation logic checks if the positions are indeed liquidable, if so, it validates if the number of shares to be liquidated exceeds the total amount of shares that can be liquidated by using the WiseSecurityHelper.checkMaxShares() function. If the amount of shares the liquidator intends to liquidate exceeds the maximum amount of liquidable shares, the execution is reverted.
- When the position has generated bad debt, the liquidation can liquidate all the user’s
borrowShareson the pool been liquidated. - When the position has not generated bad debt, the maximum amount of liquidable shares is 50% of the existing user’s
borrowShareson the pool being liquidated.
The problem with this approach is that borrowers can frontrun the liquidation and repay as little as 1 share of the existing debt on the same pool that the liquidator decided to liquidate the debt from. This will cause when the liquidation is executed, the total borrow shares of the user on the pool being liquidated to be lower. If the liquidator was trying to liquidate the maximum possible amount of shares, now, the maxShares that can be liquidated will be slightly less than the amount of shares that the liquidator specified, which will cause the tx to revert.
function checkMaxShares(
uint256 _nftId,
address _tokenToPayback,
uint256 _borrowETHTotal,
uint256 _unweightedCollateralETH,
uint256 _shareAmountToPay
)
public
view
{
//@audit-ok => total borrowShares a position owns for a _tokenToPayback pool
uint256 totalSharesUser = WISE_LENDING.getPositionBorrowShares(
_nftId,
_tokenToPayback
);
//@audit-info => If baddebt, maxShares that can be liquidated are the totalSharesUser
//@audit-info => If not baddebt, maxShares can be 50% of the total borrowShares
uint256 maxShares = checkBadDebtThreshold(_borrowETHTotal, _unweightedCollateralETH)
? totalSharesUser
: totalSharesUser * MAX_LIQUIDATION_50 / PRECISION_FACTOR_E18;
if (_shareAmountToPay <= maxShares) {
return;
}
//@audit-issue => reverts if the amount of shares to be repaid exceeds maxShares!
revert TooManyShares();
}
For example, if there is a position in a liquidable state that has 100 borrowShares on the PoolA, and a liquidator decides to liquidate the maximum possible amount of shares from this position, it will send a tx to liquidate 50 shares from that position on the PoolA. The position’s owner can use the WiseLending.paybackExactShares() function to repay 1 share and frontrun the liquidator’s tx. Now, when the liquidator’s tx is executed, the position is still liquidable, but it only has 99 borrowShares on the PoolA. As a result of this, the WiseSecurityHelper.checkMaxShares() function will determine that the maximum possible amount of liquidable shares is 49.5, and because the liquidator specified that he intended to liquidate 50 shares, the tx will be reverted.
Recommended Mitigation Steps
In the WiseSecurityHelper.checkMaxShares() function, if the _shareAmountToPay exceeds maxShares, don’t revert; re-adjust the number of shares that can be liquidated. Return the final value of _shareAmountToPay and forward it back to the WiseLending.liquidatePartiallyFromTokens() function. Then, use the final value of shareAmountToPay to compute the exact amount of tokens to be repaid in the WiseLending.liquidatePartiallyFromTokens() function.
WiseSecurity.sol:
function checksLiquidation(
...
uint256 _shareAmountToPay
)
external
view
+ returns (uint256)
{
...
- checkMaxShares(
+ return checkMaxShares(
_nftIdLiquidate,
_tokenToPayback,
borrowETHTotal,
unweightedCollateralETH,
_shareAmountToPay
);
}
WiseSecurityHelper.sol:
function checkMaxShares(
...
uint256 _shareAmountToPay
)
public
view
+ returns (uint256)
{
...
uint256 maxShares = checkBadDebtThreshold(_borrowETHTotal, _unweightedCollateralETH)
? totalSharesUser
: totalSharesUser * MAX_LIQUIDATION_50 / PRECISION_FACTOR_E18;
if (_shareAmountToPay <= maxShares) {
- return;
+ return _shareAmountToPay;
+ } else {
+ return maxShares;
+ }
- revert TooManyShares();
}
WiseLending.sol:
function liquidatePartiallyFromTokens(
...
uint256 _shareAmountToPay
)
...
{
...
- data.shareAmountToPay = _shareAmountToPay;
...
//@audit-info => First, determine the maximum amount of liquidable shares
+ data.shareAmountToPay = WISE_SECURITY.checksLiquidation(
+ _nftId,
+ _paybackToken,
+ _shareAmountToPay
+ );
//@audit-info => Then, compute the exact amount of tokens required to liquidate the final amount of liquidable shares
data.paybackAmount = paybackAmount(
_paybackToken,
- _shareAmountToPay
+ data.shareAmountToPay
);
...
- WISE_SECURITY.checksLiquidation(
- _nftId,
- _paybackToken,
- _shareAmountToPay
- );
...
}
Assessed type
Context
vonMangoldt (Wise Lending) commented:
Instead of wasting gas by frontrunning a newbie liquidator they could also make money and liquidate themselves. On Arbitrum it’s not possible at all. If liquidators don’t use tools like flashbots or eden, it’s their own fault. No reason to do anything here, in my opinion. Dismissed.
Whether the option for liquidators to bypass hacks through private mempools is grounds for reducing severity of their abuse is not a trivial question and would best be standardized in the Supreme Court.
I’m taking a stance that this cheap hack is annoying enough for liquidators to be worth Medium severity. Note that if private mempool is in-scope, attacker can use it as well and insert the annoying TX at start of block.
vm06007 (Wise Lending) commented:
Mitigated here.
Mentioned issue does not seem to be in interest of the borrower, since borrower is more incentivized to perform self-liquidation to earn than preventing others, which becomes a race on who will liquidate first making liquidation a more desired outcome for both parties, no intention to gate the minimum payback threshold by admin.
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 liquidation function reverts if the requested share amount exceeds the maximum liquidatable shares, which is calculated from the current borrow shares; a small repayment reduces that maximum and causes a revert.
Impact
Liquidations can be repeatedly blocked, which could increase the risk of bad debt; the report notes that on Arbitrum front-running may not be possible, and the protocol team dismissed the issue as not worth fixing.
What the attacker needed
A liquidatable position; borrower can front-run the liquidation transaction; borrower has funds to repay at least 1 share
The fix
The report recommends that checkMaxShares should not revert but instead return the adjusted maximum share amount, which is then used to compute the repayment amount; the team later mitigated it.
How it was found
- A liquidator sends a transaction to liquidate the maximum allowed shares (e.g., 50% of borrow shares) from a liquidatable position.
- The borrower front-runs by repaying 1 share using paybackExactShares.
- The liquidator's transaction executes, but the maximum liquidatable shares is now slightly less than the requested amount.
- The checkMaxShares function reverts with TooManyShares, causing the liquidation to fail.
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.
In a lending protocol, if a borrower's collateral value falls, anyone can liquidate (repay part of the debt) to earn a reward. This report shows that a borrower can quickly repay a tiny amount just before the liquidator's transaction, which changes the debt balance and makes the liquidator's transaction fail because it tries to repay too many shares. This can stop liquidations and increase the risk of bad debt.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.