Eggstravaganza

First Flight #37
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: medium
Invalid

The gameActive variable is not set to false automatically causing the impossibility to start a new game.

Summary

When the owner starts a game the gameActive variable is set to true and in order to set it to false it's necesary that the owner call the EggHuntGame::endGame function. If the owner forget to do this the state of the game will be active when it's not.

Vulnerability Details

To start a game, the owner have to call the EggHuntGame::startGame function that set the gameActive variable to true. To do this, is required that the initial state of gameActive is false.

function startGame(uint256 duration) external onlyOwner {
@> require(!gameActive, "Game already active");
require(duration >= MIN_GAME_DURATION, "Duration too short");
startTime = block.timestamp;
endTime = block.timestamp + duration;
@> gameActive = true;
emit GameStarted(startTime, endTime);
}

When the game time has elapsed the status of this function does not change automatically, so the game is in a “started state” when it should not be, making it impossible to start a new game.

It is necessary for the owner to call the EggHuntGame::endGame function before in order to start a new game.

Impact

Impossibility to start a new game.

Tools Used

  1. Foundry

  2. Manual Review

Recommendations

Use Chainlink Job Scheduler to remove all centralization is this aspect of the contract.

Updates

Lead Judging Commences

m3dython Lead Judge about 2 months ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.