By passing duplicate rankings within the orderedCandidates array, since there's no check to prevent the same candidate from being ranked multiple times by the same voter, malicious voters can easily exploit this to amplify their votes. This could also be done by passing address(0) as a candidate. All this would give disproportionate weight to the chosen candidate.
The recursive election process will tally votes based on how often a candidate appears in a voter's ranked list. Since the malicious voters have submitted the same candidate address for example 10 times, that candidate will get counted 10 times for each malicious voter. In the for loop, the system checks each ranking in s_rankings[VOTERS[i]][s_voteNumber] and increments the candidate’s votes if they are in the candidateList. Because the malicious voters have ranked the same candidate repeatedly, the candidate’s vote count will increase significantly compared to other candidates, artificially boosting their chances of winning.
This creates an unfair voting outcome, as the malicious voters essentially inflate the vote tally for their preferred candidate. Even though the honest voters are submitting reasonable rankings, the malicious voters manipulate the results by repeatedly ranking the same candidate, potentially leading to a skewed election result.
Additionally, passing address(0) as a candidate the contract could end up counting votes for the zero address, which is not a real candidate. This would skew the election results by including invalid votes and it could end up as the elected "candidate," which would break the election logic, as the zero address is not a valid participant.
Paste the following code in the existing test suite, proving both duplicate and address(0) could be passed:
Manual Review, Foundry
Validate whether the passed candidate is not the address(0) by adding this check in the _rankCandidatesfunction.
and ensure that is a proper check for duplicates in the passed candidates for example:
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.