President Elector

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

Unrestricted `RankedChoice.sol::s_candidateList` list growth.

Description
In the RankedChoice.sol::selectPresident function, the s_candidateList expands dynamically as new candidates are ranked by voters. If all 100 voters each rank 10 different candidates, the list could grow to 1,000 candidates. This excessive growth could result in gas exhaustion or inefficient execution, especially during the nested loops in the selectPresident and _selectPresidentRecursive functions, where the entire list is processed. As the number of candidates increases, so does the likelihood of exceeding gas limits, leading to potential transaction failures or delays in election results.

Recommended mitigation
Consider adding a reasonable upper limit on the number of unique candidates that can be added. This can be done by ensuring that no more than a predefined number of unique candidates are allowed, preventing uncontrolled growth of the list.

Updates

Lead Judging Commences

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

A high number of candidates could cause an OOG

Support

FAQs

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