There is no market enabled validation in Swap and CreateAdl activities
The swap and ADL (auto-deleveraging) code paths did not check that a market was enabled before executing activities on it. An attacker could still perform swaps and create ADL orders on a market that had been disabled.
Source: https://github.com/sherlock-audit/2023-02-gmx-judging/issues/33
Found by
IllIllI, caventa
Summary
There is no market enabled validation in Swap and CreateAdl activities.
Vulnerability Detail
Controller may execute activities for disabled market in Swaphandler and CreateAdlHandler
Impact
Activities can still be performed on an disabled market
Code Snippet
https://github.com/sherlock-audit/2023-02-gmx/blob/main/gmx-synthetics/contracts/swap/SwapUtils.sol#L98-L149 https://github.com/sherlock-audit/2023-02-gmx/blob/main/gmx-synthetics/contracts/swap/SwapUtils.sol#L158-L318 https://github.com/sherlock-audit/2023-02-gmx/blob/main/gmx-synthetics/contracts/adl/AdlUtils.sol#L125-L173
Tool used
Manual Review
Recommendation
Add the similar following code
Market.Props memory _market = MarketUtils.getEnabledMarket(dataStore, market);
to swap and createAdl
Discussion
xvi10
for ADL, the market is validated in _getExecuteOrderParams called after AdlUtils.createAdlOrder
for swaps, the swap path is fetched with getEnabledMarkets before calling the swap function
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
Activities could still be performed on a disabled market, though the maintainers state that ADL validates the market later and swaps fetch enabled markets before swapping.
What the attacker needed
A disabled market; ability to submit swap or ADL transactions
The fix
The recommendation was to add an enabled-market lookup in the swap and createAdl paths; the maintainers argued existing later checks already cover it.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A market is a trading pair that the protocol can switch off. The code that runs swaps and ADL orders did not confirm the market was switched on, so actions could still go through on a disabled market. The maintainers replied that other checks later in the flow already cover this.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.