Users cannot eliminate the liquidation risk when the CR falls below the liquidation CR by repaying partially #78
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
duplicate-107
🤖_73_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-06-size/blob/8850e25fb088898e9cf86f9be1c401ad155bea86/src/libraries/actions/Compensate.sol#L120-L125
https://github.com/code-423n4/2024-06-size/blob/8850e25fb088898e9cf86f9be1c401ad155bea86/src/Size.sol#L250
Vulnerability details
Impact
When users'
CR
falls below theliquidation CR
, their positions becomeliquidatable
, and users will experienceloss
throughliquidation
.To avoid this, users should try to increase their
CR
by depositing morecollateral
orrepaying
theirdebts
.However,
repaying
thefull debt
can be difficult, so there is acompensate
function that allows users torepay
theirdebts
partially.The
compensate
function checks whether the user'sCR
is larger than theliquidation CR
.In scenarios where
collateral
prices fall suddenly and users'CR
falls below theliquidation CR
, users need to try to increase theirCR
.It's not always possible for users to have additional
collateral
, andrepaying
thefull debt
before maturity is not effective.Some users will try to partially
repay
theirdebts
using theirUSDC
tokens.However, the
CR
will remain unchanged, and their attempt will be reverted due to theirCR
is still below theliquidation CR
.This means that their positions could still be
liquidated
, leading tolosses
.Proof of Concept
Imagine
Bob
borrows
100 USDC
fromAlice
and has enoughWETH
as collateral.The
WETH price
suddenly falls, andBob
'sCR
becomes129
, while the currentliquidation CR
is130
.This means that
Bob
'sdebt
position isliquidatable
.To avoid
loss
,Bob
tries torepay
hisdebt
partially.For example, he has
50 USDC
and attempts to split his100 USDC
debt
into two smallerdebts
of50 USDC
each, thenrepay
one of them.However, his attempt will be reverted due to the last check in the
compensate
function.His
CR
remains129
, which is still less than130
.As a result, his
100 USDC
debt
position will beliquidated
, leading to aloss
.Of course, in the
compensate
function, the user'sCR
can decrease when there is afragmentation fee
.However, in most cases, the
CR
can increase when users try tocompensate
using already existingcredit
positions or remain unchanged when creating newdebt
andcredit
positions.Therefore, it is sufficient to revert only when the
CR
decreases and is less than theliquidation CR
.If there is no decrease in
CR
, this action will benefit theprotocol's health
.Please add below test to the
test/local/actions/Compensate.t.sol
:Tools Used
Recommended Mitigation Steps
Revert only when the
CR
decreases and is less than theliquidation CR
.Assessed type
Invalid Validation
The text was updated successfully, but these errors were encountered: