Sparkn

CodeFox Inc.
DeFiFoundryProxy
15,000 USDC
View results
Submission Details
Severity: low

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 getProxyAddress(bytes32 salt, address implementation) public view returns (address proxy) {
bytes memory code = abi.encodePacked(type(Proxy).creationCode, uint256(uint160(implementation)));
bytes32 hash = keccak256(abi.encodePacked(bytes1(0xff), address(this), salt, keccak256(code)));
proxy = address(uint160(uint256(hash)));
}

Impact

To prevent any hash collisions.source

Tools Used

Manual Review

Recommendations

Use abi.encode instead, which will pad items to 32 bytes

Support

FAQs

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