The call()
function in the TwentyOne
smart contract uses a weak pseudorandom number generator (PRNG) to determine the dealer's threshold. This randomness is derived from a combination of block.timestamp
, msg.sender
, and block.prevrandao
. Due to the predictability and manipulability of these inputs, the randomness used to calculate the dealer’s stand threshold can be influenced or predicted by an attacker, potentially compromising the fairness of the game.
The dealer’s threshold is determined using the following line of code:
This calculation combines block.timestamp
(which can be manipulated by miners within a small range), msg.sender
(the address of the player, which is easily known and predictable), and block.prevrandao
(the hash of the previous block’s randomness, which miners can influence). As a result, an attacker could potentially predict or control the outcome of the threshold value, influencing when the dealer will stop drawing cards.
The impact of this vulnerability is significant because it directly affects the dealer’s decision-making process in the game. The dealer’s threshold determines when they stop drawing cards, which is a key factor in determining the game’s outcome. If an attacker can predict this threshold, they could adjust their strategy to exploit it, giving them an unfair advantage. For example, the attacker could decide when to stand based on the dealer's likely actions, significantly skewing the game in their favor.
Slither
Use Chainlink VRF to handle random number generation
Randomness Manipulation: The randomness mechanism relies on block.timestamp, msg.sender, and block.prevrandao, which may be predictable in certain scenarios. Consider using Chainlink VRF or another oracle for more secure randomness.
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.