Frontrunning Liquidation can help a bad debtor keep his collateral for longer periods than desired #820
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-312
satisfactory
satisfies C4 submission criteria; eligible for awards
Lines of code
https://github.com/code-423n4/2024-01-salty/blob/53516c2cdfdfacb662cdea6417c52f23c94d5b5b/src/stable/CollateralAndLiquidity.sol#L140-L188
https://github.com/code-423n4/2024-01-salty/blob/53516c2cdfdfacb662cdea6417c52f23c94d5b5b/src/staking/StakingRewards.sol#L97-L111
Vulnerability details
Impact
Liquidations can be delayed as well adding more collateral can be delayed which can lead to de-pegging usds
Proof of Concept
The function liquidateUser calls _decreaseUserShare as can be seen from below snippet.
_decreaseUserShare function in turn checks for liquidity cooldown but it can be manipulated easily by adding some amount of collateral just above the DUST i.e 100. So a malicious debtor can postpone his liquidation for an hour. This can be harmful for usds in a flash crash situation where each hour he gets delayed the more loss the project takes. Leading to de - pegging of the stable coin.
Conversly someone might not be able to add enough collateral to his loan in time.
Here's a coded poc-
add it to pools.t.sol and run the test using the command
Tools Used
Manual Review
Recommended Mitigation Steps
Currently 'canUserBeLiquidated' is a view function you can add a non view variant of the same function but in this function if a user can be liquidated then set his cooldown to 0. and call that non view function in the liquidateUser function.
Assessed type
Invalid Validation
The text was updated successfully, but these errors were encountered: