CVE-2026-2739

5.3 MEDIUM

📋 TL;DR

This vulnerability in bn.js versions before 5.2.3 allows attackers to cause denial of service by calling maskn(0) on any BN instance, which corrupts internal state and causes infinite loops in methods like toString() and divmod(). This affects any application using vulnerable versions of the bn.js library for big number arithmetic operations.

💻 Affected Systems

Products:
  • bn.js
Versions: All versions before 5.2.3
Operating Systems: All platforms running Node.js
Default Config Vulnerable: ⚠️ Yes
Notes: Any application using bn.js for big number operations is vulnerable if it calls maskn(0) or allows user input to reach this method.

⚠️ Manual Verification Required

This CVE does not have specific version information in our database, so automatic vulnerability detection cannot determine if your system is affected.

Why? The CVE database entry doesn't specify which versions are vulnerable (no version ranges provided by the vendor/NVD).

🔒 Custom verification scripts are available for registered users. Sign up free to download automated test scripts.

Recommended Actions:
  1. Review the CVE details at NVD
  2. Check vendor security advisories for your specific version
  3. Test if the vulnerability is exploitable in your environment
  4. Consider updating to the latest version as a precaution

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete denial of service where affected processes hang indefinitely, potentially crashing applications or servers that rely on bn.js for cryptographic operations or mathematical calculations.

🟠

Likely Case

Application instability and service disruption when malicious or malformed input triggers the vulnerable maskn(0) method, leading to hung processes that require manual intervention.

🟢

If Mitigated

Limited impact if input validation prevents calling maskn(0) with zero parameter, or if the vulnerable function isn't exposed to untrusted input sources.

🌐 Internet-Facing: MEDIUM - Exploitation requires ability to call specific API methods, but many web applications expose mathematical operations that could be abused.
🏢 Internal Only: LOW - Requires specific API calls to trigger, less likely to be exploited internally without targeted attack.

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Proof of concept is publicly available in GitHub issues. Exploitation is straightforward - simply calling maskn(0) triggers the vulnerability.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 5.2.3

Vendor Advisory: https://github.com/indutny/bn.js/commit/33df26b5771e824f303a79ec6407409376baa64b

Restart Required: Yes

Instructions:

1. Update bn.js dependency to version 5.2.3 or later. 2. Run 'npm update bn.js' or 'yarn upgrade bn.js'. 3. Restart all affected applications and services.

🔧 Temporary Workarounds

Input validation wrapper

all

Wrap maskn() calls with validation to reject zero parameter

// In your code, add validation:
function safeMaskn(bnInstance, bits) {
  if (bits === 0) {
    throw new Error('maskn(0) is not allowed');
  }
  return bnInstance.maskn(bits);
}

🧯 If You Can't Patch

  • Implement input validation to prevent maskn(0) calls from user-controlled sources
  • Monitor processes for abnormal CPU usage indicating infinite loops and implement automatic restart mechanisms

🔍 How to Verify

Check if Vulnerable:

Check package.json or run 'npm list bn.js' to see if version is below 5.2.3

Check Version:

npm list bn.js | grep bn.js

Verify Fix Applied:

Confirm bn.js version is 5.2.3 or higher with 'npm list bn.js' and test that maskn(0) no longer causes infinite loops

📡 Detection & Monitoring

Log Indicators:

  • Processes hanging with high CPU usage
  • Application crashes following mathematical operations
  • Error logs showing infinite loop warnings

Network Indicators:

  • Service unavailability after mathematical API calls
  • Timeout errors on endpoints using bn.js operations

SIEM Query:

Process monitoring for sustained 100% CPU usage on Node.js applications using bn.js library

🔗 References

📤 Share & Export