CVE-2026-71851: crypto-js Insufficient Entropy in Cryptographic Secret Generation
Summary
CVE-2026-71851: CryptoJS.lib.WordArray.random() in affected versions is not a cryptographically secure random number generator. Affects crypto-js versions < 4.0.0. Fixed in 4.0.0. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
CryptoJS is a widely used JavaScript library that provides cryptographic functions for secure data handling, including hashing and encryption. It is commonly utilized in web applications to ensure data integrity and confidentiality. However, certain versions of the library have a critical vulnerability that affects the randomness of cryptographic secret generation, making it susceptible to attacks.
Vulnerability Detail
The vulnerability arises from the use of CryptoJS.lib.WordArray.random() in versions prior to 4.0.0, which employs a non-cryptographically secure random number generator seeded from Math.random(). This results in insufficient entropy, allowing attackers to enumerate possible outputs and recover sensitive values, such as BIP39 recovery phrases. The issue was introduced in versions 3.1.2-4 and persisted in all 3.x releases except 3.2.0 and 3.2.1. The consequences are severe, as previously generated secrets remain compromised indefinitely, leading to potential financial losses.
How To Fix
Latest published version: 4.2.0 as of 22 Oct 2026
npm install crypto-js@4.2.0
Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.
If you need the minimum change
4.0.0
This is the first release that contains the fix.
npm install crypto-js@4.0.0
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If immediate upgrading is not feasible, consider replacing the randomness generation with the native Web Crypto API or Node.js crypto module. For example, in a Node.js environment, you can use:
const crypto = require('crypto');
const randomBytes =
crypto.
randomBytes(32);
Conclusion
The vulnerability CVE-2026-71851 in the crypto-js library poses a significant risk due to insufficient entropy in cryptographic secret generation. It is crucial for developers to upgrade to version 4.0.0 or later and for users to take necessary precautions to safeguard their assets.
See every vulnerability recorded for crypto-js →
FAQ
The CVSS score of this vulnerability is 9.0, indicating a critical severity level.
You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without requiring any signup.
An attacker can recover sensitive values generated through the affected function, leading to financial losses and compromised security.
No, updating the library does not strengthen previously generated secrets. You must rotate any long-term secrets generated using the vulnerable code.
Wallet users should create a new wallet with a newly generated recovery phrase from a trustworthy source and migrate assets to addresses derived from it.
References
Related vulnerabilities
Recent vulnerabilities recorded for crypto-js.