Last Man Standing

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

Platform Fee Calculation May Revert on Underflow

Root + Impact

Description

  • In claimThrone():

uint256 currentPlatformFee = (sentAmount * platformFeePercentage) / 100;
// Defensive check:
if (currentPlatformFee > (sentAmount - previousKingPayout)) {
currentPlatformFee = sentAmount - previousKingPayout;
}

But previousKingPayout is always 0, so this condition is pointless and might cause:

  • Over-allocation to platform fees

  • Loss of user trust

  • Unstable logic if payout code is added later

And if in future the previousKingPayout becomes non-zero (say 110% of sentAmount due to logic bug), subtraction underflows and causes a revert.

Risk

Impact:

  • Transfer blocked

  • Pot broken

Proof of Concept

Right now previousKingPayout == 0, but simulate a future update:

// Assume bug adds 110% payout in future
uint256 previousKingPayout = (sentAmount * 110) / 100;
uint256 currentPlatformFee = (sentAmount * platformFeePercentage) / 100;
// now: sentAmount - previousKingPayout < 0 → underflow → revert

Recommended Mitigation

Enforce safe arithmetic using SafeMath or require sentAmount >= previousKingPayout

  • Or simply remove the redundant check now and reimplement properly when king payout logic is added

Updates

Appeal created

inallhonesty Lead Judge 10 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!