Last Man Standing

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

Redundant Platform Fee Cap Check Due to Hardcoded `previousKingPayou

I-1 Redundant Platform Fee Cap Check Due to Hardcoded previousKingPayout

Description

Within the Game::claimThrone function, the variable previousKingPayout is always explicitly initialized to 0 on each invocation. As a result, the following conditional check becomes redundant:

if (currentPlatformFee > (sentAmount - previousKingPayout)) {
currentPlatformFee = sentAmount - previousKingPayout;
}

Given that:

  • previousKingPayout is always zero,

  • currentPlatformFee is derived as (sentAmount * platformFeePercentage) / 100,

  • and platformFeePercentage is bounded between 0 and 100,

this check will always evaluate to false, rendering the logic unnecessary. The condition is effectively comparing currentPlatformFee > sentAmount, which should never occur if platformFeePercentage is properly constrained.

Code Snippet Highlight

The redundant check is found in the following portion of the claimThrone function:

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;
uint256 previousKingPayout = 0;
uint256 currentPlatformFee = 0;
uint256 amountToPot = 0;
currentPlatformFee = (sentAmount * platformFeePercentage) / 100;
// Redundant check due to previousKingPayout being hardcoded to zero
if (currentPlatformFee > (sentAmount - previousKingPayout)) {
currentPlatformFee = sentAmount - previousKingPayout;
}
}

Risk

Likelihood:

  • None – This code path is not reachable due to constant values.

Impact:

  • None – The redundant logic has no effect on contract behavior or fund flow.

    While this does not introduce any functional risk, it adds unnecessary complexity and may confuse future maintainers.

Recommended Mitigation

Remove the unreachable conditional block to simplify the function and improve code clarity:

currentPlatformFee = (sentAmount * platformFeePercentage) / 100;
- if (currentPlatformFee > (sentAmount - previousKingPayout)) {
- currentPlatformFee = sentAmount - previousKingPayout;
- }
Updates

Appeal created

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