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

Re-entrancy inside 'refund' function

Summary

The 'refund' function is susceptible to a re-entrancy attack..

Vulnerability Details

Inside the 'refund' function the state change happens after the funds have been withdrawn which makes the function vulnerable to a re-entrancy attack.
The function refunds the entrance fee before it changes the state.
This makes it possible for malicious actors to exploit this function using a simple attack contract.

Impact

A critical impact due to the nature of this attack.
It is possible to drain the whole entrance fee pool with a few lines of code.

Tools Used

Vs Code
Foundry

Recommendations

Always follow the 'Checks-Effects-Interactions pattern'.
This helps to prevent attacks like this as a basic precaution.
Nowadays we can also simply use the openzeppelin reentrancyguard to prevent these kind of attacks.

Updates

Lead Judging Commences

Hamiltonite Lead Judge almost 2 years 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.