sherlock-audit / 2023-02-gmx-judging

17 stars 11 forks source link

simon135 - if the token gas limit is too little it can be an issue #215

Closed sherlock-admin closed 1 year ago

sherlock-admin commented 1 year ago

simon135

medium

if the token gas limit is too little it can be an issue

Summary

if the token gas limit is too little and the function reverts but on the createDeposit, it didn't need to or the Transfer for depositing is less than here it, users funds will be lost

Vulnerability Detail

If the system only allows a small gas limit on the call back/on native transfer/transfer and it reverts or can't go out to an external protocol users funds will be lost

Impact

protocols can integrate with the gmx and some users' funds can be stuck

Code Snippet

        MarketToken(payable(order.market())).transferOut(
            result.outputToken,
            order.receiver(),
            result.outputAmount,
            order.shouldUnwrapNativeToken()

https://github.com/gmx-io/gmx-synthetics/blob/c4814a6c4c9269b9367fb6d462e30ff6f37480e5/contracts/order/DecreaseOrderUtils.sol#L170-L174

Tool used

Manual Review

Recommendation