sherlock-audit / 2024-08-winnables-raffles-judging

6 stars 2 forks source link

Creamy Scarlet Cottonmouth - "uint64 chainSelector" may affect "function _packCCIPContract" in contract "BaseCCIPContract" and the like. #644

Closed sherlock-admin4 closed 3 months ago

sherlock-admin4 commented 3 months ago

Creamy Scarlet Cottonmouth

Low/Info

"uint64 chainSelector" may affect "function _packCCIPContract" in contract "BaseCCIPContract" and the like.

Summary

Unintended return value on chainSelector

chainSelector has a uint value of 64 and has been left-shifted by 160 before being type casted to uint256. This may return the value of zero for this part of the code.

Root Cause

In BaseCCIPContract.sol[line43]:

Internal pre-conditions

No response

External pre-conditions

No response

Attack Path

No response

Impact

When function "_packCCIPContract" this is what happens:

PoC

No response

Mitigation

The mitigation to this is the following:

- uint256(uint160(contractAddress)) | uint256(chainSelector << 160)
+ uint256(uint160(contractAddress)) | uint256(chainSelector) << 160
sherlock-admin2 commented 2 months ago

The protocol team fixed this issue in the following PRs/commits: https://github.com/Winnables/public-contracts/pull/7