Eggstravaganza

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

Premature Game Termination Vulnerability in EggHuntGame Contract

Summary

In the `EggHuntGame::endgame` unction lacks a check to verify that the game duration has elapsed before ending the game. Although a helper function getTimeRemaining() exists, its logic is not enforced in endGame(), potentially allowing the game owner to end the game prematurely.

Vulnerability Details

The EggHuntGame contract allows the owner to end a game by calling the endGame() function. However, this function only checks if the game is active, not whether the scheduled end time has passed. As a result, the owner can terminate the game before the intended duration is complete, affecting game fairness and user expectations. This issue is classified as medium severity if the design intends to run the game until endTime.

Impact

Without the time check, the game owner might accedently end the game prematurly potentially impacting rewards or game dynamics.

Tools Used

Manual review

Recommendations

Modify the function to have a requirement like this

function endGame() external onlyOwner {
// @med there should be a check to see if the endTime has passed
(diff)
+ require(endTime <= block.timestamp)
require(gameActive, "Game not active");
gameActive = false;
emit GameEnded(block.timestamp);
}
Updates

Lead Judging Commences

m3dython Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Design choice
Assigned finding tags:

Trusted Owner

Owner is trusted and is not expected to interact in ways that would compromise security

Support

FAQs

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