Dria

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

Incorrect Proof-of-Work Difficulty Check in `assertValidNonce` Function

Summary

The assertValidNonce function in the LLMOracleCoordinator contract incorrectly implements the Proof-of-Work (PoW) difficulty check, allowing invalid nonces to be accepted as valid. This discrepancy could compromise the integrity of the PoW system, leading to unintended acceptance of low-effort computations.

Vulnerability Detail

The assertValidNonce function is designed to validate a candidate nonce for a task by calculating a hash and comparing it to a difficulty threshold. The intended logic, as specified in the LLMOracleTask interface, is that the computed hash should be less than the difficulty target (SHA3(taskId, input, requester, responder, nonce) < difficulty).

However, in the current implementation:

if (uint256(keccak256(message)) > type(uint256).max >> uint256(task.parameters.difficulty)) {
revert InvalidNonce(taskId, nonce);
}

The conditional check is > rather than >=, meaning that nonces resulting in hash values equal to the difficulty target are not validated as per the intended threshold.

This oversight means that some valid PoW nonces are unnecessarily rejected, potentially causing legitimate computations to be discarded. It also creates an inconsistency in how PoW difficulty is enforced, which could be exploited if the system incorrectly interprets validation boundaries.

Impact

By incorrectly rejecting nonces that meet but do not exceed the difficulty threshold, this flaw could result in:

  • Rejection of valid tasks and associated computational results, leading to wasted resources.

  • Potential exploitation, as misinterpreted thresholds might create loopholes for attackers to bypass the difficulty restriction.

Tools Used

Manual Code Review

Recommendations

To align with the intended behavior, update the conditional statement to use >= in order to correctly enforce the difficulty boundary

Updates

Lead Judging Commences

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

Incorrect Proof-of-Work Difficulty Check in `assertValidNonce` Function

Support

FAQs

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