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

refund function is vulnerable to reentrency attack

Summary

Refund function is vulnerable to reentrency attack.

Vulnerability Details

If the user is a smart contract, it can call refund function and have a fallback function which will be run when receive the ether, and call again refund until all the funds are drained.

Impact

All the funds can be drained.

Tools Used

Solidity.

Recommendations

Either move the line "players[playerIndex] = address(0);" BEFORE "payable(msg.sender).sendValue(entranceFee);"
Or use a lock like "nonReentrant" from OpenZeppelin ReentrancyGuard.

Updates

Lead Judging Commences

patrickalphac Lead Judge
over 1 year ago
Hamiltonite Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

reentrancy-in-refund

reentrancy in refund() function

Support

FAQs

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