Last Man Standing

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

Unused previousKingPayout Variable Creates Dead and Misleading Logic

Root + Impact

The root cause lies in the presence of a previousKingPayout variable in claimThrone() that is never assigned any non-zero value. The logic surrounding it suggests the previous king should receive part of the next claim fee — as stated in documentation — but no actual payout ever occurs:

Receives a small payout from the next player's claimFee (if applicable).

The impact is twofold: (1) the platform fee calculation includes a defensive check involving a meaningless variable, and (2) players are misled into thinking they will receive payouts as the previous king, when in fact they receive nothing.

Description

  • The contract defines a previousKingPayout and references it in fee calculations, but it is never assigned or transferred to the previous king.

  • This creates misleading expectations for players and leaves dead logic that serves no purpose.

function claimThrone() external payable gameNotEnded nonReentrant {
...
uint256 previousKingPayout = 0;
...
@> if (currentPlatformFee > (sentAmount - previousKingPayout)) {
@> currentPlatformFee = sentAmount - previousKingPayout;
}
...
}

Risk

Likelihood:

The likehood is High because:

  • Always active; previousKingPayout is permanently set to 0.

  • Code executes on every claimThrone() call but has no real effect.

Impact:

The impact is Low because the issue:

  • Misleads users who expect payouts as per the documentation.

  • Introduces unnecessary code complexity and false safety checks.

Proof of Concept

None.

Recommended Mitigation

If previous king payouts are intended:

+ uint256 previousKingPayout = (sentAmount * previousKingRewardPercentage) / 100;
// set this amount to the previous king in a mapping so they can later ckaim his part of the claimFee

If not intended, simplify the logic:

- uint256 previousKingPayout = 0;
- if (currentPlatformFee > (sentAmount - previousKingPayout)) {
- currentPlatformFee = sentAmount - previousKingPayout;
- }
+ // Remove unused previousKingPayout and related condition
Updates

Appeal created

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