The 'refund' function is susceptible to a re-entrancy attack..
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.
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.
Vs Code
Foundry
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.
reentrancy in refund() function
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.