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

Incorrect tractor signature schema, should use EIP712_TYPE_HASH when composing the signature

Line of code

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

Summary

tractor signature is not eip 712 compliant

Vulnerability Details

bytes32 private constant EIP712_TYPE_HASH =
keccak256(
"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
);

This EIP712_TYPE_HASH is not in the signature schema, then the signature is not EIP 712 complicant,

https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md

if we take a look at this line of code

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

function _domainSeparatorV4() internal view returns (bytes32) {
return
keccak256(
abi.encode(
BLUEPRINT_TYPE_HASH,
TRACTOR_HASHED_NAME,
TRACTOR_HASHED_VERSION,
C.getChainId(),
address(this)
)
);
}

the BLUEPRINT_TYPE_HASH is used instead of the EIP712_TYPE_HASH

Impact

the signature will not comply with the EIP 712 and the generation is generated incorrectly.

Tools Used

Manual review

Recommendations

EIP712_TYPE_HASH must be in the signature schema to ensure the protocol is eip compliant

here is a reference implementation from openzeppelin

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/05f218fb6617932e56bf5388c3b389c3028a7b73/contracts/utils/cryptography/EIP712.sol#L89

the type hash is

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/05f218fb6617932e56bf5388c3b389c3028a7b73/contracts/utils/cryptography/EIP712.sol#L37

bytes32 private constant TYPE_HASH =
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year 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.