This repository has been archived by the owner on Sep 24, 2023. It is now read-only.
IllIllI - Positions can still be liquidated even if orders to prevent it can't execute #168
Labels
Medium
Reward
A payout will be made for this issue
Sponsor Confirmed
Won't Fix
The sponsor confirmed this issue will not be fixed
IllIllI
medium
Positions can still be liquidated even if orders to prevent it can't execute
Summary
Positions can still be liquidated even if orders to close positions or add collateral can't execute, because liquidation does not transfer tokens
Vulnerability Detail
Liquidation orders do not transfer tokens - they just use the
increment*()
/applyDelta*()
functions to update the portions allotted to the various parties. Orders to close positions, on the other hand, actually transfer the tokens so if the transfer reverts, the position can't be closed. If the collateral token is paused (e.g. USDC), a user won't be able to close their position, or add collateral to it, in order to prevent it from being liquidated, but the liquidation keeper will be able to liquidate without any issue.Impact
Users will be liquidated without being able to prevent it
Code Snippet
Liquidation doesn't actually transfer any funds - it just updates who got what:
https://github.com/sherlock-audit/2023-02-gmx/blob/main/gmx-synthetics/contracts/position/DecreasePositionCollateralUtils.sol#L344-L364
And then increments/applies delta to the accounting.
Tool used
Manual Review
Recommendation
Keep user collateral at a separate address from the pool address, so that liquidations have to do an actual transfer which may revert, rather than just updating internal accounting
The text was updated successfully, but these errors were encountered: