# CVE-2026-2739: bn.js affected by an infinite loop

> Calling maskn(0) on a BN instance corrupts internal state, causing infinite loops in methods like toString and divmod, leading to process hangs.

- **Severity:** Medium 6.9 (`CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N/E:P`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 20 Feb 2026
- **Updated:** 20 Feb 2026
- **Also known as:** AZL-78290, CLEANSTART-2026-JE33645, CLEANSTART-2026-ZJ10074, CLSA-2026-1779065199, CLSA-2026-1779065201, CLSA-2026-1782176259, CLSA-2026-1782176267, CLSA-2026-1789159797, CLSA-2026-1790541906, CLSA-2026-1791282392, CLSA-2026-1792488566, CLSA-2026-1792508499, DEBIAN-CVE-2026-2739, ECHO-e0f8-4252-e29c, GHSA-378v-28hj-76wf, MINI-24jm-qj94-5jg7, MINI-3hfx-5v9j-9jx8, MINI-768g-vgm4-7vmx, MINI-c8mh-fq3h-wgw5, MINI-f2jm-qmmr-27hg, MINI-f5x2-cx6p-f78h, MINI-gjg2-jj4q-hj5v, MINI-gjjr-5pjx-c2gh, MINI-jjf2-6gm8-f62f, MINI-m75f-388c-gh28, MINI-q66m-mmgv-m35m, MINI-r4hh-4m2j-w4wr, MINI-r83c-c964-p8mf, MINI-v877-q67q-5938, MINI-wpg6-pfhg-5xqq, MINI-wr45-77j6-pfc9, ROOT-APP-NPM-CVE-2026-2739, UBUNTU-CVE-2026-2739

## What is CVE-2026-2739?

CVE-2026-2739 is a medium-severity denial of service vulnerability in bn.js, published on 20 Feb 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

This affects versions of the package bn.js before 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.

Weakness: CWE-835 (Loop with Unreachable Exit Condition)

## Which versions are affected by CVE-2026-2739?

4 open source packages ship an affected version, including bn.js.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `bn.js` | npm | All versions | 4.12.3 |
| `bn.js` | npm | All versions | 4.12.3 |
| `bn.js` | npm | From 5.0.0 | 5.2.3 |
| `bn.js` | npm | From 5.0.0 | 5.2.3 |

## How do I fix CVE-2026-2739?

Upgrade bn.js to a fixed version for your release line: 4.12.3 or 5.2.3.

## Is CVE-2026-2739 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2026-2739 exists.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2026-2739 and fix it if it is affected.

What it is: CVE-2026-2739 is a medium-severity denial of service vulnerability in bn.js, published on 20 Feb 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2026-2739 exists.

Affected packages and fixed versions:
- bn.js (npm): affected all versions; fixed in 4.12.3
- bn.js (npm): affected all versions; fixed in 4.12.3
- bn.js (npm): affected from 5.0.0; fixed in 5.2.3
- bn.js (npm): affected from 5.0.0; fixed in 5.2.3

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2026-2739/ (Markdown: https://insights.sbomify.com/CVE-2026-2739/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2026-2739
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2026-2739
- OSV: https://osv.dev/vulnerability/CVE-2026-2739

---
From sbomify Insights: https://insights.sbomify.com/CVE-2026-2739/
Summaries are generated and may contain mistakes; the official description above is the record.
