There is a reentrancy vulnerability during the refund, because deleting of a player from the players array is done after the external call to return money
When user wants to refund their ticket, the actual transfer of money is made by an external call and executed by the user. The players array (state veriable) is being changed after the transfer of money. Thus, user can return to the contract and send funds again before they are deleted from the array.
Code of the Test:
Code of the Attack:
Impact is very high, because bad actor may drain the entire protocol and get all the funds, even the ones that weren't claimed by the owner before. Thus, the impact is considered high (funds are directly at risk).
Foundry, DeFiVulnLabs (https://github.com/SunWeb3Sec/DeFiVulnLabs/tree/main/src/test)
Follow Checks, Effects, Interactions pattern and move up the deletion of player from the players array before the actual transfer of funds:
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.