Quick answers
- Is CVE-2021-41117 exploited in the wild?
- No. Junglewise Threat Intelligence has no report of CVE-2021-41117 being exploited in the wild.
- How severe is CVE-2021-41117?
- Low severity, with a CVSS score of 3.1, published 11 October 2021.
- Which products and versions are affected?
- keypair (npm) SEMVER:introduced=0,fixed=1.0.4.
- Is there a fix for CVE-2021-41117?
- Yes. keypair (npm): upgrade to 1.0.4 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
- How is CVE-2021-41117 attacked?
- It is attacked over the network, in a software library.
- Am I affected by CVE-2021-41117?
- Check whether you run keypair (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.
How to fix
- keypair (npm): upgrade to 1.0.4 or later
npm install keypair@1.0.4
Technical details
The keypair library (versions <= 1.0.3) suffers from multiple PRNG weaknesses, primarily affecting Node.js environments. First, a variable shadowing bug causes the library to fail to detect the native Node.js 'crypto' module, falling back to an insecure Lehmer LCG seeded by Math.random(). Second, a coding error in the fallback path uses a double 'String.fromCharCode' conversion (String.fromCharCode(String.fromCharCode(next & 0xFF))), which results in approximately 97% of the entropy seed bytes being set to zero. This drastically reduces the keyspace, leading to the generation of identical or easily guessable RSA keys. Attackers can exploit this to perform key recovery attacks, decrypting traffic or impersonating users. The issue is fixed in version 1.0.4 by correctly requiring the crypto module and fixing the encoding logic.
Affected products
- juliangruber keypair <= 1.0.3
Identifiers
- CVE-2021-41117
- GHSA-3f99-hvg4-qjwj
Timeline
- 2021-09-30: disclosed: Reported to maintainer by GitHub Security Lab
- 2021-10-11: patched: Version 1.0.4 released
- 2021-10-11: advisory