The _selectPresidentRecursive() function in the RankedChoice contract is responsible for eliminating the lowest-voted candidate in each round of voting. However, the function does not account for ties in the vote count. In case of a tie between multiple candidates with the lowest votes, the function may arbitrarily eliminate one of the candidates, which could lead to unfair outcomes in the election.
The vulnerability lies in how the _selectPresidentRecursive() function handles the elimination process. Currently, the function selects the candidate with the fewest votes for removal without checking if multiple candidates share the same lowest vote count. If multiple candidates are tied for the lowest votes, the contract removes one of them without any tie-breaking mechanism. This could result in an unfair advantage or disadvantage for the tied candidates.
Here’s how the issue occurs:
The function iterates through the list of candidates and compares their vote counts.
It identifies the candidate with the fewest votes and selects them for elimination.
If two or more candidates have the same (lowest) vote count, the function still only eliminates one of them, potentially arbitrarily, without resolving the tie.
Since there is no logic to handle ties, this creates a fairness issue where tied candidates are not treated equally in the elimination process.
The absence of tie-breaking logic can lead to the following impacts:
Unfair Candidate Elimination: Tied candidates may not have equal chances of advancing to the next round. One candidate could be eliminated without a fair reason.
Election Manipulation: This vulnerability could be exploited to influence election results by strategically creating ties, leading to arbitrary eliminations that favor certain candidates.
Integrity Risk: The lack of a clear tie-breaking mechanism can undermine the transparency and fairness of the voting process, potentially damaging trust in the election system.
Recursive Functions: The issue lies in the recursive structure of the function that eliminates candidates without checking for ties.
Add Tie-Breaking Logic: Modify the _selectPresidentRecursive() function to handle ties explicitly. If two or more candidates have the same number of votes, the contract should implement a fair method for deciding which candidate to eliminate. For example, you could:
Implement a random selection mechanism in case of a tie.
Use additional criteria, such as voter ranking in earlier rounds, to break ties.
Example of Handling Ties:
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.