DeFiHardhatFoundry
250,000 USDC
View results
Submission Details
Severity: medium
Valid

EIP712 inconsistency in tractor blueprint

Summary

The _domainSeparatorV4 computation in LibTractor is wrong because it uses the BLUEPRINT_TYPE_HASH instead of EIP712_TYPE_HASH

Relevant GitHub Links:

https://github.com/Cyfrin/2024-05-beanstalk-the-finale/blob/main/protocol/contracts/libraries/LibTractor.sol#L177

Vulnerability Details

EIP712 states that to follow this proposal, it must implement the following structure to sign messages:
keccak256("\x19\x01" ‖ domainSeparator ‖ hashStruct(message)) where domainSeparator = hashStruct(eip712Domain). This eip721Domain should implement all or some of these parameters in order to prevent replaying attacks: string name, string version, uint256 chainId, address verifyingContract and bytes32 salt. In this case, we see that Beanstalk decided to use all of these parameters apart from the salt as we can see here. The typehash is computed correctly but when computing the domainSeparator we can see that a wrong typehash is used instead of using the EIP712_TYPE_HASH.

/**
* @notice Returns the domain separator for the current chain.
*/
function _domainSeparatorV4() internal view returns (bytes32) {
return
keccak256(
abi.encode(
BLUEPRINT_TYPE_HASH, // @audit-issue wrong typehash used, it should be EIP712_TYPE_HASH
TRACTOR_HASHED_NAME,
TRACTOR_HASHED_VERSION,
C.getChainId(),
address(this)
)
);
}

Impact

Medium
Implementing the domainSeparator in a wrong manner will make other integrators of the protocol to sign data that will not match with the contract implementation.

Tools Used

Manual review

Recommendations

/**
* @notice Returns the domain separator for the current chain.
*/
function _domainSeparatorV4() internal view returns (bytes32) {
return
keccak256(
abi.encode(
- BLUEPRINT_TYPE_HASH,
+ EIP712_TYPE_HASH
TRACTOR_HASHED_NAME,
TRACTOR_HASHED_VERSION,
C.getChainId(),
address(this)
)
);
}
Updates

Lead Judging Commences

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

Tractor not compliant to EIP712 requirement because it's using the type hash of the blueprint, not the EIP712Domain

Support

FAQs

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