Dria

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

The numGenerations constraint prevents Oracle from being manipulated or getting a good quality response.

Summary

The LLMOracleCoordinator's respond and validate functions are limited by numGenerations and numValidations parameters that incentivizes speed over quality in AI responses. This design encourages generators to prioritize quick responses over better-quality outputs.

Also with “temporal staking” vulnerability attacker can manipulate oracle response.

Vulnerability Details

function finalizeValidation(uint256 taskId) private {
TaskRequest storage task = requests[taskId];
// compute score for each generation
>> for (uint256 g_i = 0; g_i < task.parameters.numGenerations; g_i++) { // @audit only treat first "numGenerations" response.
// get the scores for this generation, i.e. the g_i-th element of each validation
uint256[] memory scores = new uint256[]();
>> for (uint256 v_i = 0; v_i < task.parameters.numValidations; v_i++) { // @audit only treat first "numValidations" response.
scores[v_i] = validations[taskId][v_i].scores[g_i];
}
...
}
...
}
-------
function respond(uint256 taskId, uint256 nonce, bytes calldata output, bytes calldata metadata)
public
onlyRegistered(LLMOracleKind.Generator)
onlyAtStatus(taskId, TaskStatus.PendingGeneration)
{
TaskRequest storage task = requests[taskId];
...
// check nonce (proof-of-work)
>> assertValidNonce(taskId, task, nonce); // check nonce
// push response
TaskResponse memory response =
TaskResponse({responder: msg.sender, nonce: nonce, output: output, metadata: metadata, score: 0});
>> responses[taskId].push(response); // add to response array
...
}

respond stores all response values in the responses array, but finalizeValidation only considers as valid the first numGenerations of responses that came in. validate is also the same.

The response process involves two steps:

  1. Calculate proof-of-work nonce

  2. Generate AI response

While nonce calculation time might be similar across generators, AI response generation time varies significantly. Modern models like gpt-o1 take longer but produce better results. However, the current system only processes the first N responses, creating a "fastest wins" scenario.

Impact

This can be linked to “temporal staking” vulnerability to attack the protocol.

The current implementation allows anyone to become a generator or validator at no cost, allowing them to manipulate the oracle by obtaining nonces for multiple accounts in parallel and then performing malicious responses and validations in a single block.

Tools Used

None

Recommendations

Rather than managing with numGenerations, numValidations, it is recommended to use the request parameter to set how long you want to treat responses as valid, so that all responses that come in within a certain time are treated as valid. (However, in this case, you will need to change how you manage responses to prepare for DoS).

Updates

Lead Judging Commences

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

There is no oracle whitelisting

Support

FAQs

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