Eggstravaganza

First Flight #37
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: low
Valid

`EggHuntGame::gameActive` remains `true` after `endTime` has passed

Summary

The EggHuntGame::gameActive boolean is not correctly updated if EggHuntGame::endTime has passed. This may lead to ambiguity in game state for functions that include EggHuntGame::gameActive and timestamp - resulting in 'active' games that cannot be played.

Vulnerability Details

The only way to update the EggHuntGame::gameActive state is for the Game Owner to call EggHuntGame::endGame - there is no automatic updating of state if the time is allowed to elapse. This may cause state inconsistency when calling functions that rely on both EggHuntGame::gameActive and the timestamp such as the EggHuntGame::searchForEgg function.

Impact

Low impact as it is unlikely that this will result in any loss of funds or break the protocol.

Tools Used

Manual review.

Recommendations

Adding a modifier to update the game state on functions that rely on EggHuntGame::gameActive and the timestamp such as the EggHuntGame::searchForEgg :

modifier updateGameState() {
if (gameActive && block.timestamp > endTime) {
gameActive = false;
emit GameEnded(block.timestamp);
}
_;
}
Updates

Lead Judging Commences

m3dython Lead Judge 8 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Incomplete end game handling

Incorrect values reported when a game is ended early

Support

FAQs

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

Give us feedback!