The refund() function sends the entranceFee back to the user using sendValue which handing over the control to the user contract which triggers the receive function and from which the user can able to execute selectWinner() function which is an external function having no access controls implemented in it.
The selectWinner() function which is an external function has no access control implemented in it can leads to anyone can call selectWinner().
Since anyone can call the selectWinner() function any user can have an advantage of becoming the winner by calling the selectWinner() after the time interval which brings the flaw to the entire system. The code to re-enter the contract as follows,
Remix
The external functions which carries sensitive actions like changing the state of the contract needs to have access control in place and only the owner of the contract needs to have access to call such functions.
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.