Dria

Swan
NFTHardhat
21,000 USDC
View results
Submission Details
Severity: high
Valid

Validation can't be finalized for certain generation deviation factors

Summary

When finalizing the validations coordinator will also calculate which generators (responders) are eligible for rewards. It also aims to filter out lower outliers:

// ignore lower outliers
if (generationScores[g_i] >= mean - generationDeviationFactor * stddev) {
_increaseAllowance(responses[taskId][g_i].responder, task.generatorFee);
}

There is an implicit assumption here that mean is greater than generationDeviationFactor * stddev, because if it is not, the check will underflow and TX will revert. The likelihood of this happening increases the higher value generationDeviationFactor is set to. The default value for generationDeviationFactor is 1, but it can be changed by oracle coordinator's owner at any point.

Vulnerability Details

Let's say the number of validators for a given task is 3 and the number of generators is 1. Here's a scenario that triggers the bug:

  • in round 1, validators score the response with scores 1, 100 and 200 respectively. All good

  • at the end of round 1, coordinator's owner calls setDeviationFactors and sets generationDeviationFactor to 2 (previously it was default value of 1)

  • in round 2, 1st and 2nd validators score the new task's response with scores of 1 and 100 again. Last validator also wants to score new task's response by 200. However call to validate will now fail, because mean - generationDeviationFactor * stddev underflows.

Impact

Due to this bug not all scoring outcomes are possible and that impacts the fairness of final scoring and reward distribution.

Tools Used

Manual review

Recommendations

Change implementation to avoid underflow, ie.:

// ignore lower outliers
- if (generationScores[g_i] >= mean - generationDeviationFactor * stddev) {
+ if ((mean < generationDeviationFactor * stddev) || (generationScores[g_i] >= mean - generationDeviationFactor * stddev)) {
_increaseAllowance(responses[taskId][g_i].responder, task.generatorFee);
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 12 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Underflow in `LLMOracleCoordinator::validate`

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.