Last Man Standing

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

Incorrect Event Emission in declareWinner

Root + Impact

Description

  • Normally, the GameEnded event should emit the actual prize amount won by the king.

  • The current implementation emits the pot value after it has been reset to zero, so the event always shows a prize of 0.

pendingWinnings[currentKing] = pendingWinnings[currentKing] + pot;
pot = 0; // @> pot is reset before event
emit GameEnded(currentKing, pot, block.timestamp, gameRound); // @> emits 0

Risk

Likelihood:

  • This will occur every time a winner is declared.

  • All event logs will show a prize of 0, regardless of the actual payout.

Impact:

  • Frontend and analytics tools will display incorrect prize information.

  • Reduces transparency and trust in the game.

Proof of Concept

// 1. Alice is currentKing, pot = 10 ether
// 2. declareWinner() is called
// emit GameEnded(Alice, 0, ...) // should be 10 ether

Recommended Mitigation

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

Appeal created

inallhonesty Lead Judge about 2 months 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.