The PuppyRaffle::withdrawFees function requires that the sum of fees collected must precisely match the current balance of the contract.
This assumption is grounded in the expectation that, after the prize pool is paid out, the sole remaining balance in the contract should consist exclusively of collected fees.
This would be true if entranceFee would be the only way of depositing funds into the contract.
If the attacker increases the contract balance through other means remaining balance will not match collected fees and PuppyRaffle::withdrawFees function call will fail.
Attacker contract AttackerForceFeed.sol:
The PoC test:
This kind of attack could prevent the owner from collecting any fees.
Foundry
Do not rely on the contract balance to check if there are any active players in the current raffle.
One could check the PuppyRaffle::players array to see if there are any active players before executing the fee withdrawal transaction
Since fees are allocated after the raffle ends than fee withdrawal should not impact active raffles given that they are calculated correctly.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.