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

selectWinner() - unsafe casting of `fee` from `uint256` down to `uint64`.

Summary

selectWinner() - unsafe casting of fee from uint256 down to uint64.

Vulnerability Details

If the fee is a value larger than type uint64 max, the casting will cause overflow and result in no fees being added.
Also, if the fee is smaller than uint64 max but large enough so that totalFees + uint64(fee) > type(uint64).max, it will also overflow and result in zero total fees.

Low severity because it's highly unlikely to ever reach a fee value anywhere close enough.

totalFees = totalFees + uint64(fee);

Impact

Zero fees will be recorded if the near impossible happens.
address(this).balance and totalFees will be perpetually out of sync.

Tools Used

VSC.

Recommendations

if (fee < type(uint64).max) {
totalFees = totalFees + uint64(fee);
} else {
// Handle the case where the fee is too large to fit in a uint64
}
Updates

Lead Judging Commences

Hamiltonite Lead Judge over 1 year 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.