Insufficient oracle validation
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:
// 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();
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
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.