The PuppyRaffle::getActivePlayerIndex function currently returns 0 when a player is not found in the players array. However, 0 is a valid index in the players array, which can lead to confusion or incorrect behavior.
The getActivePlayerIndex function returns 0 for non-active players, even though players[0] returns an active address when the raffle is in session.
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 under the getActivePlayerIndex section.
Execute the following command in your terminal to run the test:
Implications:
Poor UX: This can lead to a poor user experience as the protocol provides incorrect information.
Potential Manipulation: Any function or system that relies on the integrity of the getActivePlayerIndex return value is compromised due to this vulnerability.
Exploit Scenario:
John requests the index of an address and assumes the player's activity status based on the return value. John makes a transaction based on that return value, but the result of his transaction is unexpected due to the incorrect assumption about the getActivePlayerIndex return value.
Foundry
Instead of returning zero, it is recommended to revert the transaction with an error message that notifies the caller that the address isn't active.
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.