The absence of sufficient input validation in the enterRaffle function allows it to receive an empty array, resulting in a denial of service when the function is invoked with an empty array.
When the enterRaffle function is called with an empty array, it encounters an underflow issue when calculating players.length - 1 within the for loop that checks for duplicate entries. This can lead to running out of gas while checking for duplicates.
The provided test 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.
Execute the following command in your terminal to run the test:
Note that the test freezes.
Functionality Disruption: An empty array input to the enterRaffle function can lead to a denial of service, partially disabling the protocol.
Foundry
Add a require statement to check for empty array inputs and revert if an empty array is provided. The modified function should look like this:
Also use the latest solidity version.
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.