The LLMOracleCoordinator
contract implements a validation scoring system where validators provide scores for generated responses. The final validation process in finalizeValidation()
uses statistical measures (mean and standard deviation) to determine which scores are valid and which validators/generators should be rewarded.
In the finalizeValidation()
function, there is a critical underflow risk when calculating the lower bound for valid scores using the formula score >= _mean - _stddev
. The standard deviation can be larger than the mean in cases of high data variability or outliers, which would cause this calculation to underflow.
The validation logic assumes that standard deviation will always be smaller than the mean, but this is mathematically incorrect. For example, consider a set of validation scores [1, 1, 1, 97]:
Mean = 25
Variance = ((1-25)² + (1-25)² + (1-25)² + (97-25)²) / 4 = 1,800
Standard deviation = √1,800 ≈ 42.4
In this case, _mean - _stddev
would be 25 - 42.4, causing an arithmetic underflow in Solidity since unsigned integers cannot be negative.
High. An underflow in the score validation calculation would cause the transaction to revert, making it impossible to complete the validation process for tasks with high score variability. This effectively breaks the core functionality of the protocol for certain valid input scenarios.
Medium. While most normal validation scenarios might have scores within a reasonable range, the conditions leading to this underflow are not exotic. They can occur naturally when:
Validators strongly disagree on quality
There are outlier scores
The score distribution is skewed
Modify the score validation logic to handle cases where standard deviation exceeds the 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.