Last Man Standing

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

Winner Event Logs Zero Prize

Root + Impact

Description

  • Normal behavior: declareWinner() should transfer the entire pot to the current king and emit the GameEnded event with the correct prize amount.

  • Issue: The function sets pot to 0 before emitting GameEnded, so the prizeAmount logged in the event is always zero:

pendingWinnings[currentKing] += pot;
pot = 0;
emit GameEnded(currentKing, pot, block.timestamp, gameRound); // prizeAmount emitted is 0

Risk

Likelihood:

  • The bug triggers every time declareWinner() is called; the event always reports a zero prize, so the likelihood is high whenever a winner is declared.

Impact:

  • Off‑chain Misrepresentation: Analytics platforms and dApps rely on events. Incorrect prizeAmount misleads users and could break integrations that depend on the event data.


  • Audit Complexity: Off‑chain services might assume no prize was paid, leading to erroneous financial reporting.

Proof of Concept

// Deploy the contract and simulate two claims to build a pot.
vm.startPrank(alice);
game.claimThrone{ value: INITIAL_CLAIM_FEE }();
vm.stopPrank();
vm.warp(block.timestamp + GRACE_PERIOD + 1);
game.declareWinner();
(uint256 emittedPrize, ) = game.getPot(); // emitted prize is 0 in the event

Recommended Mitigation

function declareWinner() external gameNotEnded {
...
- pendingWinnings[currentKing] += pot;
- pot = 0;
- emit GameEnded(currentKing, pot, block.timestamp, gameRound);
+ uint256 prize = pot;
+ pendingWinnings[currentKing] += prize;
+ pot = 0;
+ emit GameEnded(currentKing, prize, block.timestamp, gameRound);
}
Updates

Appeal created

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

Give us feedback!