DeFiFoundry
50,000 USDC
View results
Submission Details
Severity: low
Invalid

ETH Withdrawal Disruption in GmxProxy Leading to Protocol Malfunction

Impact: Medium

Likelihood: Medium

Description

In the GmxProxy, there is a function named withdrawEth that withdraws all of the ETH to the owner. However, performing this action can cause issues with the associated PerpetualVault. If there is no ETH in GmxProxy, the main mechanism of the protocol will break. Consequently, the Keeper will be unable to execute the run function due to the lack of ETH in GmxProxy. As a result, actions such as signal changes and opening positions will become unavailable.

Impact

Breaks the main function of the protocol. Keeper won't be able to nothing so users can lost funds or get liquidated.

Proof of Concepts

  1. Alice deposits collateralToken to the PerpetualVault

  2. Signal is sent off-chain and Keeper calls run function to open some position for example to run swap, so GMX order got created

  3. GMX order got executed successfully, so swap was made

  4. GmxProxy owner calls withdrawEth and withdraw all of the ETH

  5. If there is new signal and run function will revert due to lack of ETH

PoC:
In the test file PerpetualVault.t.sol add fallback function, because in this test protocol is owner of the GmxProxy and should be able to receive funds

fallback() external payable {}

Add the following test:

function test_Run_SignalChange_Fail() external {
address keeper = PerpetualVault(vault).keeper();
address alice = makeAddr("alice");
depositFixture(alice, 2e10);
MarketPrices memory prices = mockData.getMarketPrices();
bytes[] memory swapData = new bytes[](2);
bytes memory paraSwapData = mockData.getParaSwapData(vault);
swapData[0] = abi.encode(PROTOCOL.DEX, paraSwapData);
address[] memory gmxPath = new address[](1);
gmxPath[0] = address(0x70d95587d40A2caf56bd97485aB3Eec10Bee6336);
uint256 minOutputAmount = 1e10 * prices.shortTokenPrice.min / prices.longTokenPrice.min * 95 / 100; // 5% slippage
swapData[1] = abi.encode(PROTOCOL.GMX, abi.encode(gmxPath, 1e10, minOutputAmount));
vm.prank(keeper);
PerpetualVault(vault).run(true, true, prices, swapData);
assertEq(PerpetualVault(vault).isLock(), true);
GmxOrderExecuted(true);
assertEq(uint8(PerpetualVault(vault).flow()), 0);
assertEq(PerpetualVault(vault).positionIsClosed(), false);
(PerpetualVault.NextActionSelector selector, ) = PerpetualVault(vault).nextAction();
assertEq(uint8(selector), 0);
// assertEq(uint8(PerpetualVault(vault).isNextAction()), 0);
gmxPath[0] = address(0x70d95587d40A2caf56bd97485aB3Eec10Bee6336);
address indexToken = PerpetualVault(vault).indexToken();
uint256 indexTokenBalance = IERC20(indexToken).balanceOf(vault);
bytes[] memory newSwapData = new bytes[](1);
minOutputAmount = indexTokenBalance * prices.longTokenPrice.min / prices.shortTokenPrice.min * 95 / 100; // 5% slippage
newSwapData[0] = abi.encode(PROTOCOL.GMX, abi.encode(gmxPath, indexTokenBalance, minOutputAmount));
address gmxProxy = address(PerpetualVault(vault).gmxProxy());
GmxProxy(payable(gmxProxy)).withdrawEth();
vm.expectRevert();
vm.prank(keeper);
PerpetualVault(vault).run(true, false, prices, newSwapData);
}

Execute the following command: forge test --mt test_Run_SignalChange_Fail --rpc-url arbitrum -vvvv

Recommended Mitigation

Consider adding check for minimum amount of eth that won't be withdraw and won't break the Protocol

Updates

Lead Judging Commences

n0kto Lead Judge 3 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Admin is trusted / Malicious keepers

Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelihood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point. Keepers are added by the admin, there is no "malicious keeper" and if there is a problem in those keepers, that's out of scope. ReadMe and known issues states: " * System relies heavily on keeper for executing trades * Single keeper point of failure if not properly distributed * Malicious keeper could potentially front-run or delay transactions * Assume that Keeper will always have enough gas to execute transactions. There is a pay execution fee function, but the assumption should be that there's more than enough gas to cover transaction failures, retries, etc * There are two spot swap functionalies: (1) using GMX swap and (2) using Paraswap. We can assume that any swap failure will be retried until success. " " * Heavy dependency on GMX protocol functioning correctly * Owner can update GMX-related addresses * Changes in GMX protocol could impact system operations * We can assume that the GMX keeper won't misbehave, delay, or go offline. " "Issues related to GMX Keepers being DOS'd or losing functionality would be considered invalid."

Appeal created

pindarew Submitter
3 months ago
n0kto Lead Judge
2 months ago
n0kto Lead Judge 2 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Admin is trusted / Malicious keepers

Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelihood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point. Keepers are added by the admin, there is no "malicious keeper" and if there is a problem in those keepers, that's out of scope. ReadMe and known issues states: " * System relies heavily on keeper for executing trades * Single keeper point of failure if not properly distributed * Malicious keeper could potentially front-run or delay transactions * Assume that Keeper will always have enough gas to execute transactions. There is a pay execution fee function, but the assumption should be that there's more than enough gas to cover transaction failures, retries, etc * There are two spot swap functionalies: (1) using GMX swap and (2) using Paraswap. We can assume that any swap failure will be retried until success. " " * Heavy dependency on GMX protocol functioning correctly * Owner can update GMX-related addresses * Changes in GMX protocol could impact system operations * We can assume that the GMX keeper won't misbehave, delay, or go offline. " "Issues related to GMX Keepers being DOS'd or losing functionality would be considered invalid."

Support

FAQs

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