Lack of safety buffer between liquidation threshold and LTV ratio for borrowers to prevent unfair liquidations
The liquidation threshold and the maximum loan-to-value (LTV) ratio were set to the same value, so a borrower who took a loan at the maximum LTV could be liquidated after a tiny drop in collateral value. This allowed bots to repeatedly liquidate the loan, unfairly penalising the borrower.
Submitted by peakbolt
In BigBang and Singularity, there is no safety buffer between liquidation threshold and LTV ratio, to protects borrowers from being immediately liquidated due to minor market movement when the loan is taked out at max LTV.
The safety buffer also ensure that the loans can be returned to a healthy state after the first liquidation. Otherwise, the loan can be liquidated repeatly as it will remain undercollateralized after the first liquidation.
Detailed Explanation
The collateralizationRate determines the LTV ratio for the max amount of assets that can be borrowed with the specific collateral. This check is implemented in _isSolvent() as shown below.
function _isSolvent(
address user,
uint256 _exchangeRate
) internal view returns (bool) {
// accrue must have already been called!
uint256 borrowPart = userBorrowPart[user];
if (borrowPart == 0) return true;
uint256 collateralShare = userCollateralShare[user];
if (collateralShare == 0) return false;
Rebase memory _totalBorrow = totalBorrow;
return
yieldBox.toAmount(
collateralId,
collateralShare *
(EXCHANGE_RATE_PRECISION / FEE_PRECISION) *
collateralizationRate,
false
) >=
// Moved exchangeRate here instead of dividing the other side to preserve more precision
(borrowPart * _totalBorrow.elastic * _exchangeRate) /
_totalBorrow.base;
}
However, the liquidation start threshold, which is supposed to be higher (e.g. 80%) than LTV ratio (e.g. 75%), is actually using the same collateralizationRate value. We can see that computeClosingFactor() allow liquidation to start when the loan is at max LTV.
uint256 liquidationStartsAt = (collateralPartInAssetScaled *
collateralizationRate) / (10 ** ratesPrecision);
Impact
Borrowers can be unfairly liquidated and penalized due to minor market movement when taking loan at max LTV. Also loan can be repeatedly liquidated regardless of closing factor as it does not return to healthy state after the first liquidation.
Proof of Concept
Consider the following scenario,
- Borrower take out loan at max LTV (75%).
- Immediately after the loan is taken out, the collateral value dropped slightly due to minor market movement and the loan is now at 75.000001% LTV.
- However, as the liquidation start threshold begins to at 75% LTV, bots start to liquidate the loan, before the borrower could react and repay the loan.
- The liquidation will cause the loan to remain undercollateralized despite the closing factor.
- As the loan is still unhealthy, the bots will then be able to repeatly liquidate the loan.
- Borrower is unfairly penalized and suffers losses due to the liquidations.
Recommended Mitigation Steps
Implement the liquidation threshold as a separate state variable and ensure it is higher than LTV to provide a safety buffer for borrowers.
cryptotechmaker (Tapioca) confirmed and commented:
The user is not liquidated for his entire position but only for the amount necessary for the loan to become solvent again.
Loaning up to the collateralization rate threshold is up to the user and opening such an edging position comes with some risks that the user should be aware of.
However, adding the buffer seems fair. It can remain as a ‘High’.
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 same variable, collateralizationRate, was used for both the maximum LTV check and the liquidation start threshold, so no safety buffer existed.
Impact
Borrowers could be unfairly liquidated and penalised due to minor market movements, and loans could be repeatedly liquidated because they do not return to a healthy state after the first liquidation.
What the attacker needed
Borrower takes loan at max LTV; minor market movement; liquidation bots active
The fix
The liquidation threshold should be a separate state variable set higher than the LTV ratio to provide a safety buffer.
How it was found
- Borrower takes out a loan at the maximum LTV (75%).
- Collateral value drops slightly, putting the loan just above 75% LTV.
- Liquidation bots start liquidating because the threshold is also 75%.
- The loan remains undercollateralised after the first liquidation.
- Bots can repeatedly liquidate the still-unhealthy loan.
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 system, the LTV ratio is the maximum you can borrow against your collateral. The liquidation threshold is the point at which your loan can be forcibly closed. If both are the same, a tiny price drop can trigger liquidation immediately, leaving no room for the borrower to react.
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.