Core Contracts

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

Overestimation of Borrower Debt Leading to Excess Liquidation Costs in liquidateBorrower() function

Summary

A critical bug in the liquidateBorrower() function of the StabilityPool.sol contract causes borrower debt to be overestimated due to double application of the usageIndex scaling factor. This leads to incorrectly high liquidation amounts, resulting in Stability Pool depositors overpaying for liquidations and potential premature draining of Stability Pool funds

Vulnerability Details

Within liquidateBorrower(), the user's debt is first retrieved correctly using

uint256 userDebt = lendingPool.getUserDebt(userAddress);

However, getUserDebt() in LendingPool.sol already applies the interest rate multiplier (usageIndex), as seen in:

return user.scaledDebtBalance.rayMul(reserve.usageIndex);

Yet, the function incorrectly scales the debt again by calling:

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

Since lendingPool.getNormalizedDebt() is also equivalent to**usageIndex**, this results in:

scaledUserDebt = user.scaledDebtBalance * usageIndex * usageIndex;

This incorrectly applies usageIndex twice, making liquidation amounts artificially high.

Impact

Since scaledUserDebt is larger than the real debt, the Stability Pool pays more than required to cover liquidations. Depositors lose more RTokens (rCRVUSD) than necessary, leading to faster depletion of the Stability Pool

Tools Used

Manual review

Recommendations

Remove Redundant Scaling in liquidateBorrower()

Updates

Lead Judging Commences

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

StabilityPool::liquidateBorrower double-scales debt by multiplying already-scaled userDebt with usage index again, causing liquidations to fail

Support

FAQs

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