the s_previousVoteEndTimeStamp isn’t be set to 0 when deploy the contract, which cause the bypass of the limitation of the i_presidentalDuration
in the providedRankedChoicecontract lies in theselectPresidentfunction. Specifically, the vulnerability exists in the time check logic for voting. TheNotTimeToVoteerror is triggered if the following condition is met:
Since the initial value ofs_previousVoteEndTimeStampis 0 and i_presidentalDuration is 125184000(1260 days), the block.timestamp is greater than 1726617600 (1726617600 is time of the 2024/09/18), so during the first voting attempt,block.timestamp - s_previousVoteEndTimeStampwill likely be greater thani_presidentalDuration,so this can
bypass the limitation of the time.
POC(add this to the RankedChoiceTest.t.sol ):
the attack can call rankCandidates and selectPresident to choice the first Prensent immediately.
foundry, vscode
modify the construct code to this:
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.