President Elector

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

Multiple Candidates Left in winnerList After Selection

Summary

In the selectPresident() function, after the recursive selection process, the contract expects only one candidate to remain in the winnerList. However, if no candidates or multiple candidates remain in the winnerList, the contract reverts with the error RankedChoice__SomethingWentWrong(). This indicates incomplete handling of edge cases where no candidate is left.

Impact

If the voting process fails to eliminate enough candidates, it could lead to a situation where no president is selected, or the contract reverts due to multiple candidates remaining. This could halt the election process and leave the contract in an invalid state.

Proof of Concept:

The winnerList may have multiple candidates after the selection process, leading to a reversion of the transaction. The contract assumes that the recursive selection will always leave only one candidate.

Tools Used

Manual Review

Recommendations

Implement a check to ensure that the winnerList is not empty before finalizing the president selection and handle cases where multiple candidates remain.

'''

if (winnerList.length == 0) {
revert RankedChoice__SomethingWentWrong();
}

'''

Updates

Lead Judging Commences

inallhonesty Lead Judge
9 months ago
inallhonesty Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Too generic

Support

FAQs

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