sm-crypto npm Package: Predictable SM2 Key Generation Vulnerability
An early warning has been issued regarding the sm-crypto npm package, which appears to generate SM2 private keys and signing ephemeral scalars using a predictable random number generator (RNG) in Node.js. This makes the keys vulnerable to prediction attacks.
What happened
The sm-crypto npm package version 0.4.0 is under investigation for using a predictable RNG for SM2 key generation. The default RNG implementation reportedly combines Math.random with the wall clock, which can lead to predictable outputs. This vulnerability could allow attackers to potentially predict SM2 private keys and ephemeral scalars generated by the package.
Professional software engineers are advised to avoid using the sm-crypto package for generating SM2 keys until a fix is released. For more detailed information, consult the primary source at [GHSA-vh45-f885-3848](https://github.com/advisories/GHSA-vh45-f885-3848).
As this is an early warning, the full extent of the vulnerability and any potential exploits are still under investigation. Engineers should stay updated with the latest advisories and security patches.
How 0Day mitigates this
sm-crypto is anywhere in your dependency tree, the engineers who own the affected repositories get a push alert the moment it is flagged — no manual audit to remember to run.Read how this differs from waiting on a scanner to catch a known advisory, or see the exact, read-only access 0Day needs to do this for an organization.