Dria

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

Unfair Response Selection in Oracle Task Resolution

Relevant Context

The LLMOracleCoordinator contract manages LLM generation tasks where multiple generators provide responses that are then scored by validators. The getBestResponse() function is responsible for selecting the winning response based on validation scores.

Finding Description

The getBestResponse() function has two significant fairness issues in its selection mechanism:

  1. When all scores are 0 (which can happen when all validation scores fall outside the acceptable range in finalizeValidation()), the function automatically selects the first response without any randomization or failure handling.

  2. When multiple responses have the same highest score, the function always selects the first one encountered, creating an unfair advantage for earlier responders.

The root cause is in the simple comparison logic in getBestResponse():

TaskResponse storage result = taskResponses[0];
uint256 highestScore = result.score;
for (uint256 i = 1; i < taskResponses.length; i++) {
if (taskResponses[i].score > highestScore) {
highestScore = taskResponses[i].score;
result = taskResponses[i];
}
}

This creates a deterministic bias favoring earlier responses in cases of ties or zero scores.

Impact Explanation

Medium. While this doesn't lead to direct fund loss, it undermines the fairness of the oracle system by:

  1. Creating an unfair advantage for earlier responders

  2. Potentially selecting low-quality responses when all scores are 0

  3. Reducing the incentive for later responders to provide high-quality responses

Likelihood Explanation

Medium. Score ties are likely to occur frequently in real-world scenarios, especially with discrete scoring systems. Zero scores can occur when validators assign scores that fall outside the acceptable range in finalizeValidation().

Proof of Concept

Scenario 1 - Zero Scores:

  1. Task receives 3 responses from different generators

  2. Validators assign scores that fall outside the acceptable range

  3. All responses end up with 0 scores

  4. First response is automatically selected regardless of quality

Scenario 2 - Tied Scores:

  1. Generator A submits response (index 0) with high quality

  2. Generator B submits response (index 1) with equal quality

  3. Both receive same validation scores

  4. Generator A's response is always selected due to lower index

Recommendation

Implement a fair selection mechanism that for tied scores, use a random selection mechanism.

Updates

Lead Judging Commences

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

Return value of `getBestResponse` when no validators

wrong implementation of "getBestResponse" when there are more than 1 responses with highestScore

Support

FAQs

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