Description: The selectPresident
function modifies critical state variables before completing all logic. If future modifications introduce external calls, this could be exploited to manipulate the election process through reentrancy.
Impact:
State Manipulation: If external calls were introduced, an attacker could potentially reenter the function and alter the election results by manipulating state variables such as s_currentPresident
, s_candidateList
, and s_previousVoteEndTimeStamp
.
Proof of Concept: Currently, no external calls exist in the function, so direct exploitation isn't possible. However, if external calls were added, reentrancy could be exploited as follows:
Recommended Mitigation:
Use the "Checks-Effects-Interactions" Pattern: Ensure all state changes occur after all logic is complete and before any external calls.
Reentrancy Guard: Consider using a reentrancy guard (such as OpenZeppelin's ReentrancyGuard) to prevent reentrant calls.
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.