A vulnerability has been identified in the Statistics contract where the variance calculation can revert due to integer underflow when the mean is greater than any individual data point.
In Statistics.sol:22
, the variance calculation function contains a mathematical operation that can cause an underflow. The relevant code section shows:
The vulnerability exists because:
The calculation uses unsigned integers (uint256
)
When mean
is larger than data[i]
, subtraction will underflow
No check exists to handle cases where mean > individual data points
The current implementation assumes all data points are greater than or equal to the mean
Example of failure:
Function reverts for valid statistical calculations
Unusable for datasets where mean exceeds any data point
Causes the purchase score validation logic to fail if any given score is less than the mean of all the scores
Manual Review
To address this vulnerability, implement the following measures:
Use Absolute Difference
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.