-
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
User can evade liquidation
by depositing the minimum of tokens and gain time to not be liquidated
#312
Comments
Picodes marked the issue as duplicate of #891 |
Picodes marked the issue as selected for report |
othernet-global (sponsor) confirmed |
Picodes marked the issue as satisfactory |
Picodes marked the issue as not selected for report |
Picodes marked the issue as selected for report |
The stablecoin framework: /stablecoin, /price_feed, WBTC/WETH collateral, PriceAggregator, price feeds and USDS have been removed: https://github.com/othernet-global/salty-io/commit/88b7fd1f3f5e037a155424a85275efd79f3e9bf9 |
Lines of code
https://github.com/code-423n4/2024-01-salty/blob/53516c2cdfdfacb662cdea6417c52f23c94d5b5b/src/stable/CollateralAndLiquidity.sol#L140
https://github.com/code-423n4/2024-01-salty/blob/53516c2cdfdfacb662cdea6417c52f23c94d5b5b/src/stable/CollateralAndLiquidity.sol#L70
Vulnerability details
Impact
The CollateralAndLiquidity contract contains a critical vulnerability that allows a user undergoing liquidation to evade the process by manipulating the
user.cooldownExpiration
variable. This manipulation is achieved through the CollateralAndLiquidity::depositCollateralAndIncreaseShare function, specifically within the StakingRewards::_increaseUserShare function (code line #70):Malicious user can perform front-running of the
liquidation
function by depositing small amounts of tokens to his position, incrementing theuser.cooldownExpiration
variable. Consequently, the execution of theliquidation
function will be reverted with the error messageMust wait for the cooldown to expire.
This vulnerability could lead to attackers evading liquidation, potentially causing the system to enter into debt as liquidations are avoided.Proof of Concept
A test case, named
testUserLiquidationMayBeAvoided
, has been created to demonstrate the potential misuse of the system. The test involves the following steps:liquidation
execution by depositing a the minimum amount using thecollateralAndLiquidity::depositCollateralAndIncreaseShare
function.liquidation
transaction is reverted by "Must wait for the cooldown to expire" error.Tools used
Manual review
Recommended Mitigation Steps
Consider modifying the liquidation function as follows:
This modification ensures that the
user.cooldownExpiration
expiration check does not interfere with theliquidation
process, mitigating the identified security risk.Assessed type
Invalid Validation
The text was updated successfully, but these errors were encountered: