A 12-Year-Old Crypto Bug Just Drained $5.7 Million From Five Wallets

ยท
Listen to this article~5 min
A 12-Year-Old Crypto Bug Just Drained $5.7 Million From Five Wallets

A 12-year-old flaw in the CryptoJS library's random number generator has been linked to $5.7 million in wallet thefts. Learn how this happened and what you can do to stay safe.

Here's a story that should make anyone building on JavaScript sit up and pay attention. A security research firm called Coinspect has traced a series of devastating wallet hacks back to a single, overlooked function inside a popular cryptography library. The culprit? A weak random number generator that's been sitting in CryptoJS for over a decade. The function in question is `CryptoJS.lib.WordArray.random()`. It sounds like something only a developer would care about, but its failure had real, painful consequences. According to Coinspect, this flawed function was quietly responsible for the drain of at least $5.7 million from users of five different crypto wallet applications. That's not a rounding error; that's a life-changing amount of money for the people affected. ### The Problem Hiding in Plain Sight Let's break this down in plain English. When a crypto wallet generates a recovery phrase, it needs a source of true randomness. Think of it like shuffling a deck of cards. If you shuffle poorly, someone can predict the order. If you shuffle perfectly, it's nearly impossible to guess. CryptoJS's `WordArray.random()` was supposed to be that perfect shuffle. It was introduced 12 years ago and quickly became a trusted tool for developers. The problem is that over time, the way it generated randomness became predictable. It wasn't a bug that crashed your app; it was a subtle flaw that made the "random" numbers less random than they should be. ### How a Simple Flaw Led to Massive Losses For a hacker, a predictable random number generator is a goldmine. If you can guess the seed that creates a wallet's recovery phrase, you can recreate the private keys. You don't need to hack a server or trick a user into clicking a link. You just need to calculate the same numbers the wallet did, and the funds are yours. Coinspect's on-chain analysis shows that attackers exploited this exact weakness. They watched the blockchain, spotted wallets that were likely generated with this weak function, and swept them clean. The theft happened in two major sweeps since late May, and the lower bound of the damage is pegged at $5.7 million. The real number is probably higher, as the researchers only counted what they could definitively trace. ### Are You at Risk? Here's What to Look For The scary part is that this isn't a problem with a single app. The flaw affected five different wallet applications, which means developers across the industry were relying on this library without knowing about its hidden weakness. If you're a developer, this is a stark reminder that the libraries you depend on are not infallible. - **Check your dependencies**: If you're using CryptoJS, especially an older version, you need to assess your risk immediately. - **Look for alternatives**: Modern libraries like Web Crypto API offer more robust randomness directly from the browser. - **Audit your keys**: If you generated a wallet years ago with a tool that used CryptoJS, consider moving your funds to a newly generated wallet. ### The Takeaway: Trust, But Verify The crypto world moves fast, and it's easy to trust the tools that have been around for years. But this incident proves that age doesn't equal security. In fact, older code often carries baggage that was acceptable when it was written but is dangerous today. This story isn't just about one library or one set of wallets. It's a wake-up call about the invisible infrastructure that powers the entire digital asset ecosystem. The next time you see a smart contract, a wallet app, or even a simple encryption tool, remember that its security is only as strong as the weakest link in its code. And sometimes, that weakest link has been there since day one, waiting to be discovered by someone with the right skills and the wrong intentions.