President Elector

First Flight #24
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: high
Invalid

Lack of tiebreaker mechanism leads to unfair results

Summary

When multiple candidates have the same number of votes in a round, there is no tiebreaker mechanism to determine which candidate loses that round, leading to unfair results.

Vulnerability Details

The vulnerability lies in L125-L139 of the contract.

If multiple candidates have the same number of votes in a round, and one of them is an address in the first element of the array candidateList, it would be the candidate that loses the voting round.

Proof Of Concept

Working test case

function testNoTiebreaker() public {
// All 3 candidates have the same number of votes, but candidates[0] lost in the first round because it is the default fewestVotesCandidate during computation
orderedCandidates = [candidates[0], candidates[1], candidates[2]];
vm.prank(voters[0]);
rankedChoice.rankCandidates(orderedCandidates);
orderedCandidates = [candidates[1], candidates[0], candidates[2]];
vm.prank(voters[1]);
rankedChoice.rankCandidates(orderedCandidates);
orderedCandidates = [candidates[2], candidates[1], candidates[0]];
vm.prank(voters[2]);
rankedChoice.rankCandidates(orderedCandidates);
vm.warp(block.timestamp + rankedChoice.getDuration());
rankedChoice.selectPresident();
assertEq(rankedChoice.getCurrentPresident(), candidates[1]);
}

Impact

This vulnerability leads to unfairness of the voting results because of how the contract processes information when multiple candidates have the same number of votes.

Tools Used

Foundry, manual review

Recommended Mitigation

To mitigate this vulnerability, the contract should implement a tiebreaker mechanism when there are multiple candidates with the same number of votes in a round.

Updates

Lead Judging Commences

inallhonesty Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Known issue

Support

FAQs

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