The EggHuntGame
contract contains a logical inconsistency in its getGameStatus()
function that can lead to contradictory game state reporting. The function can return "Game time elapsed" even when the internal gameActive
flag is still set to true
. This inconsistency creates a state where the game appears to be simultaneously active and ended, potentially confusing users and causing unexpected behavior in dependent contract functions and frontend interfaces.
The vulnerable function is found in the EggHuntGame
contract:
The issue arises when block.timestamp
exceeds endTime
but gameActive
is still true
. In this scenario, the function returns "Game time elapsed" despite the game still being marked as active in the contract state. This creates a misalignment between the reported status and the actual state that controls contract behavior.
The core problem is that the contract does not automatically set gameActive = false
when the time elapses, relying instead on a manual call to the endGame()
function by the contract owner.
This status inconsistency has several negative impacts:
User Confusion: Players may receive conflicting information about whether the game is active or not, leading to confusion and potential frustration.
Frontend Discrepancies: UIs relying on the getGameStatus()
function may display incorrect information or enter an undefined state, causing poor user experience.
Operational Delays: If the owner does not call endGame()
promptly, the contract remains in an inconsistent state where it reports the game has ended but still has gameActive = true
.
Manual code review
Add Automatic Game End: Modify the contract to automatically update the gameActive
state when the end time is reached:
Incorrect values reported when a game is ended early
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.