Core Contracts

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

Not updating the lending pool upon a liquidation will be problematic

Summary

Not updating the lending pool upon a liquidation will be problematic

Vulnerability Details

To finalize a liquidation, StabilityPool::finalizeLiquidation() must be called where we have the following 2 lines as the first lines of the function:

uint256 userDebt = lendingPool.getUserDebt(userAddress);
uint256 scaledUserDebt = WadRayMath.rayMul(userDebt, lendingPool.getNormalizedDebt());

The issue is that both of them are using the debt index of the lending pool however as the index was not updated, then these 2 values will be incorrect and outdated, it doesn't include the latest interest that should be accrued. Then, at the end of the function we have these 2 lines:

// Update lending pool state before liquidation
lendingPool.updateState();
// Call finalizeLiquidation on LendingPool
lendingPool.finalizeLiquidation(userAddress);

We update the pool then but it is of no use as firstly, finalizeLiquidation() will update it anyway and secondly, we already used the out-of-sync values to compute the debt to repay.

Impact

Using an outdated debt will result in the liquidation to fail as we won't be fully repaying the debt

Tools Used

Manual Review

Recommendations

Update the pool at the beginning of the function

Updates

Lead Judging Commences

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Validated
Assigned finding tags:

StabilityPool: liquidateBorrower should call lendingPool.updateState earlier, to ensure the updated usageIndex is used in calculating the scaledUserDebt

Support

FAQs

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