The PuppyRaffle::enterRaffle and PuppyRaffle::refund functions remain callable after the raffleDuration has elapsed, and a winner has not been chosen.
The enterRaffle and refund functions lack input validations that check whether block.timestamp <= raffleStartTime + raffleDuration before proceeding with the rest of the function code.
The provided test suite demonstrates the validity and severity of this vulnerability.
Requirements:
Install Foundry.
Clone the project codebase into your local workspace.
Step-by-step Guide to Run the Test:
Ensure the above requirements are met.
Copy the test below and add it to PuppyRaffleTest.t.sol tests.
Paste these events before the setUp function in PuppyRaffleTest.t.sol.
Execute the following command in your terminal to run the test:
Implications:
This vulnerability allows non-active players to enter the game after it has completed and potentially seize the winner's position if timed correctly. Additionally, players can avoid losing their stake by quickly obtaining a refund before a winner is selected.
Exploit Scenario:
John participated in a raffle session and lost the round.
But before the selectWinner transaction sent by Sarah is processed, John front-runs it with a refund transaction.
He promptly exits the game before losing his funds.
Foundry
Add a check that ensures enterRaffle and refund are only callable before the raffle duration elapses. This can be implemented as follows:
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.