refund() function does not follow Check-Effects-Interactions pattern (CEI). This can lead to a draining of funds.
Here is the scenario:
An attacker can use a smart contract address to enter the raffle then withdraw their funds.
When they receive the ETH this can then trigger a fallback function that calls 'refund()' again to withdraw more funds
At this point the setting of their entry in the players[] array to address(0)has not happened yet. This means the contract still thinks the player is in the game
Step 2 can be repeated until the balance of the contract is less than 'entranceFee'
High - this is an easy vector for an attacker to spot and exploit in order to drain ALL or MOST of the contract's ETH balance
Manual Inspection
Follow the CEI pattern and change the reund() function to look like this. We are just swapping two lines, updating the players array and calling sendValue().
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.