Skip to content
Business logic Audit finding Intermediate

_validateRange in Config does not check the input value as described

The `_validateRange` function in the Config contract does not actually check that the input value is within the allowed range, despite its documentation. An attacker could set configuration values outside the intended bounds, potentially disrupting the protocol.

0xGoodess Follow

Originally disclosed on Sherlock

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

Found by

0xGoodess

Summary

_validateRange in Config does not check the input value as described

Vulnerability Detail

in the dev note of this function _validateRange : it said // @dev validate that the value is within the allowed range. However in the function itself the value is only used in sending revert message, but not used in any check against a pre-set boundary.

Impact

function does not verify the input value is within an expected range

Code Snippet

https://github.com/gmx-io/gmx-synthetics/blob/8028cb8022b85174be861b311f1082b5b76239df/contracts/config/Config.sol#L271

Tool used

Manual Review

Recommendation

Retrieve the min/max of a baseKey and does checking.

Discussion

IllIllI000

@xvi10 can you confirm that this is invalid?

xvi10

it is a valid issue

IllIllI000

@hrishibhat agree with sponsor – valid Medium

chrisckwong821

Escalate for 10 USDC

sherlock-admin

Escalate for 10 USDC

You've created a valid escalation for 10 USDC!

To remove the escalation from consideration: Delete your comment.

You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.

IllIllI000

I messed up the tagging - Valid solo Medium

hrishibhat

Escalation accepted

Considering this issue a valid medium

sherlock-admin

Escalation accepted

Considering this issue a valid medium

This issue's escalations have been accepted!

Contestants' payouts and scores will be updated according to the changes made on this issue.

xvi10

Fix in https://github.com/gmx-io/gmx-synthetics/pull/81

The original report as published on Sherlock, by 0xGoodess. 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 function was intended to validate the range but the check was omitted, so the value is only used in the revert message.

Impact

Configuration values could be set outside the allowed range, potentially causing unexpected behaviour in the protocol.

What the attacker needed

Ability to call the function

The fix

The function should retrieve the min/max of a baseKey and perform the range check.

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 smart contract function is supposed to check that a number is within a safe range, but it doesn't. This means someone could set that number to an extreme value, which might break the system.

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 0xGoodess

View all

13 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.