Last Man Standing

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

No Previous King Payout

Root + Impact

Description

  • Normal behavior: When a new player claims the throne, a portion of their fee should reward the previous king.

  • Issue: The variable previousKingPayout is declared but never used, and no ETH is transferred to the former king. Instead, all funds (minus platform fees) are added to the pot:

uint256 previousKingPayout = 0;
...
amountToPot = sentAmount - currentPlatformFee;
pot += amountToPot; // previous king receives nothing

Risk

Likelihood:

  • The bug occurs every time a player dethrones the current king, but the practical impact is lower because the game is currently inoperable due to the H‑01 bug. If H‑01 is fixed, it becomes relevant.

Impact:

  • Incorrect Incentives: Dethroned kings earn no compensation, undermining the intended reward mechanism.


  • Player Frustration: Participants may be less inclined to play if they never recover part of their claim fee.

Proof of Concept

// Assume H‑01 is fixed and two players claim in sequence.
game.claimThrone{ value: INITIAL_CLAIM_FEE }(); // Alice is king
game.claimThrone{ value: game.claimFee() }(); // Bob dethrones Alice
// Check that no ETH was transferred to Alice.
// pendingWinnings[Alice] == 0
assertEq(game.pendingWinnings(alice), 0);

Recommended Mitigation

Implement the previous‑king payout. For example, pay a small percentage (e.g., 10%) of the claim fee to the previous king:

function claimThrone() external payable gameNotEnded nonReentrant {
require(msg.value >= claimFee, "Game: Insufficient ETH sent to claim the throne.");
require(msg.sender != currentKing, "Game: You are already the king. No need to re-claim.");
uint256 sentAmount = msg.value;
address priorKing = currentKing;
// Calculate payouts
uint256 platformFee = (sentAmount * platformFeePercentage) / 100;
uint256 previousKingReward = (sentAmount * previousKingRewardPct) / 100;
uint256 toPot = sentAmount - platformFee - previousKingReward;
// Transfer reward to previous king
if (priorKing != address(0) && previousKingReward > 0) {
pendingWinnings[priorKing] += previousKingReward;
}
platformFeesBalance += platformFee;
pot += toPot;
// update state ...
}
Updates

Appeal created

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Missing Previous King Payout Functionality

Support

FAQs

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

Give us feedback!