GHSA-W73W-HHM4-Q25P

Vulnerability from github – Published: 2026-12-01 18:42 – Updated: 2026-12-01 18:42
VLAI
Summary
Forge: RSA multi-prime private keys are read as two-prime keys, and signatures leak a factor of the modulus
Details

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.

Show details on source website

{
  "affected": [
    {
      "database_specific": {
        "last_known_affected_version_range": "\u003c= 1.4.3"
      },
      "package": {
        "ecosystem": "npm",
        "name": "node-forge"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "1.4.4"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2026-140099"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-20",
      "CWE-325"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-12-01T18:42:05Z",
    "nvd_published_at": "2026-11-30T23:17:24Z",
    "severity": "LOW"
  },
  "details": "### Summary\n\n`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.\n\n### Details\n\nRFC 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.\n\nforge\u0027s private-key operation uses the CRT with p and q, so its result is correct modulo p*q but not modulo the remaining primes. For a signature s made this way, s^e equals the encoded message modulo p*q but not modulo n, so gcd(s^e - EM, n) = p*q, where EM is the PKCS#1 encoding of the signed message, which a verifier can compute. One signature therefore splits n into p*q 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.\n\nDecryption with such a key fails, and the signatures don\u0027t 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.\n\nThe 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.\n\n### Patches\nFixed in node-forge 1.4.4.\n\n### Workarounds\nDon\u0027t 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.\n\n### Related\n- RFC 8017, appendix A.1.2 (RSA private key syntax): https://www.rfc-editor.org/rfc/rfc8017#appendix-A.1.2\n- Issue #1143 (RSAPrivateKey version not checked): https://github.com/digitalbazaar/forge/issues/1143\n- 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.\n\n### Proof of concept\n\nGenerate a three-prime key and sign with forge:\n\n    openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 \\\n      -pkeyopt rsa_keygen_primes:3 -out mp3.pem\n\n    var key = forge.pki.privateKeyFromPem(pem);   // \u003c= 1.4.3: loads\n    var md = forge.md.sha256.create();\n    md.update(\u0027hello\u0027);\n    var s = key.sign(md);\n    // the signature doesn\u0027t verify (Node.js crypto.verify() is false), and\n    // gcd(s^e - EM, n), with EM the PKCS#1 v1.5 encoding of SHA-256(\u0027hello\u0027),\n    // is a 1366-bit factor of the 2048-bit n\n    // 1.4.4: privateKeyFromPem() throws \"Cannot read private key. Only\n    // two-prime RSAPrivateKey version 0 is supported.\"\n\nRegression tests are in tests/unit/rsa.js (\"RSAPrivateKey version\").\n\n\n### Impact\n\nApplications 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\u0027s primes, and so the remaining prime(s), to anyone who sees the signature, which reduces the key\u0027s 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.",
  "id": "GHSA-w73w-hhm4-q25p",
  "modified": "2026-12-01T18:42:05Z",
  "published": "2026-12-01T18:42:05Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/digitalbazaar/forge/security/advisories/GHSA-w73w-hhm4-q25p"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-140099"
    },
    {
      "type": "WEB",
      "url": "https://github.com/digitalbazaar/forge/issues/1143"
    },
    {
      "type": "WEB",
      "url": "https://github.com/digitalbazaar/forge/commit/8d1a7bc8ad514e70f85bf5cbe4c60cd52916fdef"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/digitalbazaar/forge"
    },
    {
      "type": "WEB",
      "url": "https://github.com/digitalbazaar/forge/releases/tag/v1.4.4"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N",
      "type": "CVSS_V3"
    }
  ],
  "summary": "Forge: RSA multi-prime private keys are read as two-prime keys, and signatures leak a factor of the modulus"
}



Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Drag nodes to arrange them. Double-click a related vulnerability to open it, or a source to visit its link. The Physics button on the left tunes the layout and the simulation; the legend at the bottom left hides or shows nodes by kind and by sighting type.

Forecast uses a logistic model when the trend is rising, or an exponential decay model when the trend is falling. Fitted via linearized least squares.

Sightings

Author Source Type Date Other

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
Vulnerability timeline

Sightings and recorded dates, grouped by day · UTC

JSON
How durations are calculated

Following the VTEM framework (Black Hat USA 2015), time to patch starts when the vendor or a coordinator was informed, total time to patch at discovery, and disclosure to patch at public disclosure; vendor response time runs from the report to its acknowledgement. Time to exploit and time unpatched start at the earliest discovery or report, falling back to public disclosure. Unpatched time ends at the first recorded patch, or the calculation time when no patch is recorded. Exploitation to patch shows the interval between those two events; a published proof of concept is a public exploit, not exploitation. The method is described in a publication.

Each result shows its source dates. A negative interval means the end event came first; when date-only inputs leave the order open, the result says so. Date-only inputs are approximate. The earliest evidence wins: KEV report dates and sightings are labelled as such. Records describing another vulnerability are listed but never calculated from, and a PoC alone does not establish exploitation. Missing patch evidence does not prove that no patch exists. Filters below change the event list only.

Events included in the timeline

Loading timeline…


    Loading…

    Loading…

    Loading…

    Related by attack behaviour

    Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.