Borrowers can cause DOS by frontrunning Liquidations to increase their collateral amount by a small amount thereby increasing their cooldown periods which causes liquidation transactions to revert. #513
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-312
edited-by-warden
satisfactory
satisfies C4 submission criteria; eligible for awards
Lines of code
https://github.com/code-423n4/2024-01-salty/blob/53516c2cdfdfacb662cdea6417c52f23c94d5b5b/src/staking/Liquidity.sol#L104-L108
https://github.com/code-423n4/2024-01-salty/blob/53516c2cdfdfacb662cdea6417c52f23c94d5b5b/src/stable/CollateralAndLiquidity.sol#L153-L155
https://github.com/code-423n4/2024-01-salty/blob/53516c2cdfdfacb662cdea6417c52f23c94d5b5b/src/staking/StakingRewards.sol#L104-L112
Vulnerability details
Impact
The cooldown period is used to prevent users from reward hunting where users could frontrun reward distributions and then immediately withdraw. However, borrowers can use the cooldown period to their advantage by frontrunning liquidation and increasing their positions with a minimal amount therefore increasing their cooldown period. This forces liquidators to wait for cooldown period to expire of which borrowers can then continously repeat the same trick thereby causing DOS . Now the default cooldown period is 1 hour with a range from 15 minutes to 6 hours ( adjustable by the DAO ) which is more than the acceptable DOS of 15 minutes.
Proof of Concept
Assume a user Bob deposited collateral and borrowed a given amount of USDS. The price of his collateral fell massively and his position is open for liquidation. A liquidator Alice sees the chance to liquidate Bob's position and submits a transaction to do so. Bob monitoring the mempool, frontruns alice and deposits a small amount i.e( 0.00001wbtc & 0.0001eth ) to increase his position and thereby increases his cooldown period. since Bob's cooldown period is checked during liquidation, Alice's tx does not pass the check and reverts.Let's examine the code below.
To increase his collateral a Bob calls :
which then calls ;
Focusing on the increase user share part, we can see increase user share function has to be called with a true boolean value as stated in the comments before it meaning the Bob's cooldown period will be increased for future transactions. With that in mind , lets' see the process of liquidating Bob .
Alice calls ;
After removing liquidity , the Bob's share is supposed to be decreased and as we can see cooldown period is specified which is checked by the code below.
Therefore, since Bob's cooldown period was increased when he added their collateral the require check above will fail causing the transaction to revert and the Bob cannot be liquidated. This can happen continously and due to that liquidations are DOS'ed. This can be worse if cooldown period is set at maximum time which is 6 hours.
Tools Used
VS
Recommended Mitigation Steps
Since cooldown period is important, consider allowing the DAO to liquidate malicious borrowers since it does not use cooldown .
Assessed type
DoS
The text was updated successfully, but these errors were encountered: