CVE-2026-2739: bn.js affected by an infinite loop
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.
Published Feb 20, 2026 · Updated Feb 24, 2026
Affected packages
bn.js
- Ecosystem
- npm
- Affected
- < 4.12.3
- Fixed in
- 4.12.3
- Check
npm ls bn.js
bn.js
- Ecosystem
- npm
- Affected
- >= 5.0.0, < 5.2.3
- Fixed in
- 5.2.3
- Check
npm ls bn.js
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
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.
Credited to richardsimko, jochenschmich-aeberle.
References
- https://nvd.nist.gov/vuln/detail/CVE-2026-2739
- https://github.com/indutny/bn.js/issues/186
- https://github.com/indutny/bn.js/issues/316
- https://github.com/indutny/bn.js/pull/317
- https://github.com/indutny/bn.js/commit/33df26b5771e824f303a79ec6407409376baa64b
- https://gist.github.com/Kr0emer/02370d18328c28b5dd7f9ac880d22a91
- https://security.snyk.io/vuln/SNYK-JS-BNJS-15274301
- https://github.com/indutny/bn.js/releases/tag/v5.2.3
- https://github.com/indutny/bn.js/issues/316#issuecomment-3924217358
- https://github.com/advisories/GHSA-378v-28hj-76wf
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
