static-eval arbitrary code execution in function constructor

Severity: low · CVSS 3.1 · Published 2020-09-02

static-eval is a JavaScript library used to safely evaluate static expressions in code. Versions before 2.0.2 contain a flaw that allows attackers to break out of the sandbox and execute arbitrary code by crafting malicious input that bypasses restrictions and directly invokes the JavaScript Function constructor, potentially allowing full control over the affected application.

Technologies: static-eval (npm). Vendors: npm.

Quick answers

Is This vulnerability exploited in the wild?
No. Junglewise Threat Intelligence has no report of This vulnerability being exploited in the wild.
How severe is This vulnerability?
Low severity, with a CVSS score of 3.1, published 2 September 2020.
Which products and versions are affected?
static-eval (npm) SEMVER:introduced=0,fixed=2.0.2.
Is there a fix for This vulnerability?
Yes. static-eval (npm): upgrade to 2.0.2 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is This vulnerability attacked?
It is attacked over the network, in a software library.
Am I affected?
Check whether you run static-eval (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • static-eval (npm): upgrade to 2.0.2 or later
    npm install static-eval@2.0.2

Technical details

The vulnerability is an arbitrary code execution flaw (CWE-94) in static-eval's expression evaluation mechanism. The root cause is that the library passes untrusted user input directly to JavaScript's global Function constructor without proper sanitization or validation. Attackers can exploit this by crafting payloads that leverage object property accessors and constructor chains (e.g., via String.prototype.sub or similar methods) to gain access to the Function constructor and execute arbitrary code. The attack requires only network access to an application using the vulnerable library; no authentication or user interaction is needed. An attacker can achieve full code execution with the privileges of the Node.js process. The vulnerability is fixed in version 2.0.2 and later.

Affected products

  • static-eval static-eval <2.0.2

Timeline

  • 2019-01-03: disclosed
  • 2020-09-02: patched

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.