code-423n4 / 2023-11-panoptic-findings

0 stars 0 forks source link

Re: Hash Collision #599

Closed c4-bot-5 closed 9 months ago

c4-bot-5 commented 9 months ago

Lines of code

https://github.com/code-423n4/2023-11-panoptic/blob/main/contracts/libraries/PanopticMath.sol#L38

Vulnerability details

Impact

The method generates a pool ID from hashing parameters without collision checks.

Proof of Concept

Provide direct links to all referenced code in GitHub. Add screenshots, logs, or any other relevant proof that illustrates the concept.

Tools Used

Recommended Mitigation Steps

This modified version alters the method of concatenation and hash derivation, potentially reducing the risk of hash collisions

function getFinalPoolId( uint64 basePoolId, address token0, address token1, uint24 fee ) internal pure returns (uint64) { bytes memory poolIdData = abi.encodePacked(token0, token1, fee); bytes32 hash = keccak256(poolIdData); uint64 finalPoolId = basePoolId + (uint64(hash) >> 32); return finalPoolId; }

Assessed type

Other

c4-judge commented 9 months ago

Picodes marked the issue as unsatisfactory: Invalid