Last Man Standing

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

Uninitialized previousKingPayout Logic in claimThrone() Function

Description:

  • The previousKingPayout variable is declared and initialized to zero but never updated or transferred to the previous king in the claimThrone() function.

  • The code comment states that a small portion of the claim fee should be rewarded to the previous king, but no actual payout logic exists.

  • This results in the previous king not receiving any reward, which is against the intended game mechanics and can cause player dissatisfaction and unfair gameplay.

uint256 previousKingPayout = 0;
//If there's a previous king, a small portion of the new claim fee is sent to them.

Risk

Likelihood: High

  • Every time a new player claims the throne (after the first), the previous king should receive a reward, but currently does not. This happens on every claim after the initial one.

Impact: Medium to High

  • Previous kings do not receive promised rewards, harming game fairness and player incentives.

  • Could reduce user trust and participation.

  • The pot and platform fee calculations are also inaccurate since this missing payout is not accounted for, potentially distorting the prize pot size.

Proof of Concept:

In the POC we can see when the player claim the throne the player1 does not receive any claim.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {Test, console2} from "forge-std/Test.sol";
import {Game} from "../src/Game.sol";
contract GameTest is Test {
Game public game;
address public deployer;
address public player1;
address public player2;
address public player3;
address public maliciousActor;
// Initial game parameters for testing
uint256 public constant INITIAL_CLAIM_FEE = 0.1 ether; // 0.1 ETH
uint256 public constant GRACE_PERIOD = 1 days; // 1 day in seconds
uint256 public constant FEE_INCREASE_PERCENTAGE = 10; // 10%
uint256 public constant PLATFORM_FEE_PERCENTAGE = 5; // 5%
function setUp() public {
deployer = makeAddr("deployer");
player1 = makeAddr("player1");
player2 = makeAddr("player2");
player3 = makeAddr("player3");
maliciousActor = makeAddr("maliciousActor");
vm.deal(deployer, 10 ether);
vm.deal(player1, 10 ether);
vm.deal(player2, 10 ether);
vm.deal(player3, 10 ether);
vm.deal(maliciousActor, 10 ether);
vm.prank(deployer);
game = new Game(
INITIAL_CLAIM_FEE,
GRACE_PERIOD,
FEE_INCREASE_PERCENTAGE,
PLATFORM_FEE_PERCENTAGE
);
}
function test_claimmthrone() external{
vm.prank(player1);
game.claimThrone{value: 2 ether}();
vm.prank(player2);
game.claimThrone{value: 4 ether}();
assertEq(game.pendingWinnings(player1),0);
}
}

Recommended Mitigation

  1. Need to define percentage of fee for the previous king.

Updates

Appeal created

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