If you use keccak256(abi.encodePacked(a, b)) and both a and b are dynamic types, it is easy to craft collisions in the hash value by moving parts of a into b and vice-versa. More specifically, abi.encodePacked("a", "bc") == abi.encodePacked("ab", "c").
If you use abi.encodePacked for signatures, authentication or data integrity, make sure to always use the same types and check that at most one of them is dynamic. Unless there is a compelling reason, abi.encode should be preferred.
Compared to abi.encodePacked(), abi.encode() pads all items to 32 bytes, which helps to prevent hash collisions. Additionally, if there is only one argument to abi.encodePacked(), it can be cast to bytes() or bytes32() instead.
Low Report
abi.encodePacked()
should not be used with dynamic types when passing the result to a hash function such askeccak256()
receive()
/fallback()
functionTotal: 9 instances over 3 issues
abi.encodePacked()
should not be used with dynamic types when passing the result to a hash function such askeccak256()
As seen from the Solidity Docs:
Compared to
abi.encodePacked()
,abi.encode()
pads all items to 32 bytes, which helps to prevent hash collisions. Additionally, if there is only one argument toabi.encodePacked()
, it can be cast tobytes()
orbytes32()
instead.There are 6 instances of this issue:
Unused/empty
receive()
/fallback()
functionIf the intention is for the Ether to be used, the function should call another function, otherwise it should revert.
There is 1 instance of this issue:
Consider addings checks for signature malleability
Use OpenZeppelin's
ECDSA
contract, which checks for signature malleability, rather than callingecrecover()
directly.There are 2 instances of this issue:
Non-Critical Report
override
function argumentsconstants
should be defined rather than using magic numbersevent
is missingindexed
fieldsTotal: 29 instances over 3 issues
Unused
override
function argumentsFor functions declared as
override
, unused arguments should have the variable name removed or commented out to avoid compiler warnings.There is 1 instance of this issue:
constants
should be defined rather than using magic numbersEven assembly code can benefit from using readable constants instead of hex/numeric literals.
There are 18 instances of this issue:
96
:96
:0xff
:0xff
:0xff
:0xff
:10_000
:10_000
:2 weeks
:16
:16
:20
:16
:0x01ffc9a7
:0x80ac58cd
:0x5b5e139f
:96
:5 minutes
:event
is missingindexed
fieldsEach
event
should use threeindexed
fields if there are three or more fields.There are 10 instances of this issue: