An attacker can slightly change the eth balance of the contract to break the withdrawFees
function.
The withdraw function contains the following check:
Using address(this).balance
in this way invites attackers to modify said balance in order to make this check fail. This can be easily done as follows:
Add this contract above PuppyRaffleTest
:
Modify setUp
as follows:
Now run testWithdrawFees()
- forge test --mt testWithdrawFees
to get:
Any small amount sent over by a self destructing contract will make withdrawFees
function unusable, leaving no other way of taking the fees out of the contract.
All fees that weren't withdrawn and all future fees are stuck in the contract.
Manual review
Avoid using address(this).balance
in this way as it can easily be changed by an attacker. Properly track the totalFees
and withdraw it.
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.