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

PuppyRaffle::getActivePlayerIndex() returns 0 on non existing player

Summary

PuppyRaffle::getActivePlayerIndex(address) returns 0 on non existing player. Since there's a player on zero Index, it might confuse the player who is actually in the zero index.

Vulnerability Details

  • No difference if a input for getActivePlayerIndex(address) is player at zero address and non existing player.

  • Revert if player is non-exists.

Impact

  • Severity : low

  • likelihood : high

Tools Used

  • manual verification

Recommendations

function getActivePlayerIndex(address player) external view returns (uint256) {
for (uint256 i = 0; i < players.length; i++) {
if (players[i] == player) {
return i;
}
}
- return 0;
}
function getActivePlayerIndex(address player) external view returns (uint256) {
for (uint256 i = 0; i < players.length; i++) {
if (players[i] == player) {
return i;
}
}
+ revert("player doesnt exist");
}
Updates

Lead Judging Commences

Hamiltonite Lead Judge almost 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.