Incorrect amount calculation and approval in liquidateBorrower()
of StabilityPool.sol results in DOS of core functionality i.e liquidation and causes bad debt for the protocol.
In the liquidateBorrower()
function:
userDebt
is taken from getUserDebt()
function of lendingPool.sol
:
Here, scaledDebtBalance
of user is multiplied with usageIndex
for the userDebt
.
Now in the liquidateBorrower()
function, userDebt
is again scaled as:
lendingPool.getNormalizedDebt()
is equal to the usageIndex
.
Thus, scaledUserDebt
is multiplied twice with the usageIndex
which is incorrect.
This issue creates scaledUserDebt
way more than expected which may result in failure of liquidateBorrower()
due to InsufficientBalance
error and makes it impossible to finalize the liquidation for the borrower. Thus, hindering the core protocol functionality.
This issue will also result in the contract transferring more amount of scaledUserDebt
for liquidation than necessary if enough funds are available and causes bad debt in the protocol which will impact both the protocol and the future liquidations(DoS due to lack of funds).
Manual Analysis
scaledUserDebt
from userDebt
should be calculated as:
Instead of rayMul
, it should be rayDiv
as seen in LendingPool.sol and DebtToken.sol contracts.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.