# CVE-2026-41139: Unsafe array index getter in mathjs

> Attackers can execute arbitrary JavaScript code via the expression parser in the mathjs library, requiring an upgrade to the latest version.

- **Severity:** High 8.8 (`CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 7 May 2026
- **Updated:** 15 Jul 2026
- **Also known as:** GHSA-5v89-rwgr-qj6g, GHSA-jvff-x2qm-6286

## What is CVE-2026-41139?

CVE-2026-41139 is a high-severity code injection vulnerability in josdejong mathjs, published on 7 May 2026. Any signed-in user can exploit it over the network, with no action from the victim.

### Official description

Math.js is an extensive math library for JavaScript and Node.js. From version 13.1.0 to before version 15.2.0, arbitrary JavaScript can be executed via the expression parser of mathjs. This issue has been patched in version 15.2.0.

Weakness: CWE-94 (Improper Control of Generation of Code), CWE-915 (Improperly Controlled Modification of Dynamically-Determined Object Attributes)

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

2 open source packages ship an affected version, including mathjs. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `mathjs` | npm | From 13.1.0 | 15.2.0 |
| `mathjs` | npm | From 13.1.0 | 15.2.0 |

Products: Mathjs Mathjs.

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

Upgrade mathjs to 15.2.0 or later.

## Is CVE-2026-41139 being exploited?

There is no known exploitation of CVE-2026-41139 in the wild and no public exploit code.

## Other vulnerabilities in josdejong mathjs

- [CVE-2026-40897](https://insights.sbomify.com/CVE-2026-40897/): Math.js: Unsafe object property setter in mathjs (high 8.8)
- [CVE-2020-7743](https://insights.sbomify.com/CVE-2020-7743/): Prototype Pollution (high 7.3)

## Fix prompt for AI coding agents

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

What it is: CVE-2026-41139 is a high-severity code injection vulnerability in josdejong mathjs, published on 7 May 2026. Any signed-in user can exploit it over the network, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2026-41139 in the wild and no public exploit code.

Affected packages and fixed versions:
- mathjs (npm): affected from 13.1.0; fixed in 15.2.0
- mathjs (npm): affected from 13.1.0; fixed in 15.2.0

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-41139/ (Markdown: https://insights.sbomify.com/CVE-2026-41139/index.md)
```

## Sources

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

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