The mappings where the count of votes are stored and where it is recorded if the users have particpated in the current voting is not reset after the winner is announced. This means that users can only vote once and the likelihood of early minted tokens of being selected as future winners is higher since they will accrue points since their first voting phase.
This vulnerability has two main implications, first, martenitsas with lower token IDs will begin next rounds with the already accumulated points and therefore with some advantage over newly minted or previously less voted tokens, reducing the fairness of the competition. Second, once users participate in a voting, if they want to particpate in future votings they will have to do it from a different address.
To illustrate the first implication, imagine the following scenario:
chasy
mints token ID 0
before the first voting phase begins.
The voting begins and bob
and someUser
vote for her token. Token ID 0
has accumulated 2 points.
The voting concludes and chasy
is announced as the winner.
After finishing the first voting, jack
mints token ID 1
.
The new voting begins and now only anotherUser
votes and decides to vote for token ID 1
. Token ID 1
has 1 vote.
The voting concludes and since the voting count has not been previously reset, chasy
is announced again as the winner with no votes in this phase.
See PoC below.
Place this into MartenitsaVoting.t.sol
.
For the second implication the following scenario can be considered:
chasy
mints token ID 0
and the voting begins.
bob
votes for token ID 0
.
The voting concludes and chasy
is announced as the winner.
The second voting begins and no one mints a new token.
bob
wants to vote again for chasy
's token, however the transaction reverts as the mapping MartenitsaVoting::hasVoted
is still set to true.
See PoC below.
Place this into MartenitsaVoting.t.sol
.
Foundry and manual review.
The fix to reset the vote count is easy and it does not require to change the logic of the contract, however for the partcipants votes it requires to add an extra array and a for loop which are described in detail in the code below.
Adjust this in MartenitsaVoting
.
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.