The PerpetualVault contract uses a _gmxLock variable to prevent reentrancy and ensure atomicity during GMX operations (e.g., creating, increasing, or decreasing positions). However, inconsistent handling of this lock can lead to deadlocks, unauthorized actions, or permanent contract locking.
The _gmxLock variable is set to true when a GMX operation is initiated and reset to false after the operation is completed (via a callback from GMX).
The gmxLock modifier ensures that no other GMX operations can be initiated while _gmxLock is true.
If the afterOrderExecution or afterOrderCancellation callback fails to reset _gmxLock, the contract will remain locked.
An attacker could bypass the gmxLock modifier and create a new position while another position is being modified.
If _gmxLock is reset prematurely, the contract could allow overlapping GMX operations, leading to race conditions.
Deploy the PerpetualVault contract.
Deploy the Attack contract, passing the address of the PerpetualVault contract.
Call the attack function on the Attack contract.
This triggers a GMX operation and simulates a failed callback.
Call isLocked on the PerpetualVault contract to verify that the contract is permanently locked.
Attempt to call createOrder again. Observe that the transaction reverts with the error "GMX lock active".
The contract becomes permanently locked, preventing any further GMX operations.
Users cannot deposit, withdraw, or modify positions, effectively rendering the contract unusable.
Manual Code Review
Always reset _gmxLock to false after a GMX operation, even if the operation fails.
Implement a timeout mechanism to automatically reset _gmxLock if a GMX operation takes too long.
solidity
Ensure that only the GMX proxy contract can call the callback functions.
There is no real proof, concrete root cause, specific impact, or enough details in those submissions. Examples include: "It could happen" without specifying when, "If this impossible case happens," "Unexpected behavior," etc. Make a Proof of Concept (PoC) using external functions and realistic parameters. Do not test only the internal function where you think you found something.
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.