Eggstravaganza

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

Function `EggHuntGame::getTimeRemaining` shows the time remaining higher than 0 in case the owner decides to end the game

### [L-1] Function `EggHuntGame::getTimeRemaining` shows the time remaining higher than 0 in case the owner decides to end the game
**Description:** If the Owner of the contrct decides to call `EggHuntGame::endGame` the startTime and endTime are not updated making the `EggHuntGame::getTimeRemaining` return a value greater than 0 giving the player wrong information.
**Impact:** Player who calls the function sees the time is not over even if the game is ended by the owner
**Proof of Concept:**
1. Owner of the game ends the session
2. Player calls `EggHuntGame::getTimeRemaining` to see if he has time left to search for the NFT
3. Player gets back startTime - endTime which is greater than 0 even though the game ended
**Recommended Mitigation:** Set startTime equal to endTime in the `EggHuntGame::endGame`
```diff
function endGame() external onlyOwner {
require(gameActive, "Game not active");
gameActive = false;
+ startTime = block.timestamp;
+ endTime = block.timestamp;
emit GameEnded(block.timestamp);
}
```
Updates

Lead Judging Commences

m3dython Lead Judge 4 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.