Skip to content
Business logic Audit finding Intermediate

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.

IllIllI Follow with caventa

Originally disclosed on Sherlock

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

Solidity
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

The original report as published on Sherlock, by IllIllI. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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.

More by IllIllI

View all

119 more disclosed reports, best first.

More from GMX Update

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.