Description: The gracePeriod
should be set to a reasonable duration to allow players to fairly participate in the game. The deployer can currently update gracePeriod
to a very short window (1 second), which would not allow fair and proper game participation. This could potentially cause confusion and disruption of the protocol. A malicious deployer could use this to manipulate the outcome of a game, allowing the current king to gain an advantage (if changed mid-game).
Impact: Medium
While no funds are directly at risk, many players could be put at a disadvantage, especially if the new grace period is set to a very short duration.
Likelihood: Medium
There are no minimum duration checks on the gracePeriod
parameter. Thus, it could be set to any number by the deployer.
Proof of Concept:
Create a game with a one-day grace period.
VM.warp 1 second.
Deployer updates gracePeriod
to 1 second.
The game is now over.
Proof of Code: Paste the below code into Game.t.sol
.
Here is the output after running:
"forge test --mt test_NoMinGracePeriod -vv"
Recommended Mitigation: I would recommend creating a minimum grace period of one hour to allow the game to function properly. The game::updateGracePeriod
function will be updated plus we must initialize the new minGracePeriod
at the top.
Here is how to make the change:
And:
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.