Skip to content
Business logic Audit finding Intermediate

If block range it big and adl dosnt use currentblock in the order it will cause issues

The ADL order uses a block number from the oracle parameters that may be outside the allowed range, causing the order to fail and the protocol to accrue bad debt. An attacker could exploit this by providing an old block number if they control the ADL keeper.

simon135 Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-02-gmx-judging/issues/216

Found by

simon135

Summary

if block range is a big range and since adl order uses cache.minOracleBlockNumbers[0] there can be an issue of the block not being in range because of the littlest block with max block being a lot bigger and adl wont happen and the protocol will get bad debt

Vulnerability Detail

since the adl order updateBlock is cache.minOracleBlockNumbers[0] the block can be behind the range check and fail and the protocol can end up in bad debt with the tokens price declining

Impact

bad debt

Code Snippet

Solidity
        cache.key = AdlUtils.createAdlOrder(
            AdlUtils.CreateAdlOrderParams(
                dataStore,
                eventEmitter,
                account,
                market,
                collateralToken,
                isLong,
                sizeDeltaUsd,
                cache.minOracleBlockNumbers[0]
            )

Tool used

Manual Review

Recommendation

make it chain.currentBLock

Discussion

xvi10

doesn't seem to be a valid issue, cache.minOracleBlockNumbers[0] is from oracleParams which is provided by the ADL keeper, the ADL keeper should use the latest prices to execute ADL

IllIllI000

@xvi10 I know that the order keepers are intended to eventually be only semi-trusted. Is that not the case for ADL keepers - they'll always be fully trusted?

xvi10

i think the impact is minimized if there is at least one honest ADL keeper, if all ADL keepers are dishonest it is possible for ADLs to continually occur using older prices

IllIllI000

It sounds like ADL keepers are not fully trusted and therefore this is an unlikely, but possible risk

The original report as published on Sherlock, by simon135. 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

Root cause

Likely the ADL order uses a block number from the oracle parameters that may not be the current block, and if it falls outside the allowed range, the order fails.

Impact

If the block number is out of range, the ADL order fails and the protocol could accrue bad debt, but this requires a dishonest ADL keeper or an outdated block number.

What the attacker needed

ADL keeper provides an old block number; block number outside allowed range

The fix

The recommendation is to use the current block number instead of the oracle block number.

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.

ADL (auto-deleveraging) is a mechanism to reduce risk by closing positions. The order uses a block number from the oracle data, which might be too old and fail a check, leaving the protocol with bad debt. This could happen if the keeper (the entity submitting the order) provides an outdated block number.

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 simon135

View all

1 more disclosed report, 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.