invalid calculation happen inside liquidateBorrower
function where it calculate userDebt
using unupdated index, potentially make the function revert if the amount is less than the actual userDebt
multiplied by the updated index because insufficient balance.
the vulnerability lies inside the liquidateBorrower
:
when the function first calculate userDebt
, it fetch the value of normalized debt amount (scaled x interest).
there are few issue here, first the return value of getUserDebt
is already multiplied by interest index but on the next line the userDebt
is getting multiplied by the same index.
second, the approve function are called using the amount of scaledUserDebt
from previous step, which is innacurrate.
why? because it calculated before lendingPool.updateState()
is called. this is crucial because the updateState
function would later update the index of debt interest and also the index of income interest.
so on the first step, the index used to calculate the user debt are using the old value instead of the new one.
the function would revert when the approved amount of scaledUserDebt
are not sufficient when it would be transferred later in lendingPool.finalizeLiquidation
function. because inside of finalizeLiquidation
, the actual amount transferred from the StabilityPool would be calculated using updated index.
manual review
first update the index by calling lendingPool.updateState()
before calculating the borrower debt.
second, no need to multiply the user debt amount if you want to get the scaled amount. instead you should divide it.
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.