Skip to content
$1,000,000 in security audit grants are live now, Apply here →

Security review · August 2024

AutoCancel Updates

for GMX

Guardian's review of AutoCancel Updates for GMX, published August 2024. The report records 6 findings, including 2 medium and 4 low.

Published
Review window
August 2, 2024
Language
Solidity
Chains
Arbitrum, Avalanche
Sector
Perpetuals
  • 0 Critical
  • 0 High
  • 2 Medium
  • 4 Low
  • 0 Informational

6 acknowledged

Scope

Findings 6

  1. M-01 Medium Orders Cannot Be Updated At Max AutoCancel Amount DoS Acknowledged
    Location
    AutoCancelUtils.sol: 14

    Description

    When updating an order with the OrderHandler.updateOrder function, orders which were already present in the AutoCancel list are attempted to be re-added with the updateAutoCancelList function.

    The AutoCancel list is a set, therefore no orders are duplicated. However as the maxAutoCancelOrders validation is performed in the addAutoCancelOrderKey function, updateOrder calls are DoS'd in the following circumstance:

    • The account holds the maxAutoCancelOrders in their autoCancelOrderList
    • Order A is an existing order which is in the autoCancelOrderList
    • User attempts to update Order A, but wishes to update parameters other than the autoCancel value

    As a result the user cannot update this order without removing it from the auto cancel list or removing other auto cancel orders.

    Recommendation

    Only call the updateAutoCancelList in the event that the order autoCancel value is changed from the existing value.

  2. M-02 Medium Closed Positions With AutoCancel Orders Logical Error Acknowledged
    Location
    Global

    Description

    The syncAutoCancelOrderList function relies on an account's open positions to collect the autoCancel orders which need to be synced.

    However there may exist accounts where the position has been closed through the old contracts, and therefore autoCancel orders exist for that null position.

    Additionally some of these autoCancel orders may only be present in the autoCancel list, and not in the orderStore, therefore requiring a sync. They should all be synced and removed from the list.

    However these autoCancel orders cannot be synced as they do not belong to a position which is currently open for the account. Users may have their autoCancel orders go unsynced during the period of syncing, open their position again in the future, and have unsynced autoCancel orders which prevent their position from closing.

    Recommendation

    Consider adding a new function to target a specific positionKey instead of relying solely on the account's open positions with the getAccountPositionKeys function.

  3. L-01 Low Lacking Zero Address Checks Validation Acknowledged
    Location
    Config.sol: 83

    Description

    The initOracleProviderForToken function allows the keeper to initialize a provider. However, the provider has no validation on it and may be the zero address.

    Recommendation

    Add a zero address check on address provider.

  4. L-02 Low Compromised ConfigKeeper Can Arbitrage Impact Pool Configuration Acknowledged
    Location
    Config.sol: 101

    Description

    In the setPositionImpactDistributionRate function the configKeeper may assign any arbitrary positionImpactPoolDistributionRate, therefore if the config keeper is compromised they may drain the position impact pool by setting an excessively high rate and potential arbitrage this by depositing into the GM token market beforehand.

    Recommendation

    Consider adding a maximum impact pool distribution rate to the setPositionImpactDistributionRate function.

  5. L-03 Low Compromised ConfigKeeper Can Reset Holding Address Configuration Acknowledged
    Location
    Config.sol: 383

    Description

    The Keys.HOLDING_ADDRESS key is allowed in the _initAllowedBaseKeys function, therefore the a compromised config keeper may re-assign the holding address to their own account or assign it to the zero address.

    If the holding address is assigned to the zero address, all instances where the holding address is used will lead to a DoS, which can re-enable several risk-free trade vectors which the holding address solves.

    Recommendation

    Consider only allowing the holding address to be updated by the config keeper if it is not assigned. And allow the holding address to be configured by the more trusted timelock address.

  6. L-04 Low Compromised ConfigKeeper Can Liquidate All Positions Configuration Acknowledged
    Location
    Config.sol: 413

    Description

    In the _initAllowedBaseKeys function the MIN_POSITION_SIZE_USD and MIN_COLLATERAL_FACTOR keys are allowed as a value that the config keeper may assign, as a result a compromised config keeper may assign an exceedingly high minimum position size or minimum collateral factor and cause all GMX positions to be liquidated.

    The config keeper could short the GMX token in order to profit from such a catastrophe.

    Recommendation

    Consider moving these configurations to the more trusted time lock.

More from GMX

All 44 reports
  1. Timelock Updates

    4 findings 4 findings: 3 low, 1 informational
  2. LayerZeroProvider Routing

    1 finding 1 finding: 1 medium
  3. Open Interest Updates

    5 findings 5 findings: 2 medium, 3 low
  4. Updates Branch

    2 findings 2 findings: 2 low

Put your code through the same review.

This review started with a conversation about scope. Tell us what you are building and we will plan yours with you.

Get a quote