keypair is a a RSA PEM key generator written in javascript. keypair implements a lot of cryptographic primitives on its own or by borrowing from other libraries where possible, including node-forge. An issue was discovered where this library was generating identical RSA keys used in SSH. This would mean that the library is generating identical P, Q (and thus N) values which, in practical terms, is impossible with RSA-2048 keys. Generating identical values, repeatedly, usually indicates an issue with poor random number generation, or, poor handling of CSPRNG output. Issue 1: Poor random number generation (GHSL-2021-1012). The library does not rely entirely on a platform provided CSPRNG, rather, it uses it's own counter-based CMAC approach. Where things go wrong is seeding the CMAC implementation with "true" random data in the function defaultSeedFile. In order to seed the AES-CMAC generator, the library will take two different approaches depending on the JavaScript execution environment. In a browser, the library will use window.crypto.getRandomValues(). However, in a nodeJS execution environment, the window object is not defined, so it goes down a much less secure solution, also of which has a bug in it. It does look like the library tries to use node's CSPRNG when possible unfortunately, it looks like the crypto object is null because a variable was declared with the same name, and set to null. So the node CSPRNG path is never taken. However, when window.crypto.getRandomValues() is not available, a Lehmer LCG random number generator is used to seed the CMAC counter, and the LCG is seeded with Math.random. While this is poor and would likely qualify in a security bug in itself, it does not explain the extreme frequency in which duplicate keys occur. The main flaw: The output from the Lehmer LCG is encoded incorrectly. The specific [line][https://github.com/juliangruber/keypair/blob/87c62f255baa12c1ec4f98a91600f82af80be6db/index.js#L1008] with the flaw is: b.putByte(String.fromCharCode(next & 0xFF)) The definition of putByte is util.ByteBuffer.prototype.putByte = function(b) {this.data += String.fromCharCode(b);};. Simplified, this is String.fromCharCode(String.fromCharCode(next & 0xFF)). The double String.fromCharCode is almost certainly unintentional and the source of weak seeding. Unfortunately, this does not result in an error. Rather, it results most of the buffer containing zeros. Since we are masking with 0xFF, we can determine that 97% of the output from the LCG are converted to zeros. The only outputs that result in meaningful values are outputs 48 through 57, inclusive. The impact is that each byte in the RNG seed has a 97% chance of being 0 due to incorrect conversion. When it is not, the bytes are 0 through 9. In summary, there are three immediate concerns: 1. The library has an insecure random number fallback path. Ideally the library would require a strong CSPRNG instead of attempting to use a LCG and Math.random. 2. The library does not correctly use a strong random number generator when run in NodeJS, even though a strong CSPRNG is available. 3. The fallback path has an issue in the implementation where a majority of the seed data is going to effectively be zero. Due to the poor random number generation, keypair generates RSA keys that are relatively easy to guess. This could enable an attacker to decrypt confidential messages or gain authorized access to an account belonging to the victim.
CVE-2021-41117
“—” beside the score: it is equal to NVD's CVSS score.
Score 8.7 from GitHub Security Advisory (severity: HIGH) published 2021-10-11. NVD baseline CVSS 8.7; sources differ by 0.0.
Also known asEUVD-2021-2147 (ENISA EUVD) · GHSA-3f99-hvg4-qjwj (GitHub Security Advisories)Source: ENISA EUVD
- Public exploit or proof-of-concept code is available
A fix is available — apply it.
- CVSS v3
- 8.7
- EG Score
- 8.7HIGHmedium confidence
- EG Risk
- 55EG Risk 55/100
EG Risk is EchelonGraph's 0–100 priority score. It fuses impact severity (EG Severity, the CVSS base score, never the KEV-floored or EPSS-lifted EG Score) with real-world exploitation and automatability, under weights EchelonGraph set by hand, so you can rank equal-severity CVEs and fix the most dangerous first. Higher = act sooner.
How it’s computed (value × EchelonGraph’s weight)Severity87% × 45%Impact severity (EG Severity): CVSS 8.7 of 10. Never the KEV-floored or EPSS-lifted EG Score.Exploitation40% × 40%EchelonGraph's fixed weight for EG-KEV Tier 3 (Elevated): a constant, not a probability.Automatability0% × 15%CISA's BOD 26-04 default: no one has published Automatable for this CVE, and CISA treats it as “no” for a CVE not in KEV.SSVC (CISA's decision table, applied by EchelonGraph): Track at low, Track* at medium and Attend at high mission impact.Exploitation public PoC (exploit code on record) · Automatable no (CISA's BOD 26-04 default) · Technical impact total (CISA's BOD 26-04 default). EchelonGraph holds no SSVC assessment of this CVE from CISA: none of these inputs is from Vulnrichment. EchelonGraph applied CISA's decision table to them; CISA publishes SSVC inputs and the table, not a decision for each CVE.Action: A fix is available. Apply it within your standard update timelines at low or medium mission impact and sooner than that at high. - EPSS PROB
- 3.2%
- EPSS %ILE
- 88th
- KEV
- Not listed
What the EG score is made of (scorer v4.0: the three questions the 0–10 score mixes, published apart · methodology)
The EG score (8.7): severity, escalated by confirmed exploitation. This CVE's 8.7 is its impact severity (EG Severity), not escalated.
- EG Severity
- 8.7 HIGHCVSS-B, impact only: no KEV listing, EPSS or EG-KEV tier raises it.GitHub Security Advisory CVSS
- EG Likelihood
- 3.2% within 30 daysSource: FIRST EPSS (model v2026.06.15, score date 2026-10-31). FIRST's exploitation probability, not an EchelonGraph model.
- Confirmed exploitation
- None on record (CISA KEV, EG-KEV Tier 1)Reported apart from the likelihood: an observed fact, not a probability.
- EG Priority
- SSVC Track* at medium mission impactTrack at low, Track* at medium and Attend at high mission impact.CISA BOD 26-04: 14 days if the affected system is publicly exposed; Fix on system upgrade if it is not.Each input and its source, and whom BOD 26-04 binds: the SSVC and BOD 26-04 blocks below.
SSVC (CISA's decision table, applied by EchelonGraph)Track at low, Track* at medium and Attend at high mission impact.
A fix is available. Apply it within your standard update timelines at low or medium mission impact and sooner than that at high.
Exploitation public PoC (exploit code on record) · Automatable no (CISA's BOD 26-04 default) · Technical impact total (CISA's BOD 26-04 default). EchelonGraph holds no SSVC assessment of this CVE from CISA: none of these inputs is from Vulnrichment. EchelonGraph applied CISA's decision table to them; CISA publishes SSVC inputs and the table, not a decision for each CVE. Mission impact is CISA's Mission & Well-being decision point, and only you can judge it. CISA's table makes it high when Mission Prevalence is Essential — the vulnerable component "directly provides capabilities that constitute at least one MEF for at least one entity" (MEF: mission essential function) — or when Public Well-Being Impact is Irreversible: "multiple fatalities are likely", the cyber-physical system "is likely lost or destroyed", "extreme or serious externalities" are imposed on other parties, or social systems such as elections or the financial grid "are destabilized and potentially collapse". CISA's decision table
BOD 26-04 (CISA's remediation timeline, Table 1)14 days if the affected system is publicly exposed; Fix on system upgrade if it is not.
The score's inputs: In CISA KEV no (CISA's KEV catalog) · Automatable no (CISA's BOD 26-04 default) · Technical impact total (CISA's BOD 26-04 default). Where an input reads “CISA's BOD 26-04 default”, no one has published it for this CVE, and CISA's implementation guidance says: “If “Automatable” and “Technical Impact” information items about a CVE ID are not available and the CVE ID is not in the KEV Catalog, CISA will treat its values as “no” and “total,” respectively, until CISA or a third party provides metadata about the CVE ID. CISA will always provide the Vulnrichment data for a CVE ID listed in the KEV Catalog.” Whether your system is publicly exposed is yours to answer. BOD 26-04 binds US Federal Civilian Executive Branch agencies; for anyone else it is CISA's published timeline, a reference rather than an obligation. The directive · how EchelonGraph applies it
Published
October 11, 2021
Last Modified
November 21, 2024
Advisory Details (2)
Auto-updated Sep 1, 2026GHSL-2021-1012: Poor random number generation in keypair - CVE-2021-41117 | GitHub Security Lab
https://securitylab.github.com/advisories/GHSL-2021-1012-keypair/Insecure random number generation · Advisory · juliangruber/keypair · GitHub
https://github.com/juliangruber/keypair/security/advisories/GHSA-3f99-hvg4-qjwjPatch Availability(1)
| Vendor / Ecosystem | Fix (by version range) / Patch | Released | Source |
|---|---|---|---|
| npm | keypair @ 1.0.4 (fixes < 1.0.4) | — | ghsa |
Patches are aggregated from vendor advisories (Red Hat, Microsoft, Cisco, GitHub) and package ecosystems (OSV, GHSA). Multiple rows for the same upstream release have been deduplicated.
Affected Packages
(1 across 1 ecosystem)
npm(1)
| Package | Vulnerable range | Fix by version range | Dependents |
|---|---|---|---|
| keypair | — |
| — |
Weakness Classification(1)
MITRE Common Weakness Enumeration — the root-cause categories this CVE belongs to.
Data Freshness Timeline
(refreshed 9× in last 7d / 36× in last 30d)
Each row is a time one of our pipelines fetched, updated or re-scored this CVE. For example, "NVD update" means NVD published or revised its analysis for this CVE; "MITRE cvelistV5" means we ingested or refreshed it from the CNA feed. An arrow marks a change the record states ("CVSS v3 → 9.1"); EPSS and GHSA rows show the values recorded at that time, not what changed (EPSS values are rounded; hover one for the exact figures). Most recent first.
Showing the most recent 96 of 209 refreshes on record for this CVE.
A repeat, a row identical to one the same pipeline wrote less than 10 seconds earlier, is not a separate refresh and is not counted. 4 repeat rows among the latest 100 are merged into the row they repeat. The 113 oldest rows on record are not shown and were not checked, so the counts can still include repeats.
- 2026-11-01 08:30 UTCGHSA enrichmentGHSA-3f99-hvg4-qjwj · GitHub severity HIGH · GitHub CVSS 8.7
- 2026-11-01 08:30 UTCEG score recompute
- 2026-10-31 16:29 UTCEPSS rescoreEPSS 3.2% · 88th percentile
- 2026-10-30 16:30 UTCEPSS rescoreEPSS 3.2% · 88th percentile
- 2026-10-29 16:29 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-10-28 16:28 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-10-28 06:41 UTCEG score recompute
- 2026-10-27 16:28 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-10-26 16:28 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-10-25 18:22 UTCEG score recompute
- 2026-10-25 16:28 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-10-24 16:29 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-10-23 16:28 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-10-22 16:29 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-10-21 16:28 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-10-21 09:00 UTCEG score recompute
- 2026-10-20 16:28 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-10-19 16:28 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-10-18 16:28 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-10-18 08:54 UTCEG score recompute
- 2026-10-17 20:25 UTCOSV refresh
- 2026-10-17 16:29 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-10-16 16:34 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-10-15 16:28 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-10-14 16:29 UTCEPSS rescoreEPSS 3.1% · 87th percentile
Show 71 moreShow fewer
- 2026-10-13 16:28 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-10-12 19:10 UTCEG score recompute
- 2026-10-12 16:30 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-10-11 23:35 UTCEG score recompute
- 2026-10-11 13:44 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-10-10 19:56 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-10-09 20:04 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-10-08 16:40 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-10-07 23:45 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-10-06 15:14 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-10-05 17:40 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-10-03 14:22 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-10-02 16:23 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-10-01 19:46 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-09-30 15:41 UTCEG score recompute
- 2026-09-30 15:00 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-09-29 15:15 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-09-28 13:47 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-09-27 13:41 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-09-26 15:54 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-09-26 00:21 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-09-25 14:45 UTCOSV refresh
- 2026-09-24 14:00 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-09-23 13:44 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-09-22 14:44 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-09-21 20:28 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-09-20 20:13 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-09-19 15:38 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-09-18 19:23 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-09-17 19:23 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-09-16 14:05 UTCEPSS rescoreEPSS 3.1% · 87th percentile
- 2026-09-15 03:06 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-09-12 14:57 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-09-11 14:49 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-09-11 09:33 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-09-08 21:56 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-09-07 15:58 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-09-06 13:45 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-09-06 05:52 UTCOSV refresh
- 2026-09-05 15:25 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-09-04 13:57 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-09-04 05:03 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-09-02 14:09 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-09-01 13:50 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-09-01 03:33 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-08-30 19:14 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-08-30 01:19 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-08-28 21:37 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-08-27 14:22 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-08-26 14:43 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-08-25 13:46 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-08-24 14:13 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-08-23 00:16 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-08-21 23:46 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-08-20 22:52 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-08-19 17:26 UTCOSV refresh
- 2026-08-19 17:01 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-08-18 13:45 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-08-17 13:44 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-08-16 14:53 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-08-16 02:11 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-08-15 01:27 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-08-13 21:57 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-08-12 13:48 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-08-11 13:38 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-08-09 13:44 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-08-08 16:33 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-08-07 16:24 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-08-06 13:44 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-08-05 19:14 UTCEPSS rescoreEPSS 3.1% · 86th percentile
- 2026-08-04 12:57 UTCOSV refresh
Publicly available exploits
(1 reference)Public exploit code is referenced for this CVE (1 GitHub PoC). Defenders should treat patch urgency accordingly.
- GitHub PoCbadkeys/keypairvulnPublished May 15, 2022
Private keys generated with vulnerable keypair versions (CVE-2021-41117)
Open source ↗
Related CVEs(same CWE)
Frequently asked(5)
What is CVE-2021-41117?
When was the CVE record for CVE-2021-41117 published?
Is CVE-2021-41117 actively exploited?
What is the CVSS score of CVE-2021-41117?
How do I remediate CVE-2021-41117?
Dependency Blast Radius
See which npm, PyPI, Go, and Maven packages are affected by CVE-2021-41117
Is Your Infrastructure Affected by CVE-2021-41117?
EchelonGraph automatically scans your cloud infrastructure and maps CVE exposure using blast radius analysis.