Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: low
Valid

getActivePlayerIndex returning zero for an inactive-player address is deceptive

Summary

getActivePlayerIndex returns zero if the player is not active, this can be misleading because 0 is a valid index

Vulnerability Details

getActivePlayerIndex returns zero for a player which is present on the 0 index in array and also if the player is not active which is not an ideal behaviour as return value doesn't clarify if the state of player is either active or not.

here's a test case to show what getActivePlayerIndex returns in both conditions

address dummyAddress = makeAddr("dummy");
address playerOne = address(1);
address playerTwo = address(2);
address playerThree = address(3);
function test_GetActivePlayerIndexForNonPlayerAddress() public {
address[] memory players = new address[](2);
players[0] = playerOne;
players[1] = playerTwo;
players[2] = playerThree;
puppyRaffle.enterRaffle{value: entranceFee * 2}(players);
console.log(puppyRaffle.getActivePlayerIndex(dummyAddress));
console.log(puppyRaffle.getActivePlayerIndex(playerOne));
}
/*
Logs:
0
0
*/
  • it's clearly visible return value is same in both the cases

Tool Used

Foundry

Recommended Mitigation

some modifications in getActivePlayerIndex can fix this , for example. rather than returning zero in case of an inactive player , it can throw a custom error InActivePlayer or return an invalid index

Updates

Lead Judging Commences

Hamiltonite Lead Judge about 2 years ago
Submission Judgement Published
Validated
Assigned finding tags:

getActivePlayerIndex can say a player is both entered at slot 0 and inactive

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!