NFTBridge
60,000 USDC
View results
Submission Details
Severity: low
Invalid

Use of `abi.encodePacked` with dynamic types inside `keccak256`

Vulnerability Details

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

function requestHash(
uint256 salt,
address collection,
snaddress toL2Address,
uint256[] memory tokenIds
)
internal
pure
returns (uint256)
{
bytes32 hash = keccak256(
abi.encodePacked(
salt,
// Cairo uses felts, which are converted into u256 to compute keccak.
// As we use abi.encodePacked, we want the address to also be 32 bytes long.
uint256(uint160(collection)),
snaddress.unwrap(toL2Address),
tokenIds
)
);
return uint256(hash);
}

Impact

use of abi.encodePacked could lead to hash collisions

Recommendations

Use abi.encode() instead which will pad items to 32 bytes, which will prevent hash collisions

Updates

Lead Judging Commences

n0kto Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Known issue
Assigned finding tags:

invalid-encodePacked-collision-known-issue

Known issue: lightchaser

Support

FAQs

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