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

Overflow

Summary

totalFees is uint64 which may overflow; there is uses of unsafe casting too

Vulnerability Details

Largest value uint64 solidity is 18446744073709551615 which is about 18.44 ether. Its possible for a raffle to be big ticket and have totals up to 2000 ETH such that fee can be > 19 ETH this implies uint64(fee) will overflow and lead to 0.
Additionally the total fees for a raffle with large entries can easily accumulate over 19 ETH leading to overflow totalFees

Impact

This unsafe casting and overflow prone logic may lead to fees not being accumulated into the protocol as they reset to 0 and or totalFees also overflowing and going to 0 resulting in wrong accounting and loss of value and faulty payouts

Tools Used

Manual Analysis

Recommendations

Ensure totalFees and fees are uint256

uint256 public totalFees = 0; //line 30 change from uint64
uint256 fee = (totalAmountCollected * 20) / 100;
totalFees = totalFees + fee; //line 134 (remove unsafe downcast from uint256 to unit64)

Other alternative is to use SafeCasting Libraries like OpenZeppeli

Updates

Lead Judging Commences

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

unsafe cast of fee to uint64

overflow-uint64

Support

FAQs

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

Give us feedback!