PuppyRaffle::selectWinner involve calculating 20% from the total participant fees as fees treasury, the rest (80%) will be sent to the winner.
i notice that the fee is cast to uint64. the max value of uint64 is 18,446,744,073,709,551,615 (~18 ETH). if the participant is large enough that the fee exceeding the max value of uint64, it will result in overflow, and silently truncates the value back to 0 and start counting, causes the fee treasury to receive less than it should.
Likelihood: High/Medium
when the total participants are high enough that the 20% of the total deposited exceeding the max value of uint64, overflow occurs
Impact: High/Medium
when overflow occurs, total fees will gets truncated to 0, and start counting from here, causing the fee treasury to receive less fees than it should
assuming the participant fee is 1 ETH. a total of at least 93 participants are required to trigger this bug
create a new test file, paste the above PoC into the newly created test file, and run it.
below is the output result from the test:
the output log has stated a total of ~0.15 ETH has been collected. however, the entrance fee per one participant is 1 ETH!! lets see the actual amount that the fee treasury should receive using the python terminal as shown below:
the actual total fees the treasury should receive is ~18.6 ETH, while the current cast has cause the total fees to be reduced to ~0.15 ETH !!
avoid casting to small data while calculating fees
The contest is live. Earn rewards by submitting a finding.
Submissions are being reviewed by our AI judge. Results will be available in a few minutes.
View all submissionsThe contest is complete and the rewards are being distributed.