Math.js parser RCE in expression eval (CVE-2026-40897) [PoC]
CVE-2026-40897
CVE-2026-40897: High-severity RCE in Math.js 13.1.1 to 15.2.0 via expression parser. Unauthenticated users can execute arbitrary JavaScript. Update to 15.2.0.
Vendor-confirmed - CVE-2026-40897 is a high-severity RCE in Math.js versions 13.1.1 through 15.1.0 that lets unauthenticated attackers execute arbitrary JavaScript on the server via the expression parser. Patched in 15.2.0 - update immediately.
Overview
CVE-2026-40897 affects the Math.js expression parser, a feature designed to evaluate mathematical expressions dynamically. An attacker who can submit arbitrary expressions to the parser can inject malicious JavaScript code, gaining the ability to execute system commands, read sensitive data, or manipulate server-side logic. The vulnerability exists because the parser does not properly sanitize user-supplied input during evaluation, allowing unexpected code paths to reach JavaScript execution functions.
This vulnerability receives a CVSS score of 8.8 (High) with a vector of AV:N/AC:L/PR:L/UI:N - meaning it can be exploited over the network with low complexity, requires only low privileges, and needs no user interaction. Any application that exposes the Math.js expression parser to user input is at risk.
Impact
An attacker exploiting CVE-2026-40897 achieves remote code execution (RCE) on the server hosting the vulnerable application. This can lead to complete server compromise, including data exfiltration, lateral movement within the network, and persistent access via backdoors. Unlike typical injection attacks that target operating system commands, this vulnerability uses JavaScript, the same language as the runtime, making detection more difficult for signature-based defenses.
Remediation
Update Math.js to version 15.2.0 or later immediately. The fix disables unsafe evaluation paths in the expression parser. If immediate patching is not possible, restrict access to the expression parser to trusted users only, and implement input validation to block suspicious expression patterns. Consider using a Web Application Firewall (WAF) to filter malicious expression payloads while you migrate.
Security Insight
This vulnerability belongs to the growing class of parser injections that target library-internal languages rather than operating system shells. Similar flaws exist in other evaluation engines such as Python’s eval(), Python’s exec(), and JavaScript’s Function() constructor. The Math.js team has addressed this by tightening the parser’s sandbox, but developers should treat any user-controllable expression parser as a high-risk attack surface and sandbox it separately from application logic. Data breach reports are available at breach reports. For more cybersecurity news, visit security news.
Further Reading
Never miss a critical vulnerability
Get real-time security alerts delivered to your preferred platform.
Public PoC References
Unverified third-party code
These repositories are publicly listed on GitHub and have not been audited by Yazoul Security. They may contain malware, backdoors, destructive payloads, or operational security risks (telemetry, exfiltration). Treat them as hostile binaries. Inspect source before execution. Run only in isolated, disposable lab environments (offline VM, no credentials, no production data).
Authorized use only. This information is provided for defensive research, detection engineering, and patch validation. Using exploit code against systems you do not own or do not have explicit written permission to test is illegal in most jurisdictions and violates Yazoul's terms of use.
| Repository | Stars |
|---|---|
| EQSTLab/CVE-2026-40897 mathjs | ★ 0 |
Showing 1 of 1 known references. Source: nomi-sec/PoC-in-GitHub.
Related Advisories
Improperly controlled modification of dynamically-determined object attributes in the Cognito User Pool configuration in AWS Ops Wheel before PR #165 allows remote authenticated users to escalate to d...
Improperly Controlled Modification of Dynamically-Determined Object Attributes vulnerability in Apache Camel Camel-Coap component. Apache Camel's camel-coap component is vulnerable to Camel message h...
Out of bounds read and write in V8 in Google Chrome prior to 149.0.7827.103 allowed a remote attacker to execute arbitrary code inside a sandbox via a crafted HTML page. (Chromium security severity: H...
A vulnerability in the CLI of Cisco Catalyst SD-WAN Controller, formerly SD-WAN vSmart, Cisco Catalyst SD-WAN Manager, formerly SD-WAN vManage, and Cisco Catalyst SD-WAN Validator, formerly SD-WAN vBo...