The contract uses a push-based withdrawal mechanism to transfer winnings to players, which creates a Denial of Service (DoS) vulnerability. If the contract balance is insufficient at the time of payout, the transfer call reverts, and the player is unable to receive their winnings. Furthermore, there is no mechanism for players to retry withdrawing their winnings later, even if the contract is subsequently funded. This results in permanent loss of winnings for affected players and disrupts the game flow.
Root Cause:
The endGame function transfers winnings to the player directly using the transfer method:
This push-based method:
Relies on the contract’s balance being sufficient at the time of execution.
Does not provide a fallback mechanism to allow players to withdraw their winnings later.
Symptoms:
If the contract balance is insufficient when a player wins:
The transfer call fails, causing the entire transaction to revert.
The player is unable to retry withdrawing their winnings, even if the contract is subsequently funded.
Code Affected:
endGame Function:
Behavior Details:
Players’ winnings are tied to the immediate state of the contract balance. If funds are insufficient, the winnings are permanently inaccessible.
Permanent Loss of Winnings:
Players cannot retrieve their winnings if the prize payout fails due to insufficient contract balance.
Denial of Service for Prize Withdrawals:
The push-based mechanism locks players out of their funds with no option to retry later, disrupting the game flow.
Reputation Risk:
Players may lose trust in the protocol if winnings are not consistently and reliably paid out.
Manual code review.
Switch to Pull-Based Withdrawal Mechanism:
Replace the push-based prize withdrawal mechanism with a pull-based approach, where players can manually withdraw their winnings when the contract balance is sufficient. This prevents reverts due to insufficient funds at the time of payout and provides a fallback for players to claim their prizes later.
Modify the endGame function to record the player’s winnings instead of transferring them immediately:
Add a withdrawWinnings function that allows players to claim their winnings when the contract balance is sufficient:
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.