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

Not Handling revert conditions refunding ether

Summary

The refund() function is not handling the revert case when sending ether to the msg.sender using sendValue which when reverts

Vulnerability Details

function refund(uint256 playerIndex) public {
payable(msg.sender).sendValue(entranceFee);

In this line of code, the refund function is sending the ether to the msg.sender which might be a contract when reverts doesn't execute the contract further.

Impact

When handing over the control to the msg.sender, the contract is not handling the revert case which stops the execution of the contrat when reverted.

Tools Used

vscode

Recommendations

Use call to send ether to other contracts which is the recommended way of sending ether to other contracts as follows,

- payable(msg.sender).sendValue(entranceFee)
+ error PuppyRaffle__TransferNotSuccess();// add under errors section
+ (bool success, ) = payable(msg.sender).call{value: entranceFee}("");
+ if(!success){ revert PuppyRaffle__TransferNotSuccess(); };
Updates

Lead Judging Commences

hexbyte Lead Judge about 2 years ago
Submission Judgement Published
Invalidated
Reason: Other

Support

FAQs

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

Give us feedback!