The Statistics.variance() function will revert in most practical cases due to an arithmetic underflow when calculating differences between values and their mean. Since Solidity 0.8+ includes checked arithmetic, any subtraction where data[i] < mean will revert. This vulnerability effectively breaks the oracle validation system which relies on this statistical calculation.
The variance function in Statistics.sol uses unchecked arithmetic to calculate the difference between each value and the mean.
This can lead to underflows when the value is less than the mean.
The variance function is used in Statistics.stddev() which is called in LLMOracleCoordinator::finalizeValidation() to calculate the standard deviation of the oracle responses and determine the validation score.
Where the oracles.validators calls LLMOracleCoordinator.validate() to validate the oracle responses.
In Statistics.sol:
This function is used in LLMOracleCoordinator.sol for validating oracle responses:
HIGH. The vulnerability:
Breaks the entire oracle validation system
Prevents calculation of validation scores
Makes it impossible to determine valid oracle responses
Affects all operations that depend on statistical validation
Attack Path:
Oracle nodes submit responses
Validation attempt is made
Variance calculation reverts due to underflow
Validation fails
No responses can be processed
Protocol becomes unusable
Manual Review
Consider this simple example that will fail:
Replace the current implementation with a safe version that handles values below mean:
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.