The claimThrone function fails to consider the "previous king reward" when calculating the accumulated pot amount.
When computing amountToPot, the existence of previousKingPayout is completely ignored. This flawed logic causes amountToPot to be larger than it should be.
Impact:
After normal pot accumulation, three parties are expected to withdraw funds: the admin (platform fees), the previous king (small reward), and the current winning king (pot prize).
Due to the miscalculation of amountToPot that ignores the previous king's payout, the accounting becomes inconsistent.
This discrepancy will inevitably cause the last withdrawer to fail, as the recorded balances no longer reflect the actual available funds.
This vulnerability assumes the claimThrone function has already fixed the following two issues:
Correct initial check: require(msg.sender != currentKing, "Game: You are already the king. No need to re-claim.");
Proper previous king reward calculation and tracking: uint256 previousKingPayout = (sentAmount * previousKngFeePercentage) / 100;
Admin deploys the contract.
Player player1 pays the claim fee and calls claimThrone.
Player player2 pays the claim fee and calls claimThrone.
Wait for the grace period to expire (1 day).
Player player1 successfully withdraws their reward.
Admin deployer successfully withdraws platform fees.
Player player2 attempts to withdraw pot winnings but fails with: Game: Failed to withdraw winnings.
Simply adjust the amountToPot calculation to account for previousKingPayout as shown below:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.