DittoETH

Ditto
DeFiFoundryOracle
55,000 USDC
View results
Submission Details
Severity: low
Invalid

`abi.encodePacked()` should not be used with dynamic types when passing the result to a hash function such as `keccak256()`

Summary

abi.encodePacked() should not be used with dynamic types when passing the result to a hash function such as keccak256()

Vulnerability Details

Use abi.encode() instead which will pad items to 32 bytes, which will prevent hash collisions (e.g. abi.encodePacked(0x123,0x456) => 0x123456 => abi.encodePacked(0x1,0x23456), but abi.encode(0x123,0x456) => 0x0...1230...456). "Unless there is a compelling reason, abi.encode should be preferred". If there is only one argument to abi.encodePacked() it can often be cast to bytes() or bytes32() instead.

File: contracts/bridges/BridgeReth.sol
25: RETH_TYPEHASH = keccak256(abi.encodePacked("contract.address", "rocketTokenRETH"));
27: keccak256(abi.encodePacked("contract.address", "rocketDepositPool"));

Impact

hash collisions

Tools Used

Manual

Recommendations

As all arguments are strings and or bytes, bytes.concat() should be used instead

Updates

Lead Judging Commences

0xnevi Lead Judge
over 1 year ago
0xnevi Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Other

Support

FAQs

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