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

Downcasting error

Summary

Downcasting error makes impossible to withdraw fees.

Vulnerability Details

PoC:

uint constant NUMBER_OF_PLAYERS = 100;
modifier playersEnteredMore() {
address[] memory players = new address[](NUMBER_OF_PLAYERS);
for (uint i = 0; i < NUMBER_OF_PLAYERS; i++) {
players[i] = address(i + 1);
}
puppyRaffle.enterRaffle{value: entranceFee * NUMBER_OF_PLAYERS}(players);
_;
}
function testWithdrawFeesDOS() public playersEnteredMore {
vm.warp(block.timestamp + duration + 1);
vm.roll(block.number + 1);
uint256 expectedPrizeAmount = ((entranceFee * NUMBER_OF_PLAYERS) * 20) / 100;
puppyRaffle.selectWinner();
console.log("puppyRaffle balance = %uint", uint64(address(puppyRaffle).balance));
console.log("puppyRaffle totalFees = %uint", puppyRaffle.totalFees());
puppyRaffle.withdrawFees();
assertEq(address(feeAddress).balance, expectedPrizeAmount);
}

Impact

Impossible to withdraw fees.

Tools Used

Foundry

Recommendations

Make totalFees uint256 value.

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.