Blockchain & Cryptocurrency Glossary

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

  • search-icon Clear Definitions
  • search-icon Practical
  • search-icon Technical
  • search-icon Related Terms

Insecure Randomness Vulnerability

2 min read
Pronunciation
[ɪn-sɪ-ˈkjʊr ˈræn-dəm-nəs vʌl-nər-ə-ˈbɪl-ɪ-ti]
Analogy
Think of insecure randomness as using a transparent dice that shows its result before it stops rolling. In a fair game, no player knows what number will appear when the dice lands, ensuring equal chances for everyone. But if someone can see what number will come up before placing their bet (like when blockchain randomness is predictable), or if they can subtly nudge the dice toward their preferred number (like when randomness can be manipulated), they gain an unfair advantage that undermines the entire game.
Definition
A critical security flaw in blockchain applications where the source of randomness used by a smart contract is predictable, manipulable, or biased, allowing attackers to anticipate or influence supposedly random outcomes. This vulnerability particularly affects gambling dApps, NFT minting processes, and random selection mechanisms in DeFi protocols.
Key Points Intro
Insecure randomness vulnerabilities arise from several common implementation mistakes in blockchain applications.
Key Points

Block attributes exploitation: Using future block hashes, timestamps, or miner-controllable values as randomness sources.

On-chain derivation: Generating random values entirely on-chain where all inputs are publicly visible and thus predictable.

Single-source dependency: Relying on a single oracle or randomness provider without verification or aggregation.

Insufficient entropy: Using randomness sources with limited unpredictability or biased distribution patterns.

Example
CryptoCardGame, a blockchain-based collectible card game, used the hash of the next block as a random seed to determine the rarity of cards in purchased packs. A miner discovered this vulnerability and wrote a specialized mining software that would only broadcast blocks that would generate legendary cards for their address. By selectively mining blocks, they extracted over $450,000 worth of rare cards before developers discovered the exploit and implemented a verifiable random function using multiple off-chain entropy sources.
Technical Deep Dive
Secure randomness in blockchain environments is challenging due to the deterministic nature of blockchain execution and the public visibility of all inputs. Several solution patterns address this vulnerability: Commit-reveal schemes require participants to commit to a secret value (by submitting its hash) before the random event, then reveal their original value after all commitments are made, with the combined values serving as the random seed. Verifiable Random Functions (VRFs) use cryptographic techniques to generate random outputs with proofs of correctness that anyone can verify. Multi-party computation (MPC) distributes the randomness generation across multiple parties, requiring a threshold of participants to collude to manipulate the outcome. Chain-agnostic randomness services like Chainlink VRF combine off-chain cryptographic proofs with on-chain verification to provide unpredictable and unbiased random values that cannot be manipulated by miners, users, or the oracle operators themselves.
Security Warning
Applications using block variables (block.timestamp, blockhash, etc.) as randomness sources are inherently vulnerable to miner manipulation. Never use these for high-value randomness. Even seemingly complex derivations of on-chain data can be simulated and predicted by attackers.
Caveat
Truly secure randomness often introduces trade-offs in terms of cost, latency, or complexity. VRF solutions typically require payment per random number generated, while commit-reveal schemes introduce delays and may suffer from participant dropout. Even advanced randomness solutions may be vulnerable if implemented incorrectly or if their security assumptions are violated. No randomness solution is appropriate for all use cases, and the security requirements should match the value at risk.

Insecure Randomness Vulnerability - Related Articles

No related articles for this term.