Eggstravaganza

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

Inconsistent Time Boundary Handling Across Game Functions

Summary

The getTimeRemaining function handles the end time boundary (block.timestamp == endTime) differently from other game functions like searchForEgg and getGameStatus, which could lead to player confusion and inconsistent game state reporting.

Vulnerability Details

Compare how different functions handle the end time condition:

// getTimeRemaining returns 0 when block.timestamp = endTime
function getTimeRemaining() external view returns (uint256) {
return block.timestamp >= endTime ? 0 : endTime - block.timestamp;
}
// searchForEgg allows playing when block.timestamp = endTime
function searchForEgg() external {
require(gameActive, "Game not active");
require(block.timestamp >= startTime, "Game not started yet");
require(block.timestamp <= endTime, "Game ended"); // Inclusive
// ... rest of the function
}
// getGameStatus considers game active when block.timestamp = endTime
function getGameStatus() external view returns (string memory) {
if (gameActive) {
if (block.timestamp < startTime) {
return "Game not started yet";
} else if (block.timestamp >= startTime && block.timestamp <= endTime) {
return "Game is active"; // Inclusive
} else {
return "Game time elapsed";
}
} else {
return "Game is not active";
}
}

The inconsistency occurs at exactly block.timestamp == endTime:

  1. getTimeRemaining returns 0 (suggests game is over)

  2. searchForEgg allows playing (suggests game is active)

  3. getGameStatus reports "Game is active" (suggests game is active)

Impact

LOW severity because no funds or assets are at risk, but it affects user experience at a very specific timestamp.

Tools Used

Manual code review

Recommendations

Make the boundary condition handling consistent across all functions.

Updates

Lead Judging Commences

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

Support

FAQs

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