CVEReports
CVEReports

Automated vulnerability intelligence platform. Comprehensive reports for high-severity CVEs generated by AI.

Product

  • Home
  • Sitemap
  • RSS Feed

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CVEReports. All rights reserved.

Made with love by Amit Schendel & Alon Barad



GHSA-JVFF-X2QM-6286

GHSA-jvff-x2qm-6286: Arbitrary JavaScript Execution via Sandbox Bypass in mathjs

Alon Barad
Alon Barad
Software Engineer

Apr 11, 2026·5 min read·60 visits

Executive Summary (TL;DR)

A sandbox bypass in mathjs < 15.2.0 allows low-privileged attackers to execute arbitrary JavaScript code via crafted expressions. The flaws involve array method shadowing and type confusion, resulting in a CVSS score of 8.8. Immediate upgrade to version 15.2.0 is required.

The mathjs library prior to version 15.2.0 contains critical vulnerabilities in its expression parser sandbox. An attacker can leverage improper property validation and type confusion to execute arbitrary JavaScript within the host environment. The issue stems from lenient array property validation and inadequate type checking on the index parameter during dimension evaluation.

Vulnerability Overview

The mathjs library provides an extensive mathematical expression parser designed to evaluate inputs safely within JavaScript and Node.js environments. To prevent untrusted input from accessing sensitive global objects, mathjs implements a custom sandbox. This sandbox restricts access to properties and methods that could be abused to execute arbitrary code.

Two critical flaws exist within this sandbox implementation in versions prior to 15.2.0. The first vulnerability involves improper property validation that allows an attacker to shadow native array methods. The second vulnerability is a type confusion flaw within the indexing utilities that permits the injection of malicious duck-typed objects.

These vulnerabilities are classified under CWE-915 (Improperly Controlled Modification of Dynamically-Determined Object Attributes). Because mathjs executes within the context of the host application, a successful sandbox bypass typically results in remote code execution (RCE) on server-side Node.js environments. The CVSS 3.0 vector evaluates to 8.8 due to the low privilege requirements and the complete compromise of confidentiality, integrity, and availability.

Root Cause Analysis: Array Method Shadowing

The first execution pathway exploits the isSafeProperty validation function within the mathjs expression parser. Prior to version 15.2.0, this function utilized a blacklist approach to restrict property access during evaluation. The blacklist explicitly targeted properties located on Object.prototype and Function.prototype to prevent prototype pollution and subsequent execution escapes.

This validation strategy failed to properly distinguish between standard Objects and Arrays. The lack of specific isolation for Array.prototype allowed an attacker to define native array methods as "own-properties" directly on an array instance. Methods such as map, reduce, or push could be successfully shadowed by malicious functions.

When the internal logic of mathjs subsequently invoked these shadowed methods on the poisoned array object, the JavaScript engine executed the attacker-controlled function rather than the native implementation. This control flow hijack provided a reliable pathway to retrieve the global Function constructor, bypassing the sandbox restrictions entirely.

Root Cause Analysis: Type Confusion in Indexing

The second execution pathway leverages a type confusion flaw within the get function located in src/utils/array.js. This function is responsible for evaluating matrix and array indices during expression processing. Prior to version 15.2.0, the function lacked strict type validation for its index parameter.

Because the parameter was not strictly validated as a native JavaScript Array, an attacker could supply a duck-typed object. This malicious object merely needed to satisfy the expected property checks, such as exposing a length property, to pass the initial validation routines. The object could then be constructed to include a custom reduce method containing a malicious payload.

During dimension validation, mathjs iterates over the provided indices using the reduce method. Invoking this method on the attacker-supplied duck-typed object triggered the embedded payload. This execution occurred during internal processing, bypassing the expression parser's standard safety boundaries.

Exploitation and Attack Methodology

Exploitation requires the attacker to supply a crafted string to the math.evaluate() or math.parse() functions within a vulnerable application. No user interaction is required, and network access is sufficient if the application exposes the mathjs evaluation endpoint via a web API.

The Array Method Shadowing attack involves instantiating an ArrayNode and extracting the underlying JavaScript array. The attacker overrides the map method on this array to inject a custom function. By passing this poisoned array to a FunctionAssignmentNode, the execution flow extracts the global Function constructor.

The Duck-Typed Index Injection attack directly targets the matrix get method. The attacker creates a matrix and invokes its get method, supplying an object literal instead of a valid index array. When mathjs validates the matrix dimensions, it executes the injected reduce function, returning a reference to process in Node.js.

// Proof of Concept: Duck-Typed Index Injection
m = matrix();
// Supply duck-typed object to bypass Array validation
func = m.get({"length":1,"reduce":f(callback,a)=callback(cos,"constructor")});
// Obtain global Function constructor and execute
getProcess = func("return process");
getProcess()

Code Analysis and Patch Review

The vulnerabilities were resolved in commit 0aee2f61866e35ffa0aef915221cdf6b026ffdd4 (PR #3656), which introduced strict validation mechanisms. The primary architectural change involved deprecating the generic isSafeProperty function. The maintainers replaced it with context-specific validators named isSafeObjectProperty and isSafeArrayProperty.

The new isSafeArrayProperty function implements a strict whitelist for array access. It permits access exclusively to numeric indices and the literal .length property. This structural change entirely prevents attackers from shadowing executable methods like map and reduce, closing the first execution pathway.

To resolve the type confusion vulnerability, the patch introduced explicit Array.isArray(index) checks. These checks enforce strict type validation within src/utils/array.js and the matrix get methods. Duck-typed objects are now rejected immediately before dimension validation occurs.

The implementation of these whitelist and strict typing mechanisms provides a robust defense against sandbox evasion. The patch eliminates the known execution vectors and significantly reduces the attack surface for future bypass attempts.

Remediation and Mitigation

The primary and only definitive remediation strategy is upgrading the mathjs dependency. Development teams must update their package.json files to specify version 15.2.0 or later. Applications must be redeployed to ensure the patched library is active in the runtime environment.

There are no viable configuration workarounds to secure vulnerable versions of mathjs. The application of the patch is mandatory for any software relying on the library to process untrusted mathematical expressions.

Security operations teams can implement detection mechanisms while patches are deployed. Web Application Firewalls (WAFs) and monitoring solutions should flag requests containing mathjs expressions that utilize reviver, toJSON, or attempt to override array methods. Monitoring for access to the constructor property within mathjs inputs is also highly recommended.

Official Patches

josdejongFix Pull Request #3656
josdejongRelease v15.2.0

Fix Analysis (1)

Technical Appendix

CVSS Score
8.8/ 10
CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Affected Systems

mathjs npm package (< 15.2.0)Node.js server applications evaluating untrusted input via mathjsClient-side web applications exposing mathjs evaluation to users

Affected Versions Detail

Product
Affected Versions
Fixed Version
mathjs
josdejong
< 15.2.015.2.0
AttributeDetail
CWE IDCWE-915
Attack VectorNetwork
CVSS Base Score8.8
ImpactRemote Code Execution
Exploit StatusProof of Concept
RemediationPatch Available

MITRE ATT&CK Mapping

T1190Exploit Public-Facing Application
Initial Access
T1565.001Stored Data Manipulation
Impact
CWE-915
Improperly Controlled Modification of Dynamically-Determined Object Attributes

Improperly Controlled Modification of Dynamically-Determined Object Attributes

Known Exploits & Detection

GitHub Security AdvisoryExploit payloads demonstrating array shadowing and duck-typed index injection.

Vulnerability Timeline

Fix commit pushed and PR #3656 created.
2026-04-07
Version 15.2.0 released.
2026-04-10
GitHub Security Advisory GHSA-jvff-x2qm-6286 published.
2026-04-10

References & Sources

  • [1]GHSA-jvff-x2qm-6286 Advisory
  • [2]Fix PR #3656
  • [3]Fix Commit
  • [4]v15.2.0 Release Notes

Attack Flow Diagram

Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.

More Reports

•18 minutes ago•CVE-2026-68587
9.2

CVE-2026-68587: Broken Access Control in SiYuan Note Transaction Endpoints

CVE-2026-68587 is a critical authorization bypass vulnerability in SiYuan, an open-source personal knowledge management workspace. When deployed in publish mode, specific transaction endpoints fail to perform administrative role validation. This omission enables unauthenticated remote readers to retrieve the rendered Document Object Model (DOM) of publish-disabled (private) documents by supplying a target heading block identifier. Upgrading to version v3.7.3 or later resolves this issue by applying appropriate routing middleware constraints.

Amit Schendel
Amit Schendel
1 views•6 min read
•about 1 hour ago•CVE-2026-68586
9.2

CVE-2026-68586: Missing Authorization in SiYuan Backlink Content Endpoints Allows Information Disclosure

SiYuan is a privacy-first personal knowledge management system. In versions prior to v3.7.3, the application fails to apply publish-access filters to the getBacklinkDoc and getBackmentionDoc content endpoints (/api/ref/getBacklinkDoc and /api/ref/getBackmentionDoc). While the corresponding backlink list endpoints correctly filter out publish-forbidden documents, the content endpoints, which are only gated by high-level route authorization checks via CheckAuth, do not. Consequently, a user with low-privilege read access, or an anonymous reader when publish Basic Auth is disabled, can directly invoke these endpoints using a known publish-forbidden document's ID to retrieve its rendered DOM content or determine whether it references a specific target block.

Amit Schendel
Amit Schendel
1 views•7 min read
•about 2 hours ago•CVE-2026-68585
5.8

CVE-2026-68585: Metadata Disclosure via Missing Authorization in SiYuan API

A metadata disclosure vulnerability exists in SiYuan prior to version v3.7.3. The /api/block/getBlockInfo endpoint fails to validate authorization boundaries in publish mode, allowing anonymous readers to access private document metadata.

Alon Barad
Alon Barad
3 views•8 min read
•about 3 hours ago•CVE-2026-72812
6.5

CVE-2026-72812: Broken Access Control and SQL Injection in SiYuan

A critical authorization bypass vulnerability exists in SiYuan personal knowledge management system before v3.7.4. The /api/ref/refreshBacklink endpoint lacks administrative role verification, enabling unauthenticated users to initiate database transactions and disk operations. When combined with an unsafe SQL generation pattern in nested backlink queries, an attacker can exploit a secondary SQL injection vulnerability to compromise local databases or cause denial-of-service conditions.

Amit Schendel
Amit Schendel
3 views•6 min read
•about 4 hours ago•CVE-2026-72811
10.0

CVE-2026-72811: Remote SQL Injection in SiYuan Backlink and Mention Search Engine

A critical SQL Injection vulnerability exists in the SiYuan note-taking application (versions <= v3.7.2) due to improper neutralization of single quotes within the backlink and mention search queries. Because the application constructs SQLite Full Text Search (FTS) queries via direct string concatenation and uses a database driver that supports stacked query statements, remote unauthenticated attackers can execute arbitrary SQL commands on the master database, compromising all hosted notebooks. This issue has been fully remediated in version v3.7.4.

Amit Schendel
Amit Schendel
3 views•7 min read
•about 5 hours ago•CVE-2026-72810
8.6

CVE-2026-72810: Publish-Boundary Bypass and Real-Time Data Leakage via WebSocket Session Pollution in SiYuan

CVE-2026-72810 is a critical publish-boundary bypass vulnerability in the SiYuan personal knowledge management system before version 3.7.4. The flaw lies in the backend real-time WebSocket broadcast mechanism. When configured in public publish mode, the system fails to differentiate between unauthenticated public reader sessions and authorized administrative sessions within its global connection pool. This architectural oversight allows unauthenticated remote attackers connecting to the public WebSocket endpoint on port 6808 to passively receive real-time, raw workspace modification events, including keystroke logs, block updates, and content from protected or forbidden documents.

Amit Schendel
Amit Schendel
4 views•7 min read