TwentyOne

First Flight #29
Beginner FriendlyGameFiFoundrySolidity
100 EXP
View results
Submission Details
Severity: medium
Invalid

Insecure Ether Transfer Mechanism via `transfer` in Payment Logic

Summary

The current implementation of the payment logic in the endGame function uses transfer to send Ether to the player. This approach imposes a fixed gas stipend of 2,300, which may lead to failed transactions when interacting with smart contract wallets or wallets with high execution requirements.

Vulnerability Details

The vulnerability exists in the endGame function

// Ends the game, resets the state, and pays out if the player won
function endGame(address player, bool playerWon) internal {
delete playersDeck[player].playersCards; // Clear the player's cards
delete dealersDeck[player].dealersCards; // Clear the dealer's cards
delete availableCards[player]; // Reset the deck
if (playerWon) {
@> payable(player).transfer(2 ether); // Transfer the prize to the player
emit FeeWithdrawn(player, 2 ether); // Emit the prize withdrawal event
}
}

The use of transfer in Solidity imposes a hard gas limit of 2,300. If the recipient is a contract with complex logic in its fallback or receive functions, this transfer may fail even if the contract holds sufficient funds. This could prevent valid payouts.

Impact

Game payouts may fail for valid winners, leading to an inconsistent user experience and potential loss of trust in the system.
The contract may accumulate stuck Ether if transfers fail repeatedly, making funds inaccessible to intended recipients.

Tools Used

manual review

Recommendations

use this instead

+ (bool success, ) = payable(player).call{value: 2 ether}("");
+ require(success, "Transfer failed");
Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!