President Elector

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

Lack of Duplicate Check in `rankCandidates` Allows Manipulation of Candidate Ranking

Summary

The rankCandidates function does not implement a validation check to ensure that the orderedCandidates array contains unique candidate addresses. This oversight allows candidates to be ranked multiple times, which could unfairly influence the ranking outcome, resulting in manipulation of the voting or ranking system.

Vulnerability Details

The rankCandidates function takes an array of candidate addresses, orderedCandidates, and calls the _rankCandidates function with it. However, there is no logic to ensure that the addresses in the array are unique. As a result, the same candidate address can appear multiple times, leading to a skewed ranking process. This issue can be exploited by submitting duplicate candidate addresses to boost a candidate’s ranking position or affect the fairness of the overall ranking.

function rankCandidates(address[] memory orderedCandidates) external {
_rankCandidates(orderedCandidates, msg.sender);
}

Proof of Code

An attacker can submit the same candidate address multiple times in the array, for example:

address[] orderedCandidates = [candidateA, candidateA, candidateB, candidateC];

In this case, candidateA is ranked twice, which may affect the ranking calculation and unfairly promote this candidate over others.

Impact

Allowing duplicates in the ranking system introduces the risk of manipulation, where specific candidates can be unfairly promoted more than intended. Malicious actors could exploit this flaw by submitting the same candidate multiple times, undermining the integrity of the ranking process.

Tools Used

Manual code review.

Recommendations

Add Validation for Duplicate Candidates. Implement logic to ensure that the orderedCandidates array contains unique addresses before passing them to the _rankCandidates function.

Revert on Duplicate Entries. Use a mapping or set to track candidates that have already been ranked and revert the transaction if a duplicate is found.

Updates

Lead Judging Commences

inallhonesty Lead Judge 10 months ago
Submission Judgement Published
Validated
Assigned finding tags:

rankCandidates() allows duplicate votes inside the `orderedCandidates` array

Appeal created

inallhonesty Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
Assigned finding tags:

rankCandidates() allows duplicate votes inside the `orderedCandidates` array

Support

FAQs

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