Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: high
Valid

Unsafe casting of the 'totalFees' from 'uint256' to 'uint64'.

Summary

The value of the totalFees goes through unsafe casting from 'uint256' to 'uint64'.

Vulnerability Details

In the selectWinner() function, 'fee' is unsafely casted from 'uint256' to 'uint64'. This makes it possible for the amount to be recorded to be lower than the actual amount expected.

uint256 fee = (totalAmountCollected * 20) / 100;
totalFees = totalFees + uint64(fee);

For example.

If the value of fee is larger than 2 ** 64 - 1 then the unsafe cast will only keep the rightmost bits, which in turn will result in a value much smaller than defined in uint256 fee.

Impact

Loss of funds for the totalFees.

Tools Used

Manual Review.

Recommendations

Updates

Lead Judging Commences

Hamiltonite Lead Judge about 2 years ago
Submission Judgement Published
Validated
Assigned finding tags:

unsafe cast of fee to uint64

Support

FAQs

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

Give us feedback!