Skip to content
Audit finding Intermediate

Insufficient oracle validation

Breeje Follow with IllIllI, PRAISE and 2 others

Originally disclosed on Sherlock

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

Found by

Breeje, IllIllI, PRAISE, ShadowForce, rvierdiiev

Summary

Most prices are provided by an off-chain oracle archive via signed prices, but a Chainlink oracle is still used for index prices. These prices are insufficiently validated.

Vulnerability Detail

There is no freshness check on the timestamp of the prices, so old prices may be used if OCR was unable to push an update in time

Impact

Old prices mean traders will get wrong PnL values for their positions, leading to liquidations or getting more/less than they should, at the expense of other traders and the liquidity pools.

Code Snippet

The timestamp field is ignored, which means there's no way to check whether the price is recent enough:

Solidity
// File: gmx-synthetics/contracts/oracle/Oracle.sol : Oracle._setPricesFromPriceFeeds()   #1

571                (
572                    /* uint80 roundID */,
573                    int256 _price,
574                    /* uint256 startedAt */,
575 @>                 /* uint256 timestamp */,
576                    /* uint80 answeredInRound */
577:                ) = priceFeed.latestRoundData();

https://github.com/sherlock-audit/2023-02-gmx/blob/main/gmx-synthetics/contracts/oracle/Oracle.sol#L567-L587

Tool used

Manual Review

Recommendation

Add a staleness threshold number of seconds configuration parameter, and ensure that the price fetched is within that time range

Discussion

xvi10

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

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

What is known

A medium-severity security bug in GMX Update. Sherlock made it public on 4 April 2023. Found in the 6 audit contest (finding M-8), also found by 4 other wardens.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

More by Breeje

View all

6 more disclosed reports, best first.

More from GMX Update

View all

The newest disclosed reports for this program.

Similar reports

Same bug class and techniques, clearest first.