Owner might set the contest with closeTime = block.timestamp, which will make a contest available for only current block and then in next block organizer have no choice but to distribute tokens at a cost of commission fee.
https://github.com/Cyfrin/2023-08-sparkn/blob/0f139b2dc53905700dd29a01451b330f829653e9/src/ProxyFactory.sol#L105-L117
https://github.com/Cyfrin/2023-08-sparkn/blob/0f139b2dc53905700dd29a01451b330f829653e9/src/ProxyFactory.sol#L110
In setContest function, there is a check with closeTime. When closeTime = block.timestamp, we can see, this check fails and then it allows to set close time of a contest at
https://github.com/Cyfrin/2023-08-sparkn/blob/0f139b2dc53905700dd29a01451b330f829653e9/src/ProxyFactory.sol#L114-L115
When closeTime = block.timestamp, this contest set by owner is only valid for the current block. Once organizer see the contest is set by owner by using event emitted by setContest as emit SetContest(organizer, contestId, closeTime, implementation);, they will send tokens to address computed by getProxyAddress function.
https://github.com/Cyfrin/2023-08-sparkn/blob/0f139b2dc53905700dd29a01451b330f829653e9/src/ProxyFactory.sol#L225-L229
Since contest is over due to closeTime < current block.timestamp, organizer have to distribute tokens to winners(supporters). But since contest got over immediately after its been set by owner, there is no winner, so organizer can pass their own address as winners and total percentage (BASIS_POINTS - COMMISSION_FEE) as percentages in distribute function to get their tokens back but at the cost of losing commission fee.
Note: owner is not allowed to reset closeTime once its set as if owner tries to reset this value, that call will get reverted due to check
https://github.com/Cyfrin/2023-08-sparkn/blob/0f139b2dc53905700dd29a01451b330f829653e9/src/ProxyFactory.sol#L114
organizer losing their tokens when owner set the closeTime incorrectly.
Manual Review
We recommend to have some MIN_CONTEST_PERIOD and have a check on closeTime such that its atleast MIN_CONTEST_PERIOD further from current block.timestamp at the time of setContest
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.