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
Scope
Findings 6
-
M-01 Medium Orders Cannot Be Updated At Max AutoCancel Amount DoS Acknowledged
Description
When updating an order with the
OrderHandler.updateOrderfunction, orders which were already present in the AutoCancel list are attempted to be re-added with theupdateAutoCancelListfunction.The AutoCancel list is a set, therefore no orders are duplicated. However as the
maxAutoCancelOrdersvalidation is performed in theaddAutoCancelOrderKeyfunction, updateOrder calls are DoS'd in the following circumstance:- The account holds the
maxAutoCancelOrdersin theirautoCancelOrderList - 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
autoCancelvalue
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
updateAutoCancelListin the event that the orderautoCancelvalue is changed from the existing value. - The account holds the
-
M-02 Medium Closed Positions With AutoCancel Orders Logical Error Acknowledged
Description
The
syncAutoCancelOrderListfunction relies on an account's open positions to collect theautoCancelorders which need to be synced.However there may exist accounts where the position has been closed through the old contracts, and therefore
autoCancelorders exist for that null position.Additionally some of these
autoCancelorders may only be present in theautoCancellist, and not in theorderStore, therefore requiring a sync. They should all be synced and removed from the list.However these
autoCancelorders 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 unsyncedautoCancelorders which prevent their position from closing.Recommendation
Consider adding a new function to target a specific
positionKeyinstead of relying solely on the account's open positions with thegetAccountPositionKeysfunction. -
L-01 Low Lacking Zero Address Checks Validation Acknowledged
Description
The
initOracleProviderForTokenfunction 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.
-
L-02 Low Compromised ConfigKeeper Can Arbitrage Impact Pool Configuration Acknowledged
Description
In the
setPositionImpactDistributionRatefunction theconfigKeepermay assign any arbitrarypositionImpactPoolDistributionRate, 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
setPositionImpactDistributionRatefunction. -
L-03 Low Compromised ConfigKeeper Can Reset Holding Address Configuration Acknowledged
Description
The
Keys.HOLDING_ADDRESSkey is allowed in the_initAllowedBaseKeysfunction, 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.
-
L-04 Low Compromised ConfigKeeper Can Liquidate All Positions Configuration Acknowledged
Description
In the
_initAllowedBaseKeysfunction theMIN_POSITION_SIZE_USDandMIN_COLLATERAL_FACTORkeys 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.
No findings match.
More from GMX
All 44 reportsPut 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.
