Description: Users can deposit and withdraw funds using the deposit() and withdraw() functions. An off-chain keeper manages the opening and closing of positions on GMX via the run() and runNextAction() functions. However, when users fully withdraw their funds, the protocol fails to clear the state variable positionIsClosed
. As a result, even though the user's position is fully closed, the vault remains in an "open" state, preventing subsequent deposits from being processed and potentially locking user funds.
Impact: New deposits trigger an increase flow that never completes, locking funds in the vault and preventing users from opening new positions or withdrawing funds.
Proof-Of-Concept:
Alice deposits funds when the vault is idle.
The vault immediately mints shares via _mint()
, and then the off-chain keeper calls run()
and runNextAction()
to open a position on GMX. now, positionIsClosed
is false.
After that Alice withdraws all her funds from protocol, fully closing her position but the vault does not reset positionIsClosed
back to true, so the vault remains in an “open position” state.
When Alice later attempts to deposit again in protocol. the deposit function falls into the branch that handles active positions because positionIsClosed
is false. This branch queues an increase action rather than minting shares immediately.
The keeper calls the run()
but the calls revert and Alice's funds are stuck in the protocol
When the keeper calls run()
, the call reverts with a FlowInProgress() error because the vault’s flow state was not properly reset. If the keeper then calls runNextAction()
, the flow remains stuck in the DEPOSIT state instead of being cleared to NONE.
As a result, if Alice subsequently attempts to withdraw, the transaction reverts with a custom error indicating that a flow is in progress, leaving her funds locked in the vault.
Paste this code in PrepetualVAult.t.sol
Recommended Mitigation Steps: Implement a state reset logic that correctly updates flow
and the positionIsClosed
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.