Vulnerability library
Security checkFebruary 24, 2026

bn.js affected by an infinite loop

Understand the exposure, see the recommended fix, and check whether your own website has related weaknesses.

Medium severitynpmbn.js

Check your website

Find this and other vulnerabilities with a free scan.

Your scan runs on your computer. No account required.

Description

This affects versions of the package bn.js before 4.12.3 and 5.2.3. Calling maskn(0) on any BN instance corrupts the internal state, causing toString(), divmod(), and other methods to enter an infinite loop, hanging the process indefinitely.

Recommendation

Update the bn.js package to the latest compatible version. Followings are version details:

  • Affected version(s): **>= 5.0.0, < 5.2.3 < 4.12.3**
  • Patched version(s): **5.2.3 4.12.3**

References

Could your website be exposed too?

SmartScanner can check your website for bn.js affected by an infinite loop and gives you actionable findings to investigate.

Start a free scan

Related Issues

See something that needs correcting? Let us knowUpdated February 24, 2026