Dria

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

Validator Score Manipulation Enables Response Selection Control

Relevant Context

The LLM Oracle protocol uses a validation system where multiple validators score generated responses. The final selection of the best response depends on these validation scores. The scoring mechanism uses statistical methods (mean and standard deviation) to determine valid scores and calculate final response scores.

Finding Description

In the validate() function of LLMOracleCoordinator, a malicious validator can manipulate the validation process by submitting an extremely high score. The validation scoring system uses a statistical approach where scores within one standard deviation of the mean are considered valid:

if ((score >= _mean - _stddev) && (score <= _mean + _stddev)) {
innerSum += score;
innerCount++;
_increaseAllowance(validations[taskId][v_i].validator, task.validatorFee);
}

By submitting an extremely high score, an attacker can:

  1. Artificially inflate the standard deviation

  2. Make their manipulated scores fall within the accepted range

  3. Significantly influence the final score of their preferred response

@> uint256 inner_score = innerCount == 0 ? 0 : innerSum / innerCount;
responses[taskId][g_i].score = inner_score;

This is particularly effective when front-running the last validation submission, as the attacker can observe all previous scores and calculate exactly how high their score needs to be to achieve their desired outcome.

Impact Explanation

High. This vulnerability allows complete control over which response gets selected as the best one, effectively breaking the core functionality of the oracle system. This can be exploited to:

  • Force selection of malicious or low-quality responses

  • Manipulate the outcome of any dependent protocols

  • Unfairly distribute rewards to specific generators

Likelihood Explanation

High. The attack:

  • Requires only one validator account

  • Can be executed reliably through front-running to manipulate any task the malicious actor wish

  • Has no significant economic costs

  • Can be automated

Proof of Concept

  1. Attacker observes a task with N-1 completed validations

  2. Attacker calculates current scores: [1e17, 1e16, 2e15] (example)

  3. Attacker front-runs the last validator with their malicious validation

  4. Attacker submits scores like [0, 0, 1e200]

  5. The high score causes a large standard deviation, making all scores "valid"

  6. The response associated with an incredibly high score, and thus selected as the best response in getBestResponse()

Recommendation

Implement strict bounds on validation scores and use more robust statistical methods:

function validate(uint256 taskId, uint256 nonce, uint256[] calldata scores, bytes calldata metadata) public {
// ... existing checks ...
// Add maximum score limit
uint256 constant MAX_SCORE = 1e18;
for (uint256 i = 0; i < scores.length; i++) {
if (scores[i] > MAX_SCORE) {
revert ScoreExceedsMaximum(scores[i], MAX_SCORE);
}
}
}

Additionally, consider implementing a commit-reveal scheme for score submission to prevent front-running attacks.

Updates

Lead Judging Commences

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

Unbounded score values in `validate` function

Support

FAQs

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