# CVE-2021-21413: Misuse of `Reference` and other transferable APIs may lead to access to nodejs isolate

> Attackers can escape isolated VM contexts to access the main Node.js isolate, potentially executing arbitrary code via native module loading.

- **Severity:** High 8.0 (`CVSS:3.1/AV:A/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 30 Mar 2021
- **Updated:** 3 Aug 2024
- **Also known as:** GHSA-mmhj-4w6j-76h7

## What is CVE-2021-21413?

CVE-2021-21413 is a high-severity vulnerability in laverdet isolated-vm, published on 30 Mar 2021. It can only be exploited from the same machine or local network, with no action from the victim.

### Official description

isolated-vm is a library for nodejs which gives you access to v8's Isolate interface. Versions of isolated-vm before v4.0.0 have API pitfalls which may make it easy for implementers to expose supposed secure isolates to the permissions of the main nodejs isolate. Reference objects allow access to the underlying reference's full prototype chain. In an environment where the implementer has exposed a Reference instance to an attacker they would be able to use it to acquire a Reference to the nodejs context's Function object. Similar application-specific attacks could be possible by modifying the local prototype of other API objects. Access to NativeModule objects could allow an attacker to load and run native code from anywhere on the filesystem. If combined with, for example, a file upload API this would allow for arbitrary code execution. This is addressed in v4.0.0 through a series of related changes.

Weakness: CWE-913 (Improper Control of Dynamically-Managed Code Resources)

## Which versions are affected by CVE-2021-21413?

2 open source packages ship an affected version, including isolated-vm. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `isolated-vm` | npm | All versions | 4.0.0 |
| `isolated-vm` | npm | All versions | 4.0.0 |

Products: Isolated-Vm Project Isolated-Vm.

## How do I fix CVE-2021-21413?

Upgrade isolated-vm to 4.0.0 or later.

## Is CVE-2021-21413 being exploited?

There is no known exploitation of CVE-2021-21413 in the wild and no public exploit code.

Public exploit code:

- CVE-2021-21413 isotaled-vm Sandbox Escape PoC (github_poc): https://github.com/sm1ee/CVE-2021-21413

## Other vulnerabilities in laverdet isolated-vm

- [CVE-2022-39266](https://insights.sbomify.com/CVE-2022-39266/): isolated-vm has vulnerable CachedDataOptions in API (critical 9.7)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2021-21413 and fix it if it is affected.

What it is: CVE-2021-21413 is a high-severity vulnerability in laverdet isolated-vm, published on 30 Mar 2021. It can only be exploited from the same machine or local network, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2021-21413 in the wild and no public exploit code.

Affected packages and fixed versions:
- isolated-vm (npm): affected all versions; fixed in 4.0.0
- isolated-vm (npm): affected all versions; fixed in 4.0.0

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/CVE-2021-21413/ (Markdown: https://insights.sbomify.com/CVE-2021-21413/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2021-21413
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2021-21413
- OSV: https://osv.dev/vulnerability/CVE-2021-21413

---
From sbomify Insights: https://insights.sbomify.com/CVE-2021-21413/
Summaries are generated and may contain mistakes; the official description above is the record.
