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

The token with id=0 will aways win the voting when there are no participants

Summary

The token with id=0 will win the voting process always when there are no participants in the vote.

Vulnerability Details

As the default value of uint256 is 0, if there aren't participants in the voting, and the token with id=0 is listed for sale, it win.

POC

function testMTZeroWillWinIfNoParticipants() public startVoting listMartenitsa {
uint256 chasyHTbeforeWinning = healthToken.balanceOf(chasy);
console.log("Balance of Chasy before the voting: ", chasyHTbeforeWinning);
vm.warp(block.timestamp + 1 days + 1);
voting.announceWinner();
uint256 chasyHTAfter = healthToken.balanceOf(chasy);
console.log("Balance of Chasy after the voting: ", chasyHTAfter);
assert(chasyHTbeforeWinning < chasyHTAfter);
}

Impact

The first minted MT can be listed for a very high price and win some HT when nobody votes.

Tools Used

Manual Review

Recommendations

Revert if the winner has 0 votes.

Updates

Lead Judging Commences

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

`tokenId=0` wins the voting

Support

FAQs

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