TwentyOne

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

Dealer's Hand Cannot Be Retrieved

Summary: Dealer's Hand Cannot Be Retrieved

Vulnerability Details: In the current implementation of the TwentyOne contract, it is not possible to reliably retrieve the dealer's hand because the dealer's cards are stored in dealersDeck[player], and this mapping is deleted in the endGame function. As a result, after the game ends, the dealer's hand is permanently removed from the contract's state.

Impact:

  • Players cannot verify the fairness of the game's outcome.

  • Transparency is reduced, which could lead to trust issues between the contract owner and players.

Tools Used: Foundry, remix

Recommendations: Do not delete the dealer's hand in the endGame function. Instead, retain the cards in dealersDeck[player] until the player explicitly starts a new game.

function endGame(address player, bool playerWon) internal {
delete playersDeck[player].playersCards; // Clear the player'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
}
// Do not delete dealer's cards here
}
Updates

Lead Judging Commences

inallhonesty Lead Judge
7 months ago
inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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