Steadefi

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

GMXEmergency doesn't have slippage protection

Summary

GMXEmergency contract doesn't pass slippage arguments to GMX request inside emergencyPause and emergencyResume functions. As result they can be sandwhiched.

Vulnerability Details

GMXEmergency contract has ability to pause protocol using emergencyPause function.
https://github.com/Cyfrin/2023-10-SteadeFi/blob/main/contracts/strategy/gmx/GMXEmergency.sol#L47-L66

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
);
self.status = GMXTypes.Status.Paused;
emit EmergencyPause();
}

This function creates RemoveLiquidityParams struct and set only lpAmt and executionFee to it. Then later it pass this param to execute GMX request. Later, in GMXWorker this param is used to fetch min amounts that should be received after withdraw. As these min amount were not set, they are 0, so there is no slippage protection for such withdraw.

Exactly same situation is for emergencyResume function, where minMarketTokenAmt is not calculated.

So both these functions can be sandwhiched in order to get profit. And the main risk here is that whole vault balance is used here.

Impact

Functions don't have slippage protection.

Tools Used

VsCode

Recommendations

You need to calculate min amounts that you are going to receive from GMX.

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.