Executive brief
node-forge is a widely-used JavaScript cryptography library that provides TLS and other cryptographic tools. A flaw in its BigInteger modular inverse calculation causes an infinite loop when processing zero values, allowing an attacker to crash applications by supplying crafted cryptographic parameters (such as a zero signature value) that trigger the vulnerable function. A single malicious request can hang the entire application indefinitely.
Technical details
The vulnerability is a denial-of-service flaw in the BigInteger.modInverse() function (CWE-835: Loop with Unreachable Exit Condition) inherited from the bundled jsbn library. The Extended Euclidean Algorithm implementation lacks input validation for zero values; when modInverse(0) is called, the loop condition is never satisfied and the process enters an infinite loop, consuming 100% CPU and blocking the Node.js event loop. The vulnerability is reachable via network if an application processes untrusted cryptographic parameters—for example, a DSA/ECDSA signature with s=0 would trigger s.modInverse(q), or any custom RSA/Diffie-Hellman implementation handling user-supplied modular arithmetic. No privileges or user interaction are required. The fix (patch in version 1.4.0+) adds a zero-value check that throws an error before entering the algorithm.
Affected products
- Digital Bazaar node-forge <= 1.3.1
Timeline
- 2026-03-26: disclosed: Public advisory published
- 2026-03-24: patched: Patch available in version 1.4.0