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

Tractor actioin signature can be replayed

Line of code

https://github.com/Cyfrin/2024-05-beanstalk-the-finale/blob/df2dd129a878d16d4adc75049179ac0029d9a96b/protocol/contracts/beanstalk/farm/TractorFacet.sol#L33C44-L33C61

Summary

Tractor actioin signature can be replayed

Vulnerability Details

The tractor facet handles tractor and blueprint operations. It utilizes blueprint in order to execute on behalf of the publisher. The problem is that the blueprintHash does not include the nonce and therefore it allows the signature to be replayed.
the function verifyRequisition has a call to getBlueprintHash as shown below.

bytes32 blueprintHash = LibTractor._getBlueprintHash(requisition.blueprint);

this calls this

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
)
)
);
}

when the blueprint is exceuted, the nonce is incremented but beecause the signature schema does not use the nonce to compose signature and use the max nonce to compose signature, the same signature can be replayed a lot of times.

Impact

The same signature can be replayed multiple times allow users to execute the blueprint action multiple times,

for example, the user (original publisher) sign a blueprint to transfer token

function transferToken(
IERC20 token,
address recipient,
uint256 amount,
LibTransfer.From fromMode,
LibTransfer.To toMode
) external payable fundsSafu noSupplyChange oneOutFlow(address(token)) { // @audit no payable?
LibTransfer.transferToken(token, LibTractor._user(), recipient, amount, fromMode, toMode);
}

the code transfer token from LibTractor._user() to recipient address,

if this blueprint is executed multiple times and the LibTractor._user() has unlimited allowance, the fund in the publisher are drained.

Tools Used

Manual review

Recommendations

Use the nonce to compose the signature to ensure the signature is not replayable.

Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Appeal created

asefewwexa Submitter
about 1 year ago
inallhonesty Lead Judge
about 1 year ago
inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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