CVE-2026-118781
Forge: Denial of Service via infinite loop in BigInteger.modInverse() with negative input (incomplete fix of CVE-2026-33891)
Forge (also called node-forge) is a native implementation of Transport Layer Security in JavaScript. Prior to 1.4.1, the affected implementation used BigInteger.prototype.modInverse(), bnModInverse(), lib/jsbn.js, RSA public exponent e to process the relevant input or security decision. node-forge's bundled jsbn implementation entered an infinite loop when BigInteger.prototype.modInverse() received a negative value or modulus. An attacker who could control the RSA public exponent passed to key generation, or a direct modInverse() operand, could block the Node.js event loop at full CPU. Parsed DER, PEM, JWK, PKCS#12, X.509, and TLS values are unsigned and cannot trigger this issue. This issue is fixed in version 1.4.1.
Attack profile
How easy it is to exploit
- Attack vector
- Local
- Complexity
- High
- Privileges needed
- None
- User interaction
- None
What an attacker can affect
- Confidentiality
- None
- Integrity
- None
- Availability
- Low
Exploit likelihood
What each source reports
CVE List Score used
2.9
Forge: Denial of Service via infinite loop in BigInteger.modInverse() with negative input (incomplete fix of CVE-2026-33891)
Forge (also called node-forge) is a native implementation of Transport Layer Security in JavaScript. Prior to 1.4.1, the affected implementation used BigInteger.prototype.modInverse(), bnModInverse(), lib/jsbn.js, RSA public exponent e to process the relevant input or security decision. node-forge's bundled jsbn implementation entered an infinite loop when BigInteger.prototype.modInverse() received a negative value or modulus. An attacker who could control the RSA public exponent passed to key generation, or a direct modInverse() operand, could block the Node.js event loop at full CPU. Parsed DER, PEM, JWK, PKCS#12, X.509, and TLS values are unsigned and cannot trigger this issue. This issue is fixed in version 1.4.1.
- Record
CVE-2026-118781- CVSS 3.1
- 2.9 Low
CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L - Weakness
- CWE-835
- Updated
- 2026-11-02
EUVDEUVD-2026-113339
2.9
Forge (also called node-forge) is a native implementation of Transport Layer Security in JavaScript. Prior to 1.4.1, the affected implementation used BigInteger.prototype.modInverse(), bnModInverse(), lib/jsbn.js, RSA public exponent e to process the relevant input or security decision. node-forge's bundled jsbn implementation entered an infinite loop when BigInteger.prototype.modInverse() received a negative value or modulus. An attacker who could control the RSA public exponent passed to key generation, or a direct modInverse() operand, could block the Node.js event loop at full CPU. Parsed DER, PEM, JWK, PKCS#12, X.509, and TLS values are unsigned and cannot trigger this issue. This issue is fixed in version 1.4.1.
- Record
EUVD-2026-113339- CVSS 3.1
- 2.9 Low
CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L - Updated
- 2026-11-02
GitHub AdvisoriesGHSA-h6cr-wjv9-3cpp
2.9
Forge: Denial of Service via infinite loop in BigInteger.modInverse() with negative input (incomplete fix of CVE-2026-33891)
Summary
BigInteger.prototype.modInverse() in node-forge's bundled jsbn library enters an infinite loop when the value or the modulus is negative, for example when a negative public exponent is passed to forge.pki.rsa.generateKeyPair(). This is an incomplete fix of CVE-2026-33891 (GHSA-5m6q-g25r-mvwx), which handled only a zero value. Fixed in node-forge 1.4.1.
Details
bnModInverse() (lib/jsbn.js, exposed as forge.jsbn.BigInteger.prototype.modInverse) implements the binary extended Euclidean algorithm (Handbook of Applied Cryptography, Algorithm 14.61), which is defined for positive integers. With a negative operand the loop cannot terminate: rShiftTo is an arithmetic shift, so a negative value never moves towards zero, and the loop's exit condition (u reaching zero) is never met. The calling thread spins at 100% CPU indefinitely; in Node.js this blocks the event loop. Memory does not grow.
node-forge 1.4.0 fixed CVE-2026-33891 (GHSA-5m6q-g25r-mvwx) by returning zero early when this.signum() == 0, although its changelog describes the check as "<= 0". Negative values were not covered, and a negative modulus was never handled. Every negative input that did terminate already returned zero.
Within node-forge, RSA key generation is the only path to a negative operand: the caller's public exponent e becomes BigInteger.fromInt(e), and state.e.modInverse(state.phi) is called with it. gcd() works on absolute values, so the coprimality checks pass and the loop is reached. Any exponent other than 3 or 65537 uses the pure JavaScript implementation, even when forge.options.usePureJavaScript is not set. RFC 8017, Section 3.1 requires the RSA public exponent to be at least 3.
Values that node-forge parses (DER, PEM, JWK, PKCS#12, X.509, TLS) are always read as unsigned integers and cannot produce a negative operand.
The fix makes modInverse() return zero when the value or the modulus is zero or negative, as it already does when no inverse exists. Results for positive inputs are unchanged.
This issue was reported by wzc.
Patches
Fixed in node-forge 1.4.1. modInverse() now returns zero when the value or the modulus is zero or negative.
Workarounds
- Pass only fixed, valid RSA public exponents (e.g. 65537) to key generation, or validate caller-supplied exponents first: an odd integer
>= 3. - Do not call
BigInteger#modInverse()with negative operands. Reduce the value modulo a positive modulus first (x.mod(m).modInverse(m)).
Proof of concept
A negative public exponent passed to RSA key generation never returns (also with the callback form and with createKeyPairGenerationState() / stepKeyPairGenerationState()):
var forge = require('node-forge');
forge.pki.rsa.generateKeyPair({bits: 256, e: -1}); // hangs at 100% CPU
Calling modInverse() directly with a negative value or modulus hangs the same way:
var BigInteger = forge.jsbn.BigInteger;
new BigInteger('-1').modInverse(new BigInteger('7')); // hangs
new BigInteger('3').modInverse(new BigInteger('-7')); // hangs
With the fix, these calls return zero. The regression tests are in tests/unit/jsbn.js.
Impact
Applications are affected only if they:
- pass an untrusted value as the RSA public exponent
etoforge.pki.rsa.generateKeyPair(),forge.pki.rsa.createKeyPairGenerationState()orforge.pki.rsa.stepKeyPairGenerationState(), or - call
forge.jsbn.BigInteger#modInverse()directly with negative values derived from untrusted input.
An attacker who can supply such a value makes the call hang indefinitely at 100% CPU, which blocks the Node.js event loop (denial of service). Keys and other data parsed by node-forge (DER, PEM, JWK, PKCS#12, X.509, TLS) cannot trigger this issue, and the documented usage of key generation passes a constant exponent (65537). There is no effect on confidentiality or integrity.
- Record
GHSA-h6cr-wjv9-3cpp- CVSS 3.1
- 2.9 Low
CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L - Weakness
- CWE-835
- Updated
- 2026-11-02
NVD
2.9
Forge (also called node-forge) is a native implementation of Transport Layer Security in JavaScript. Prior to 1.4.1, the affected implementation used BigInteger.prototype.modInverse(), bnModInverse(), lib/jsbn.js, RSA public exponent e to process the relevant input or security decision. node-forge's bundled jsbn implementation entered an infinite loop when BigInteger.prototype.modInverse() received a negative value or modulus. An attacker who could control the RSA public exponent passed to key generation, or a direct modInverse() operand, could block the Node.js event loop at full CPU. Parsed DER, PEM, JWK, PKCS#12, X.509, and TLS values are unsigned and cannot trigger this issue. This issue is fixed in version 1.4.1.
- Record
CVE-2026-118781- CVSS 3.1
- 2.9 Low
CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L - Weakness
- CWE-835
- Updated
- 2026-11-02
OSV
2.9
Forge: Denial of Service via infinite loop in BigInteger.modInverse() with negative input (incomplete fix of CVE-2026-33891)
Forge (also called node-forge) is a native implementation of Transport Layer Security in JavaScript. Prior to 1.4.1, the affected implementation used BigInteger.prototype.modInverse(), bnModInverse(), lib/jsbn.js, RSA public exponent e to process the relevant input or security decision. node-forge's bundled jsbn implementation entered an infinite loop when BigInteger.prototype.modInverse() received a negative value or modulus. An attacker who could control the RSA public exponent passed to key generation, or a direct modInverse() operand, could block the Node.js event loop at full CPU. Parsed DER, PEM, JWK, PKCS#12, X.509, and TLS values are unsigned and cannot trigger this issue. This issue is fixed in version 1.4.1.
- Record
CVE-2026-118781- CVSS 3.1
- 2.9 Low
CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L - Weakness
- CWE-835
- Updated
- 2026-11-02
OSVGHSA-h6cr-wjv9-3cpp
2.9
Forge: Denial of Service via infinite loop in BigInteger.modInverse() with negative input (incomplete fix of CVE-2026-33891)
Summary
BigInteger.prototype.modInverse() in node-forge's bundled jsbn library enters an infinite loop when the value or the modulus is negative, for example when a negative public exponent is passed to forge.pki.rsa.generateKeyPair(). This is an incomplete fix of CVE-2026-33891 (GHSA-5m6q-g25r-mvwx), which handled only a zero value. Fixed in node-forge 1.4.1.
Details
bnModInverse() (lib/jsbn.js, exposed as forge.jsbn.BigInteger.prototype.modInverse) implements the binary extended Euclidean algorithm (Handbook of Applied Cryptography, Algorithm 14.61), which is defined for positive integers. With a negative operand the loop cannot terminate: rShiftTo is an arithmetic shift, so a negative value never moves towards zero, and the loop's exit condition (u reaching zero) is never met. The calling thread spins at 100% CPU indefinitely; in Node.js this blocks the event loop. Memory does not grow.
node-forge 1.4.0 fixed CVE-2026-33891 (GHSA-5m6q-g25r-mvwx) by returning zero early when this.signum() == 0, although its changelog describes the check as "<= 0". Negative values were not covered, and a negative modulus was never handled. Every negative input that did terminate already returned zero.
Within node-forge, RSA key generation is the only path to a negative operand: the caller's public exponent e becomes BigInteger.fromInt(e), and state.e.modInverse(state.phi) is called with it. gcd() works on absolute values, so the coprimality checks pass and the loop is reached. Any exponent other than 3 or 65537 uses the pure JavaScript implementation, even when forge.options.usePureJavaScript is not set. RFC 8017, Section 3.1 requires the RSA public exponent to be at least 3.
Values that node-forge parses (DER, PEM, JWK, PKCS#12, X.509, TLS) are always read as unsigned integers and cannot produce a negative operand.
The fix makes modInverse() return zero when the value or the modulus is zero or negative, as it already does when no inverse exists. Results for positive inputs are unchanged.
This issue was reported by wzc.
Patches
Fixed in node-forge 1.4.1. modInverse() now returns zero when the value or the modulus is zero or negative.
Workarounds
- Pass only fixed, valid RSA public exponents (e.g. 65537) to key generation, or validate caller-supplied exponents first: an odd integer
>= 3. - Do not call
BigInteger#modInverse()with negative operands. Reduce the value modulo a positive modulus first (x.mod(m).modInverse(m)).
Proof of concept
A negative public exponent passed to RSA key generation never returns (also with the callback form and with createKeyPairGenerationState() / stepKeyPairGenerationState()):
var forge = require('node-forge');
forge.pki.rsa.generateKeyPair({bits: 256, e: -1}); // hangs at 100% CPU
Calling modInverse() directly with a negative value or modulus hangs the same way:
var BigInteger = forge.jsbn.BigInteger;
new BigInteger('-1').modInverse(new BigInteger('7')); // hangs
new BigInteger('3').modInverse(new BigInteger('-7')); // hangs
With the fix, these calls return zero. The regression tests are in tests/unit/jsbn.js.
Impact
Applications are affected only if they:
- pass an untrusted value as the RSA public exponent
etoforge.pki.rsa.generateKeyPair(),forge.pki.rsa.createKeyPairGenerationState()orforge.pki.rsa.stepKeyPairGenerationState(), or - call
forge.jsbn.BigInteger#modInverse()directly with negative values derived from untrusted input.
An attacker who can supply such a value makes the call hang indefinitely at 100% CPU, which blocks the Node.js event loop (denial of service). Keys and other data parsed by node-forge (DER, PEM, JWK, PKCS#12, X.509, TLS) cannot trigger this issue, and the documented usage of key generation passes a constant exponent (65537). There is no effect on confidentiality or integrity.
- Record
GHSA-h6cr-wjv9-3cpp- CVSS 3.1
- 2.9 Low
CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L - Weakness
- CWE-835
- Updated
- 2026-11-02
Show 6 moreShow less
OSVUBUNTU-CVE-2026-118781
2.9
Forge (also called node-forge) is a native implementation of Transport Layer Security in JavaScript. Prior to 1.4.1, the affected implementation used BigInteger.prototype.modInverse(), bnModInverse(), lib/jsbn.js, RSA public exponent e to process the relevant input or security decision. node-forge's bundled jsbn implementation entered an infinite loop when BigInteger.prototype.modInverse() received a negative value or modulus. An attacker who could control the RSA public exponent passed to key generation, or a direct modInverse() operand, could block the Node.js event loop at full CPU. Parsed DER, PEM, JWK, PKCS#12, X.509, and TLS values are unsigned and cannot trigger this issue. This issue is fixed in version 1.4.1.
- Record
UBUNTU-CVE-2026-118781- CVSS 3.1
- 2.9 Low
CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L - Updated
- 2026-11-05
OSVAZL-112487 No score
CVE-2026-118781 affecting package python-tensorboard 2.16.2-6
Forge (also called node-forge) is a native implementation of Transport Layer Security in JavaScript. Prior to 1.4.1, the affected implementation used BigInteger.prototype.modInverse(), bnModInverse(), lib/jsbn.js, RSA public exponent e to process the relevant input or security decision. node-forge's bundled jsbn implementation entered an infinite loop when BigInteger.prototype.modInverse() received a negative value or modulus. An attacker who could control the RSA public exponent passed to key generation, or a direct modInverse() operand, could block the Node.js event loop at full CPU. Parsed DER, PEM, JWK, PKCS#12, X.509, and TLS values are unsigned and cannot trigger this issue. This issue is fixed in version 1.4.1.
- Record
AZL-112487- Updated
- 2026-11-05
OSVCLSA-2026-1793828837 No score
TuxCare security update for node-forge (1 CVE)
TuxCare rebuilt node-forge to address 1 CVE. Fixed in 1.3.3-tuxcare.4.
- Record
CLSA-2026-1793828837- Updated
- 2026-11-05
OSVCLSA-2026-1793874982 No score
TuxCare security update for node-forge (1 CVE)
TuxCare rebuilt node-forge to address 1 CVE. Fixed in 1.3.1-tuxcare.4.
- Record
CLSA-2026-1793874982- Updated
- 2026-11-05
OSVCLSA-2026-1793882307 No score
TuxCare security update for node-forge (1 CVE)
TuxCare rebuilt node-forge to address 1 CVE. Fixed in 0.10.0-tuxcare.10.
- Record
CLSA-2026-1793882307- Updated
- 2026-11-06
OSVCLSA-2026-1793952431 No score
TuxCare security update for node-forge (1 CVE)
TuxCare rebuilt node-forge to address 1 CVE. Fixed in 0.9.0-tuxcare.3.
- Record
CLSA-2026-1793952431- Updated
- 2026-11-06
Affected products
Affected packages
| Package | Affected | Fixed |
|---|---|---|
node-forgenpm |
through 1.4.0 | 1.4.1 |
python-tensorboardAzure Linux:3 |
through 2.16.2-6 | None known |
node-forgeTuxCare:npm |
1.3.3-tuxcare.0 up to 1.3.3-tuxcare.4, plus listed versions 1.3.31.3.3-tuxcare.11.3.3-tuxcare.21.3.3-tuxcare.3 |
1.3.3-tuxcare.4 |
node-forgeTuxCare:npm |
1.3.1-tuxcare.0 up to 1.3.1-tuxcare.4, plus listed versions 1.3.11.3.1-tuxcare.11.3.1-tuxcare.21.3.1-tuxcare.3 |
1.3.1-tuxcare.4 |
node-forgeTuxCare:npm |
0.10.0-tuxcare.0 up to 0.10.0-tuxcare.10, plus listed versions 0.10.00.10.0-tuxcare.10.10.0-tuxcare.20.10.0-tuxcare.30.10.0-tuxcare.4 Show 5 moreShow less0.10.0-tuxcare.50.10.0-tuxcare.60.10.0-tuxcare.70.10.0-tuxcare.80.10.0-tuxcare.9 |
0.10.0-tuxcare.10 |
node-forgeTuxCare:npm |
0.9.0-tuxcare.0 up to 0.9.0-tuxcare.3, plus listed versions 0.9.00.9.0-tuxcare.10.9.0-tuxcare.2 |
0.9.0-tuxcare.3 |
node-forgenpm |
before 1.4.1 | 1.4.1 |
node-node-forgeUbuntu:20.04:LTS |
All versions, plus listed versions 0.8.5~dfsg-20.9.1~dfsg-1 |
None known |
node-node-forgeUbuntu:22.04:LTS |
All versions, plus listed versions 0.10.0~dfsg-31.2.1~dfsg-2 |
None known |
History
| Recorded | Changed | Sources |
|---|---|---|
| affected, aliases | ||
| affected, aliases | OSV | |
| affected, aliases | OSV | |
| affected, aliases, facts | OSV | |
| first indexed | CVE List, EUVD, GitHub Advisories, NVD, OSV |
Dates are when Every CVE recorded each change. Upstream dates may differ.
In short
CVE-2026-118781 is a low vulnerability (CVSS 2.9) in Digitalbazaar Forge, published October 29, 2026. No source lists public exploit code. EPSS puts the chance of exploitation in the next 30 days at 0.12%, the 1st percentile. Fixed in node-forge 1.4.1.
References
github.com/digitalbazaar/forge/security/advisories/GHSA-h6cr-wjv9-3cpp
github.com/digitalbazaar/forge/commit/e96c47b7f006dec66fb7bb1934e7375498b04a72
github.com/digitalbazaar/forge/releases/tag/v1.4.1
nvd.nist.gov/vuln/detail/CVE-2026-118781
github.com/advisories/GHSA-h6cr-wjv9-3cpp
github.com/CVEProject/cvelistV5/tree/main/cves/2026/118xxx/CVE-2026-118781.json
github.com/digitalbazaar/forge
ubuntu.com/security/CVE-2026-118781
cve.org/CVERecord?id=CVE-2026-118781