Open hats-bug-reporter[bot] opened 2 months ago
All Markets
are created by the MarketFactory
, and this is validated on createScalarMarket
https://github.com/seer-pm/demo/blob/4e56254cbd071b6f678a108ccdb8660951636d27/contracts/src/MarketFactory.sol#L185
the Market
itself is just a value object, and creating an invalid Market
outside of the MarketFactory
doesn't represent any risk.
Yeah, this is checked at market creation.
Github username: -- Twitter username: -- Submission hash (on-chain): 0xa2be774f8cb5c86358593e2338ab864e60d4ae0ee24be7b13c6a5f0a5aa8fbc3 Severity: medium
Description: Description\ In the current implementation of the
Market
contract, theinitialize
function allows users to set scalar market boundaries via the_lowerBound
and_upperBound
parameters. However, the contract does not validate that the_lowerBound
value is less than or equal to the_upperBound
value. This omission creates the potential for logical errors and underflows during the market resolution process.Scalar markets are markets where the outcome is a numerical value within a predefined range, defined by
lowerBound
andupperBound
. These bounds are crucial to the correct functioning of the market since they establish the valid range within which the actual result can fall.The lack of validation in the initialize function can lead to scenarios where:
lowerBound
is greater thanupperBound
, creating an invalid scalar range.resolveScalarMarket
will face underflow issues and reverts leading DOS due to the misconfiguration.The problematic area is in the initialize function:
The contract allows any values for lowerBound and upperBound, leading to a scenario where:
Here,
high - answer
andanswer - low
could result in an underflow iflowerBound > upperBound
due to incorrect assumptions about the relative values of answer, low, and high.Impact Area:
This lack of validation directly affects the behavior of the scalar markets when the market is resolved, particularly in the resolveScalarMarket function of the RealityProxy contract. The payouts array might result in underflows or incorrect payouts depending on how the results compare to the bounds.
Impact\ If
lowerBound > upperBound
, the payout calculations in theresolveScalarMarket
function will cause arithmetic underflows which will cause regular reverts leading to potential DOS.If low is greater than high, these operations will fail, and the contract will throw an exception, reverting the entire transaction and leaving the market unresolved
Recommendation\ To mitigate this issue, a simple validation check should be added in the
initialize
function to ensure that_lowerBound
is always less than_upperBound
. This will prevent the creation of invalid scalar markets and avoid the underflows and logical inconsistencies that result from inverted bounds.Suggested fix:
This check will ensure that scalar markets always have a valid range, preventing runtime errors and maintaining the integrity of the market.