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

WithdrawFees functionality depends on the balance of the contract

Summary

The PuppyRaffle::withdrawFees function uses the contract's balance as a counter which is highly unreliable and can lead to unexpected behavior.

Vulnerability Details

A contract's balance is dynamic and can receive Ether through various ways, including payable functions, mining rewards, destroyed contracts, and precalculated addresses.

Impact

The functionality of the PuppyRaffle::withdrawFees function can be frustated by external actors.

Tools Used

Foundry

Recommendations

I recommend to do not create external dependencies, moreover with the contract's balance.

You can also add access control to this function, but depending on what you want, you may prefer it without it.

function withdrawFees() external {
- require(address(this).balance == uint256(totalFees), "PuppyRaffle: There are currently players active!");
uint256 feesToWithdraw = totalFees;
totalFees = 0;
(bool success,) = feeAddress.call{value: feesToWithdraw}("");
require(success, "PuppyRaffle: Failed to withdraw fees");
}
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!