This repository was archived by the owner on Sep 24, 2023. It is now read-only.
This repository was archived by the owner on Sep 24, 2023. It is now read-only.
IllIllI - A single precision value may not work for both the min and max prices #182
Open
Description
IllIllI
medium
A single precision value may not work for both the min and max prices
Summary
The same precision may not work for the min and max prices
Vulnerability Detail
If the min price reaches the maximum value possible for the specified level of precision, the max price won't be able to use the same precision.
Impact
Depending on how the order keepers and oracle archive work, either the fetching the price from the oracle will fail, or the user will get less than they deserve. This may happen when a user is at the border of being liquidated, and it would be unfair to liquidate the user.
Code Snippet
The same precision is required to be used for both the min and max prices:
// File: gmx-synthetics/contracts/oracle/OracleUtils.sol : OracleUtils.validateSigner() #1
254 ) internal pure {
255 bytes32 digest = ECDSA.toEthSignedMessageHash(
256 keccak256(abi.encode(
257 SALT,
258 info.minOracleBlockNumber,
259 info.maxOracleBlockNumber,
260 info.oracleTimestamp,
261 info.blockHash,
262 info.token,
263 info.tokenOracleType,
264 @> info.precision,
265 @> info.minPrice,
266 @> info.maxPrice
267 ))
268 );
269
270: address recoveredSigner = ECDSA.recover(digest, signature);
The example from the source comments show that legitimate values feasibly can occur on precision boundaries.
Tool used
Manual Review
Recommendation
Provide separate precision values for min and max prices