Beginner FriendlyFoundryGameFi
100 EXP
View results
Submission Details
Severity: medium
Valid

When vote are ties the `winner` is the first one in the list is selected as the winner

Summary

  • when votes are tied the first candidate in the list is selected as the winner

Vulnerability Details

  • when votes are tied the first candidate in the list is selected as the winner

function announceWinner() external onlyOwner {
require(block.timestamp >= startVoteTime + duration, "The voting is active");
uint256 winnerTokenId;
uint256 maxVotes = 0;
for (uint256 i = 0; i < _tokenIds.length; i++) {
@> if (voteCounts[_tokenIds[i]] > maxVotes) {
maxVotes = voteCounts[_tokenIds[i]];
winnerTokenId = _tokenIds[i];
}
}
list = _martenitsaMarketplace.getListing(winnerTokenId);
_healthToken.distributeHealthToken(list.seller, 1);
emit WinnerAnnounced(winnerTokenId, list.seller);
}

Impact

  • First candidate which touches the tie and maximum votes will be selected as the winner

  • Bias towards the first candidate in the list

Tools Used

  • Manual review

Recommendations

  • Use chainlink VRF for random number generation to select the winner in case of a tie

Updates

Lead Judging Commences

bube Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Tie in voting is not considered

Support

FAQs

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