CVE-2026-140099 is a low-severity (CVSS 3.7) Improper Input Validation vulnerability in node-forge. A fix is available for node-forge — see the affected versions and patch details below.
Forge: RSA multi-prime private keys are read as two-prime keys, and signatures leak a factor of the modulus
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
How urgent is this, really
Where this sits among everything scored
Real-World Exposure
node-forgeReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects npm packages — download data is not available via public APIs for these ecosystems.
Description
Summary
pki.privateKeyFromPem() and pki.privateKeyFromAsn1() ignore the RSAPrivateKey version and the otherPrimeInfos field, so a multi-prime RSA key is read with only its first two primes. Signatures made with such a key are invalid, and each one reveals a factor of the modulus to anyone who sees it. Fixed in node-forge 1.4.4.
Details
RFC 8017 (A.1.2) allows RSA private keys with more than two primes: version 1, with the extra primes in otherPrimeInfos. node-forge only supports two-prime keys, but pki.privateKeyFromAsn1() in lib/rsa.js (used by pki.privateKeyFromPem(), PKCS#8 and PKCS#12 key parsing) never checked the version, and ASN.1 validation ignores the extra field. A multi-prime key is therefore read as if it were a two-prime key with modulus n, primes p and q, and the CRT values for p and q.
forge's private-key operation uses the CRT with p and q, so its result is correct modulo pq but not modulo the remaining primes. For a signature s made this way, s^e equals the encoded message modulo pq but not modulo n, so gcd(s^e - EM, n) = pq, where EM is the PKCS#1 encoding of the signed message, which a verifier can compute. One signature therefore splits n into pq and the product of the other primes. For a three-prime key (the usual case; OpenSSL with rsa_keygen_primes:3) this reveals the third prime and leaves a two-prime modulus of about two thirds of the size: for a 2048-bit key, a 1366-bit RSA modulus instead of 2048 bits.
Decryption with such a key fails, and the signatures don't verify, so applications that use a multi-prime key with forge see errors immediately. Keys generated by forge, by OpenSSL by default, by Node.js and by most other tools are two-prime and not affected.
The fix rejects RSAPrivateKeys with a version other than 0 or with otherPrimeInfos ("Only two-prime RSAPrivateKey version 0 is supported."). This also rejects two-prime keys with an invalid version, as reported in https://github.com/digitalbazaar/forge/issues/1143.
Patches
Fixed in node-forge 1.4.4.
Workarounds
Don't use multi-prime RSA keys with node-forge. Before loading a key from an untrusted or unknown source, check that its RSAPrivateKey version is 0. Multi-prime keys that were used to sign with node-forge should be replaced, since their signatures reveal a factor of the modulus.
Related
- RFC 8017, appendix A.1.2 (RSA private key syntax): https://www.rfc-editor.org/rfc/rfc8017#appendix-A.1.2
- Issue #1143 (RSAPrivateKey version not checked): https://github.com/digitalbazaar/forge/issues/1143
- Boneh, DeMillo and Lipton, "On the Importance of Checking Cryptographic Protocols for Faults" (Eurocrypt 1997): the same gcd recovers factors from a faulty CRT signature.
Proof of concept
Generate a three-prime key and sign with forge:
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 \
-pkeyopt rsa_keygen_primes:3 -out mp3.pem
var key = forge.pki.privateKeyFromPem(pem); // <= 1.4.3: loads
var md = forge.md.sha256.create();
md.update('hello');
var s = key.sign(md);
// the signature doesn't verify (Node.js crypto.verify() is false), and
// gcd(s^e - EM, n), with EM the PKCS#1 v1.5 encoding of SHA-256('hello'),
// is a 1366-bit factor of the 2048-bit n
// 1.4.4: privateKeyFromPem() throws "Cannot read private key. Only
// two-prime RSAPrivateKey version 0 is supported."
Regression tests are in tests/unit/rsa.js ("RSAPrivateKey version").
Impact
Applications that load a multi-prime RSA private key with node-forge and sign with it are affected. Each signature reveals the product of two of the key's primes, and so the remaining prime(s), to anyone who sees the signature, which reduces the key's security (for a 2048-bit three-prime key, to that of a 1366-bit RSA key). The signatures are invalid and decryption fails, so the problem is visible to the application. Two-prime keys, which nearly all tools generate, are not affected.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 📦npm | node-forge | all versions | 1.4.4npm install node-forge@1.4.4 |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for node-forge, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update node-forge to 1.4.4 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2026-140099 is resolved across your whole dependency graph.
Workarounds
If you can't upgrade right away: gate or disable the affected feature, validate untrusted input at the boundary, and avoid passing attacker-controlled data into the vulnerable path. O3's runtime protection blocks exploitation in production as an interim safeguard until the upgrade lands.
Frequently Asked Questions
Is CVE-2026-140099 in your dependencies?
Find it across npm, including transitive dependencies.