sm-crypto provides JavaScript implementations of the Chinese cryptographic algorithms SM2, SM3, and SM4. Prior to 0.5.0, the default no-argument sm2.generateKeyPairHex() path in Node.js uses the module-wide SecureRandom instance in src/sm2/utils.js, supplied by jsbn@1.1.0, which seeds an ARC4 stream from Math.random() and new Date().getTime() because window.crypto.getRandomValues is unavailable even though globalThis.crypto exists. An attacker who can observe the process's Math.random() outputs and estimate the key-generation time can reconstruct the seed, recover generated SM2 private keys, and predict signing ephemeral scalars used to forge signatures. This issue is fixed in version 0.5.0.
Security readout for executives and security teams
Plain-English summary
Affected Node.js applications may create guessable SM2 private keys and signing values because sm-crypto used weak randomness. An attacker meeting the observation and timing prerequisites could recover private keys or forge signatures, threatening confidentiality and trust in signed data. Version 0.5.0 fixes the issue.
Executive priority
Treat as an urgent cryptographic remediation where affected Node.js usage is confirmed. Prioritize systems whose SM2 keys protect sensitive data, authenticate services, or authorize high-impact transactions. Upgrade promptly, then assess historical keys and signatures; updating the package alone does not restore trust in previously exposed private keys.
Technical view
Before sm-crypto 0.5.0, no-argument sm2.generateKeyPairHex() in Node.js used jsbn's ARC4-based generator, seeded from Math.random() and wall-clock time. If an attacker observes relevant Math.random() outputs and estimates generation time, they may reconstruct the seed, recover SM2 private keys, and predict signing ephemeral scalars.
Likely exposure
Exposure is limited to Node.js deployments using sm-crypto versions below 0.5.0 and the default no-argument SM2 key-generation path. Keys and signatures produced through that weak module-wide random generator may require investigation. Browser behavior and callers supplying their own randomness are not established as affected by the bundle.
Exploitation context
The CVSS 3.1 score is 9.1, reflecting remote impact without required privileges or user interaction. Exploitation nevertheless depends on observing process Math.random() outputs and estimating key-generation time. The bundle marks this CVE as absent from KEV and provides no evidence of active exploitation.
Researcher notes
CWE-338 applies because security-sensitive values came from an insufficiently random generator. The documented failure chain is Node.js fallback to jsbn@1.1.0, ARC4 state seeded by Math.random() and current time, followed by use for SM2 keys and signing scalars. The supplied evidence does not quantify exploit prevalence or confirm attacks.
Mitigation direction
Upgrade sm-crypto to version 0.5.0 or later.
Identify Node.js services using affected sm-crypto versions.
Review uses of the no-argument sm2.generateKeyPairHex() path.
Assess and rotate SM2 private keys potentially generated under affected conditions.
Review trust in signatures created with potentially exposed keys.
Validation and detection
Confirm installed and locked sm-crypto versions are 0.5.0 or later.
Search application code for no-argument sm2.generateKeyPairHex() calls.
Verify whether affected calls executed in Node.js environments.
Inventory keys and signatures generated before remediation.
Confirm replacement keys no longer depend on the affected generator.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cwe · low confidence lookup
CWE-338: Exact CWE lookup
Use the exact CWE identifier as the starting point before reviewing related ATT&CK behavior. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
1CVSS vectors
3Timeline events
1ADP providers
3Source links
SSVC decision data
CISA-ADPCISA Coordinator
Timestamp
Version
2.0.3
Exploitation: noneAutomatable: yesTechnical Impact: total
CVSS vector scores
1 official score
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.
CWE links open Glexia weakness intelligence pages with official CWE context, developer remediation guidance, and related CVE mappings.
CWE-338 · source CWE mapping
Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG)
Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG) represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.