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

Unaddressed nextAction state after Signal_CHANGE cancellation

Title

Unaddressed nextAction state after Signal_CHANGE cancellation

Summary

When a decrease order fails during position closure and reopening, the nextAction isn't reset. This violates the system's invariant that expects nextAction to be empty after all actions are completed.

Vulnerability Details

  1. A leveraged position on GMX is being closed and a new one opened.

  2. The keeper triggers the run() function, leading to the else block at lines 314-325:

    nextAction.selector = NextActionSelector.INCREASE_ACTION;
    nextAction.data = abi.encode(isLong);

    This schedules the next action as INCREASE_ACTION.

  3. During _createDecreasePosition(), a MarketDecrease order is created, but it fails on GMX.

  4. The keeper cancels the order, triggering afterOrderCancellation(), which resets flow and flowData but doesn't clear nextAction.

Impact

The nextAction remains set to INCREASE_ACTION, breaking the invariant that it should be empty after all actions.

Tools Used

Manual Review

Recommendations

Modify the afterOrderCancellation() function to reset nextAction when flow is SIGNAL_CHANGE.

Updates

Lead Judging Commences

n0kto Lead Judge 3 months ago
Submission Judgement Published
Invalidated
Reason: Design choice
Assigned finding tags:

invalid_afterOrderCancellation_do_not_reset_nextAction

Normal behavior, the keeper will retry to increase the position. That’s why there is this condition in `_createIncreasePosition`: ``` if (flow == FLOW.DEPOSIT) { amountIn = depositInfo[counter].amount; flowData = vaultReader.getPositionSizeInTokens(curPositionKey); } else { amountIn = collateralToken.balanceOf(address(this)); } ```

Support

FAQs

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