TwentyOne

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

The dealer wins when his/her hand is equal to player`s hand .

Summary

The current implementation of the call function in the game logic introduces an unfair advantage for the dealer, violating standard blackjack rules.

Vulnerability Details

In the description of this game is written "The game involves a player competing against a dealer, with standard blackjack rules applied." The rule is when the dealer's hand value equals the player's hand value, it leads to a tie (push) rather than allowing the dealer to win. In the case of a tie (“push” or “standoff”), bets are returned without adjustment.

There is no check to determine if the dealer's hand value equals the player's hand value.

// Determine the winner
if (dealerHand > 21) {
emit PlayerWonTheGame(
"Dealer went bust, players winning hand: ",
playerHand
);
endGame(msg.sender, true);
} else if (playerHand > dealerHand) {
emit PlayerWonTheGame(
"Dealer's hand is lower, players winning hand: ",
playerHand
);
endGame(msg.sender, true);
}
else {
emit PlayerLostTheGame(
"Dealer's hand is higher, dealers winning hand: ",
dealerHand
);
endGame(msg.sender, false);
}

Impact

This check omission is significant because it violates standard blackjack rules and potentially creates an unfair advantage for the dealer.

Tools Used

Manual code review.

Recommendations

Apply this code:

// Determine the winner
if (dealerHand > 21) {
emit PlayerWonTheGame(
"Dealer went bust, players winning hand: ",
playerHand
);
endGame(msg.sender, true);
} else if (playerHand > dealerHand) {
emit PlayerWonTheGame(
"Dealer's hand is lower, players winning hand: ",
playerHand
);
endGame(msg.sender, true);
}
+ else if (playerHand == dealerHand) {
+ emit PushHappened("Push!!!!", dealerHand,playerHand);
+ payable(msg.sender).transfer(1 ether);
+ }
else {
emit PlayerLostTheGame(
"Dealer's hand is higher, dealers winning hand: ",
dealerHand
);
endGame(msg.sender, false);
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Tie case

Support

FAQs

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