Core Contracts

Regnum Aurum Acquisition Corp
HardhatReal World AssetsNFT
77,280 USDC
View results
Submission Details
Severity: medium
Invalid

Change in `liqudationGracePeriod` can cause instant liquidation.

Summary

owner can change the liquidation grace period, this can make some accounts instantly liquidatable.

Vulnerability details

If user collateral value is less than the required threshold, the account is marked as liquidable using LendingPool:initiateLiquidation, after this call user has some time liquidationGracePeriod to repay and avoid the liquidation.

function initiateLiquidation(
address userAddress
) external nonReentrant whenNotPaused {
if (isUnderLiquidation[userAddress])
revert UserAlreadyUnderLiquidation();
// update state
ReserveLibrary.updateReserveState(reserve, rateData);
UserData storage user = userData[userAddress];
uint256 healthFactor = calculateHealthFactor(userAddress);
if (healthFactor >= healthFactorLiquidationThreshold)
revert HealthFactorTooLow();
isUnderLiquidation[userAddress] = true;
@-> liquidationStartTime[userAddress] = block.timestamp;
emit LiquidationInitiated(msg.sender, userAddress);
}

Let’s say the liquidationGracePeriod is 2 days when the user was flagged for liquidation, he is now thinking of repaying the loan and close liquidation on day 2 for some reason to avoid liquidation. After 1 day has passed if the owner decides to change the grace period from 2 days to 1 day using LendingPool:setParameters, then the user will get liquidated without having any time to repay.

function closeLiquidation() external nonReentrant whenNotPaused {
address userAddress = msg.sender;
if (!isUnderLiquidation[userAddress]) revert NotUnderLiquidation();
// update state
ReserveLibrary.updateReserveState(reserve, rateData);
if (
block.timestamp >
@-> liquidationStartTime[userAddress] + liquidationGracePeriod
) {
revert GracePeriodExpired();
}
UserData storage user = userData[userAddress];
uint256 userDebt = user.scaledDebtBalance.rayMul(reserve.usageIndex);
if (userDebt > DUST_THRESHOLD) revert DebtNotZero();
isUnderLiquidation[userAddress] = false;
liquidationStartTime[userAddress] = 0;
emit LiquidationClosed(userAddress);
}

as you can see because of this check liquidationStartTime[userAddress] + liquidationGracePeriod user cannot close his liquidation even if he repay the loan.

Impact

user will get instantly liquidated if gracePeriod is decreased.

Recommendation

when the user is flagged for liquidation, the current liquidationGracePeriod should be saved in a state variable associated with the user and later that should be user instead of the latest one. This will make sure that user are getting the grace period as they were promised initially.

Updates

Lead Judging Commences

inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!