Summary
An unsafe token transfer occurs in _createIncreasePosition
, where collateral tokens are transferred to gmxProxy
before confirming order creation. If the order fails, the funds could be stuck.
Vulnerability Details
Collateral tokens are transferred before ensuring successful order creation.
The function safeTransfer
prevents direct transfer failures but does not handle failures in the subsequent order creation process (gmxProxy.createOrder
).
If createOrder
fails, there is no recovery mechanism to reclaim transferred tokens.
Impact
If gmxProxy.createOrder
fails, tokens remain in gmxProxy
, potentially leading to fund loss.
There is no rollback mechanism to recover these tokens in case of failure.
Premature Transfer: Collateral tokens are transferred before verifying whether the order can be successfully created.
No Recovery Mechanism: If createOrder
fails, the contract lacks a function to reclaim tokens from gmxProxy
.
Order Failure Scenarios: createOrder
might fail due to insufficient execution gas, disabled GMX execution, or invalid order parameters.
Tools Used
Manual Code Review
Static Analysis Tools (Slither, MythX)
Recommendations
Verify Order Creation Feasibility Before Transferring Tokens
Ensure createOrder
will succeed before calling safeTransfer
.
Use a Two-Step Process for Token Transfer:
First, approve tokens for transfer.
Transfer only after createOrder
succeeds.
Implement a Fallback Recovery Mechanism:
Add a function to retrieve stuck tokens in case of order failure.
Example:
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.
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.