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

Potential Token Approval and Rounding Pitfalls in Order Creation

GmxProxy.sol

Observation:
Within createOrder, the contract calls:

IERC20(orderData.initialCollateralToken).safeApprove(address(gmxRouter), orderData.amountIn);

to approve the collateral token for transfer to the GMX router. Some ERC20 tokens require that an existing allowance be zeroed out before a new nonzero allowance is set. Furthermore, the approval is followed immediately by a token transfer via gExchangeRouter.sendTokens.

Validated Issue:
If the token in question follows the “approve–reset–approve” pattern, the above safeApprove call might fail or be susceptible to race conditions (i.e. if an allowance is nonzero, some tokens might be reapproved or even exploited by an attacker if they control the token’s approval flow). In addition, the order creation and subsequent state changes (including the queue assignment) depend on exact amounts. Rounding or approval issues could cause the router to receive an incorrect amount, resulting in an order that does not match the vault’s intended position sizing.

Recommendation:
Before approving, the contract should either (a) ensure that the current allowance is zero or (b) use a safe approval pattern that first resets allowance to zero (if needed). This would align with best practices and reduce the risk of allowance-related errors during order creation.

Updates

Lead Judging Commences

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

invalid_safeApprove_no_reset

USDT or other unusual ERC20 tokens: out of scope. For the other reports: No proof that the allowance won't be consumed by the receiver.

Support

FAQs

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

Give us feedback!