Incorrect assumption of loss in liquidatePositionBadDebt(), leads to undue burning of Treasury shares #434
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-190
🤖_86_group
AI based duplicate group recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-07-loopfi/blob/57871f64bdea450c1f04c9a53dc1a78223719164/src/CDPVault.sol#L607
Vulnerability details
Impact
Undue burning of Treasury shares in PoolV3 leading to loss of profit to stakers, protocol and dLp lockers.
Proof of Concept
In
liquidatePosition()
during full repayment
It can also be observed in
calDecrease()
that whencumulativeQuotaInterest
oraccumulatedInterest
is repaid,profit
is recorded. hereliquidatePositionBadDebt()
liquidatePositionBadDebt()
incorrectly assumes that, once therepayAmount
is less thantotalDebt
, a loss occurs, this is not correct in all cases.Instance
From the snippet above, it shows that, debt is 1,000 and liquidator repaid 1,050, which leaves 50 as part of the interest payment and shares should be minted to the treasury for that. But the current implementation of
liquidatePositionBadDebt()
does other wise, by burning treasury shares worth 1,200 - 1,050 = 150. In the real sense, 150 was not lost here, 50 was gained as part interest payment!Tools Used
Manual review
Recommended Mitigation Steps
check if the repaid amount is greater or less than the actual debt, if it is greater, the difference should be minted as profit to the treasury, if lower, difference should be burnt from treasury.
Assessed type
Math
The text was updated successfully, but these errors were encountered: