Last Man Standing

First Flight #45
Beginner FriendlyFoundrySolidity
100 EXP
View results
Submission Details
Severity: low
Valid

Incorect pot value emitted in GameEnded Event

Root + Impact

Description

  • In the declareWinner() function, the GameEnded event is emitted after the pot value is reset to zero.

  • As a result this event always emits 0 as the pot value, even though the king actually won a non-zero amount. This breaks expectations for indexers, frontends and monitoring tools that rely on GameEnded for prize tracking.

gameEnded = true;
pendingWinnings[currentKing] += pot;
pot = 0;
emit GameEnded(currentKing, pot, block.timestamp, gameRound); // @> emits 0 as pot

Risk

Likelihood:

  • Always when calling declareWinner() function.

Impact:

  • The emitted pot value in the GameEnded event is misleading and incorrect.

  • External services (indexers, analytics, UIs) may display inaccurate reward data.

  • Reduces transparency and trust for users monitoring game state via events.

  • This issue is not just cosmetic. Many third-party systems use GameEnded to trigger UI updates, build game histories, distribute community rewards, or trigger off-chain processes. A false pot value causes logical failures or confusion in all these layers.

Proof of Concept

To reproduce the issue:

  1. Let’s assume the pot currently holds 5 ether.

  2. A user calls the claimThrone() function multiple times, incrementally increasing the pot.

  3. After the last successful claimThrone(), no one claims the throne for the full duration of gracePeriod.

  4. An external caller (anyone) calls declareWinner(), triggering the end of the game.

// Internal logic:
pendingWinnings[currentKing] += 5 ether;
pot = 0;
// But the event logs:
GameEnded(currentKing, 0, ..., ...)

Recommended Mitigation

Store pot in a local variable before modifying it, and emit that value

+ uint256 winnings = pot;
+ pendingWinnings[currentKing] += winnings;
+ pot = 0;
+ emit GameEnded(currentKing, winnings, block.timestamp, gameRound);
Updates

Appeal created

inallhonesty Lead Judge about 1 month ago
Submission Judgement Published
Validated
Assigned finding tags:

Game::declareWinner emits GameEnded event with pot = 0 always

Support

FAQs

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