Description: The contract processes all voters and candidates in loops within functions like selectPresident
and _selectPresidentRecursive
. If the number of voters or candidates is large, these loops could exceed the block gas limit, causing transactions to fail.
Impact:
Transaction Failure: Large voter or candidate lists could lead to transactions running out of gas, resulting in failed attempts to execute critical functions like selecting a president.
Operational Disruption: This could disrupt the election process, preventing the selection of a new president and potentially halting the governance process.
Proof of Concept: If the number of voters or candidates is sufficiently large, attempting to execute the selectPresident function could result in an out-of-gas error:
Recommended Mitigation:
Batch Processing: Process voters and candidates in smaller batches over multiple transactions to avoid hitting gas limits.
Gas Limit Checks: Implement checks to ensure that loops do not exceed a safe number of iterations based on current gas limits.
Optimized Data Structures: Use more gas-efficient data structures and algorithms to handle large lists.
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.