-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Users can prevent themselves from getting liquidated indefinitely #891
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
Comments
Picodes marked the issue as primary issue |
This was referenced Jan 31, 2024
DoS: Liquidation of an Undercollateralized position might fail due to Cooldown period of Wallet
#922
Closed
A user can prevent being liquidated by adding few wei of collateral just before liquidator call
#921
Closed
Closed
This was referenced Jan 31, 2024
Picodes marked issue #312 as primary and marked this issue as a duplicate of 312 |
This was referenced Jan 31, 2024
Closed
Picodes marked the issue as satisfactory |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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/main/src/stable/CollateralAndLiquidity.sol#L140-L188
https://github.com/code-423n4/2024-01-salty/blob/main/src/staking/StakingRewards.sol#L104-L111
Vulnerability details
Impact
The logic for liquidating a user involves calling
_decreaseUserShare
for the user being liquidated, as their entire WBTC-WETH collateral is being taken. However, in this call, the parameteruseCooldown
=true, which means that you must wait untilcooldownExpiration
is reached for a user. A malicious user who is getting liquidated can then abuse this by front-running all calls to liquidate themselves by adding a very small amount of LP such thatcooldownExpiration
is incremented, making the liquidation call revert. This action can be done indefinitely to prevent liquidations forever at very low cost.Proof of Concept
When a user is getting liquidated, the liquidator will call
CollateralAndLiquidity:liquidateUser
, which is defined as follows:As can be seen, there is a call to
_decreaseShare
with the parameteruseCooldown
set totrue
. Let's see how this is used in theStakingRewards:_decreaseUserShare
function call:As can be seen,
(block.timestamp >= user.cooldownExpiration)
is required, else this call will fail. Although this is already an issue in itself, a malicious user can abuse this to continuously increaseuser.cooldownExpiration
every time there is an attempt to liquidate them by simply callingCollateralAndLiquidity:depositCollateralAndIncreaseShare
withmaxAmountWBTC
=101,maxAmountWETH
=101. This function does in internal call to_depositLiquidityAndIncreaseShare
, which includes the following logic:Here
useCooldown
is alsotrue
, meaning thatuser.cooldownExpiration
is updated, allowing the attacker to prevent themselves from getting liquidated.Tools Used
Manual review
Recommended Mitigation Steps
In
CollateralAndLiquidity:liquidateUser
on line 154, the call to_decreaseUserShare
should not haveuseCooldown
=true.Assessed type
Other
The text was updated successfully, but these errors were encountered: