CVE-2026-40897: mathjs Arbitrary JavaScript Execution via Expression Parser

mathjs Updated 17 Apr 2026

Summary

16/04/2026
Yes i
High
8.8

CVE-2026-40897: Unsafe object property setter in mathjs. Affects mathjs versions >= 13.1.1, < 15.2.0. Fixed in 15.2.0. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

mathjs is a comprehensive mathematics library for JavaScript and Node.js, designed to handle a wide range of mathematical operations, including algebra, calculus, and statistics. It allows users to evaluate expressions, perform calculations, and manipulate mathematical objects. However, a recent vulnerability has been identified that exposes applications using mathjs to potential security risks when users can evaluate arbitrary expressions.

Vulnerability Detail

The vulnerability arises from an unsafe object property setter in the mathjs expression parser, which allows for the execution of arbitrary JavaScript code. This issue was introduced in version 13.1.1 and can be exploited in applications where users are permitted to input and evaluate expressions. The ramifications include unauthorized access to sensitive data, manipulation of application behavior, and potential system compromise.

How To Fix

Latest published version: 15.2.0 as of 22 Oct 2026

npm install mathjs@15.2.0

The newest release already contains this fix.

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

There are no effective workarounds available without upgrading to version 15.2.0. It is strongly recommended to apply the update to mitigate the risk associated with this vulnerability.

Conclusion

In summary, CVE-2026-40897 is a critical vulnerability in the mathjs library that allows for arbitrary JavaScript execution through its expression parser. It is crucial for developers to update to version 15.2.0 or later to mitigate the risks associated with this vulnerability. Regular monitoring using tools like Vulert can help maintain the security of your applications.

See every vulnerability recorded for mathjs →

Share this vulnerability

FAQ

CVE-2026-40897 is a security vulnerability in the mathjs library that allows for arbitrary JavaScript execution through its expression parser.

If your application uses mathjs version 13.1.1 to 15.1.9 and allows users to evaluate arbitrary expressions, it is likely affected by this vulnerability.

Exploiting this vulnerability can lead to unauthorized access to sensitive data, manipulation of application behavior, and potential system compromise.

You can use Vulert, which monitors and alerts in real-time for open-source vulnerabilities by analyzing your package-lock.json file. You can also check if your application is affected using the Vulert playground without any signup.

The CVSS score of this vulnerability is 8.8, indicating a high level of severity.

Related vulnerabilities

Recent vulnerabilities recorded for mathjs.

How To Fix

Latest published version: 15.2.0 as of 22 Oct 2026

npm install mathjs@15.2.0

The newest release already contains this fix.

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback