PuppyRaffle::totalFees loses fees0.8.0, integers were subject to integer overflows.PuppyRaffle::selectWinner, totalFees are accumulated for the feeAddress to collect later in withdrawFees. However, if the totalFees variable overflows, the feeAddress may not collect the correct amount of fees, leaving fees permanently stuck in the contract.We first conclude a raffle of 4 players to collect some fees.
We then have 89 additional players enter a new raffle, and we conclude that raffle as well.
totalFees will be:
You will now not be able to withdraw, due to this line in PuppyRaffle::withdrawFees:
Although you could use selfdestruct to send ETH to this contract in order for the values to match and withdraw the fees, this is clearly not what the protocol is intended to do.
Place this into the PuppyRaffleTest.t.sol file.
There are a few recommended mitigations here.
Use a newer version of Solidity that does not allow integer overflows by default.
Alternatively, if you want to use an older version of Solidity, you can use a library like OpenZeppelin's SafeMath to prevent integer overflows.
Use a uint256 instead of a uint64 for totalFees.
Remove the balance check in PuppyRaffle::withdrawFees
We additionally want to bring your attention to another attack vector as a result of this line in a future finding.
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.