Steadefi

Steadefi
DeFiHardhatFoundryOracle
35,000 USDC
View results
Submission Details
Severity: medium
Valid

`addLiquidity` && `removeLiquidity` in `emergencyResume` and `emergencyPause` are prone to sandwich attacks

Summary

addLiquidity && removeLiquidity in the emergencyResume and emergencyPause functions do not check the minimum liquidity amounts. This makes vault funds vulnerable to sandwich attacks.

Vulnerability Details

During an emergency pause, the removeLiquidity function is called without specifying the minimum amount for long and short tokens that must be received (minLongTokenAmount and minShortTokenAmount). This exposes the transaction to potential sandwich attacks, where an attacker can manipulate the market price by performing trades before and after the transaction. The same vulnerability is present in the emergencyResume function with addLiquidity, where liquidity is added back without checking for minimum amounts, making it possible for an attacker to extract value.

Exemple :

function emergencyPause(
GMXTypes.Store storage self
) external {
self.refundee = payable(msg.sender);
GMXTypes.RemoveLiquidityParams memory _rlp;
// Remove all of the vault's LP tokens
_rlp.lpAmt = self.lpToken.balanceOf(address(this));
_rlp.executionFee = msg.value;
GMXManager.removeLiquidity(
self,
@> _rlp
);

Since minTokenAAmt and minTokenBAmt are not defined, the _rlp.minTokenBAmt and _rlp.minTokenAAmt have the default value 0. Which makes this transaction vulnerable to MEV Bots. Same thing for for the emergencyResume function where minMarketTokenAmt is not defined for addingLiquidity.

Impact

High. The lack of minimum amount checks can lead to significant financial loss as attackers can drain the value from the transactions.

Tools Used

Manual Review

Recommendations

Define and enforce minimum amounts for long, short tokens and LP tokens as function parameters when calling removeLiquidity and addLiquidity during emergency procedures to prevent exploitation through sandwich attacks.

Updates

Lead Judging Commences

hans Lead Judge almost 2 years ago
Submission Judgement Published
Validated
Assigned finding tags:

Slippage protection on emergency Pause/Resume

Impact: High Likelihood: Low Because the whole lpToken balance is used during the emergency process, the impact is high. But the likelihood is LOW because of the dependence on the emergency.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.