The LLMOracleCoordinator::respond function does not validate the contents of the output parameter, allowing registered generators to submit empty responses. This lack of validation can result in incomplete or unusable outputs stored in the TaskResponse array of structs. If numValidations is set to 0, meaning no validation phase occurs, the response generator receives the generatorFee without any content checks, leading to potential exploitation of the fee system.
In the respond function, generators submit responses containing output data. However, there is no mechanism to ensure that the output is not empty, even though natspec requires it: @dev output must not be empty. As such, it is possible for a registered generator to submit broken or empty outputs.
The lack of output validation is further compounded when task.parameters.numValidations is set to 0, meaning no validation phase occurs. Under this condition:
There are no checks to ensure that the output is non-empty or meets minimal quality criteria.
When task.parameters.numValidations == 0, the task’s status is set to Completed immediately, bypassing the validation phase. This results in direct rewards for generators without any verification of the output’s quality or relevance.
If the generatorFee is substantial, this design could be exploited by malicious actors who submit arbitrary or empty outputs to repeatedly collect fees without providing meaningful contributions. While the assertValidNonce function’s Proof-of-Work mechanism requires computational effort from oracles, it does not ensure that the content is correct or complete, leaving some potential for abuse by dishonest oracles.
On the other hand, if numValidations > 0, only those respondents whose answers achieve an "above-average" score will receive a fee, see [https://github.com/Cyfrin/2024-10-swan-dria/blob/main/contracts/llm/LLMOracleCoordinator.sol#L368-L369].
Here is a valid test case that serves as a proof of concept, please paste it into the LLMOracleCoordinator.test.ts file:
The test can be run with yarn test ./test/LLMOracleCoordinator.test.ts.
Here are the logs:
As shown in the error logs, both oracle responses contain an empty output with a score of 0, which is expected since no validation was required in this case. Both generators successfully received their respective fees for responding. Note that in this scenario, the protocol accepts empty outputs as valid responses.
Without required response validations, generators can earn fees for responses that may be empty or irrelevant. This can lead to potential fee drift and higher costs for users without providing meaningful value in return.
Manual Code Review, Hardhat
In LLMOracleCoordinator::respond, consider implementing checks to at least ensure that the output field is not empty and meets minimum length criteria.
If possible, introduce a minimum validation requirement in LLMOracleManager.sol, such as task.parameters.numValidations == 1, to ensure that tasks undergo some scrutiny before reaching the Completed status, and before any generator fees are distributed.
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.