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

L2ContractMigrationFacet.sol uses incorrect chainId in EIP712 signature

Summary

L2ContractMigrationFacet.sol implements EIP712. For some reason it requires signature to be signed with chainId = 1 (Mainnet). However protocol is migrated to L2 so it should use chainId of current chain instead.

Vulnerability Details

Here you can see it uses legacyChainId when calculates domain separator:
https://github.com/Cyfrin/2024-05-beanstalk-the-finale/blob/df2dd129a878d16d4adc75049179ac0029d9a96b/protocol/contracts/beanstalk/silo/L2ContractMigrationFacet.sol#L237

function _domainSeparatorV4() internal view returns (bytes32) {
return
keccak256(
abi.encode(
EIP712_TYPE_HASH,
MIGRATION_HASHED_NAME,
MIGRATION_HASHED_VERSION,
C.getLegacyChainId(),
address(this)
)
);
}

Impact

L2ContractMigrationFacet.sol doesn't conform to EIP712.

Tools Used

Manual Review

Recommendations

Use current chainId:

function _domainSeparatorV4() internal view returns (bytes32) {
return
keccak256(
abi.encode(
EIP712_TYPE_HASH,
MIGRATION_HASHED_NAME,
MIGRATION_HASHED_VERSION,
- C.getLegacyChainId(),
+ block.chainId,
address(this)
)
);
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 11 months ago
Submission Judgement Published
Invalidated
Reason: Known issue
Assigned finding tags:

Replay attack in case of hard fork - Hardcoded chainId 712

Appeal created

T1MOH Submitter
11 months ago
inallhonesty Lead Judge
11 months ago
inallhonesty Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Known issue
Assigned finding tags:

Replay attack in case of hard fork - Hardcoded chainId 712

Support

FAQs

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