Anyone can view the players' and the dealer's hands. This is a potential cheating behavior
https://github.com/Cyfrin/2024-11-TwentyOne/blob/a4429168302722d14a5e5996d25d6fc5be22a899/src/TwentyOne.sol#L175-L186
As we can see above, the function is public. Although the view modifier restricts state changes, it can still be called freely to view the players' and dealer's hands.
If a player calls the getDealerCards
function and passes in the dealer's address, they will be able to see the dealer's hand. The player can then decide whether to hit based on the value of the dealer's hand.
If the dealer calls the getPlayerCards
function, they can know whether the player's hand value is greater than their own, and then manipulate the outcome of the game
Manual inspection
Implement access control restrictions for these two functions
You can design the game logic to reveal the hands only at specific stages, such as after the game ends or once all players have made their decisions. For example, reveal all hands after the player has completed their actions, or reveal the dealer's cards only after the dealer's turn
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.