Description
In the first time when the RankedChoice::selectPresident
function is called s_previousVoteEndTimeStamp variable is equal to zero, so we can simplify the condition/requirement to block.timestamp <= i_presidentalDuratio
and block.timestamp
never will be lower than presidentalDuration (4 year) unless we go back to the beginning of human origin.
The contract needs a way to define the previous president selection time to compare the next president selection time with previous one.
Impact
It is possible call RankedChoice::selectPresident
function with success before the presidentalDuration.
Proof of Concepts
Add this line of code in the RankedChoiceTest::setUp
to simulate that the time at the moment of the deployment is 2024 10:19:49 PM and assuming that the deployment timestamp is the time of the previous president selection.
Then paste the below snipped code into the RankedChoiceTest.t.sol file
The test will pass with without passing 4 years before the previous president selection.
Recommended mitigation
The contract needs a way to define the previous president selection time to compare the next president selection time with previous one. A good place to do it could be in the deployment
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.