DeFiHardhatFoundry
250,000 USDC
View results
Submission Details
Severity: low
Invalid

`TractorFacet.cancelBlueprint()` completely removes ability to execute defined set of actions in future

Summary

Blueprint is cancelled by setting type(uint256).max nonce so it can't be incremented during execution.
Problem is that blueprintHash value depends on publisher and defined set of actions.

Example of using Tractor acctoding to specification:

A Farmer creates a Blueprint for an Operator to Plant on their behalf anytime they have more than 100 Plantable Seeds and will pay the caller 1 Earned Bean.

Suppose a scenario:

  1. User wants to allow operators to Plant and signs blueprint

  2. For some reason he calls cancelBlueprint(). He could changed his mind or different reason, doesn't matter

  3. Now he realizes it was right decision to allow operators to Plant. However that Blueprint has already been cancelled.

As a result he can't use blueprint with exact same parameters because it was cancelled forever. And this behaviour is not documented.

Vulnerability Details

Blueprint hash depends on blueprint parameters:

function _getBlueprintHash(Blueprint calldata blueprint) internal view returns (bytes32) {
return
_hashTypedDataV4(
keccak256(
abi.encode(
BLUEPRINT_TYPE_HASH,
blueprint.publisher,
keccak256(blueprint.data),
keccak256(abi.encodePacked(blueprint.operatorPasteInstrs)),
blueprint.maxNonce,
blueprint.startTime,
blueprint.endTime
)
)
);
}

Blueprint is cancelled by setting maxNonce so it can't be incremented during execution:

function _cancelBlueprint(bytes32 blueprintHash) internal {
_tractorStorage().blueprintNonce[blueprintHash] = type(uint256).max;
}

Impact

Cancelled Blueprint is cancelled forever. And blueprintHash depends solely on blueprint parameters and publisher, i.e. defined set of actions. Moreover this behaviour is not documented which can result in users cancelling blueprint which they want to use in he future.

Tools Used

Manual review

Recommendations

Add salt to Blueprint struct to make hashes unique even for the same publisher and set of actions.

Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational/Gas

Invalid as per docs https://docs.codehawks.com/hawks-auditors/how-to-determine-a-finding-validity

Cancelled Blueprint is cancelled forever due to nonce being set to max.

Support

FAQs

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