CVE-2021-21413: Isolated vm Misuse Of `Reference` And Other Vulnerability

HIGH
Advisory Identifier: GHSA-mmhj-4w6j-76h7
CVSS 8.0
CWE-913
Published
Advisory Summary

CVE-2021-21413 is a HIGH (CVSS 8.0) misuse of `reference` and other vulnerability (CWE-913: Improper Control of Dynamically-Managed Code Resources) affecting Isolated vm libraries in the npm ecosystem. The issue involves misuse of `reference` and other transferable apis may lead to access to nodejs isolate. Remediation is available by upgrading affected packages to version 4.0.0.

CVE-2021-21413 at a Glance

CVE Identifier CVE-2021-21413
GHSA Identifier GHSA-mmhj-4w6j-76h7
Severity HIGH
CVSS v3.1 Base Score 8.0
CWE Classification CWE-913: Improper Control of Dynamically-Managed Code Resources
Affected Product Isolated vm
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 8.0

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:A/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:N).

Attack Vector Adjacent (AV:A)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2021-21413

To remediate this vulnerability, upgrade all affected Isolated vm dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

isolated-vm fixed: 4.0.0
npm install isolated-vm@4.0.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls isolated-vm

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2021-21413, inspect your project dependencies using npm:

npm ls isolated-vm

Analyze the terminal output to locate any version of Isolated vm in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.0.0), your application is affected.

Note: The npm ls isolated-vm command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-913: Improper Control of Dynamically-Managed Code Resources, where the product does not properly restrict reading from or writing to dynamically-managed code resources such as variables, objects, classes, attributes, functions, or executable instructions or statements. In Isolated vm, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

Versions of `isolated-vm` before v4.0.0, and especially before v3.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. To address these issues the following changes were made in v4.0.0: - Documentation was updated with more explicit guidelines on building secure applications. - `Reference` instances will no longer follow prototype chains by default, nor will they invoke accessors or proxies. - All `isolated-vm` API prototypes are now immutable. - `NativeModule` constructor may only be invoked from a nodejs isolate.

CVE-2021-21413 Affected Isolated vm Versions

1 component(s)
Fixed Versions:
4.0.0
Product / Package Ecosystem Affected Versions Fixed Version
isolated-vm
npm
< 4.0.0
4.0.0

References

Frequently Asked Questions

What is CVE-2021-21413?
CVE-2021-21413 is a security vulnerability in Isolated vm involving Misuse of `Reference` and other transferable APIs may lead to access to nodejs isolate under CWE-913: Improper Control of Dynamically-Managed Code Resources.
Which Isolated vm versions are affected?
Affected versions include releases prior to 4.0.0 across affected packages: isolated-vm.
What version fixes CVE-2021-21413?
Upgrading to 4.0.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is isolated-vm affected?
Yes, isolated-vm is affected in releases prior to 4.0.0. Upgrade your dependency to 4.0.0 or later.
What is the CVSS score of CVE-2021-21413?
CVE-2021-21413 has a CVSS v3.1 base score of 8.0 (HIGH) with vector string CVSS:3.1/AV:A/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:N.
What CWE is associated with CVE-2021-21413?
CVE-2021-21413 is classified under CWE-913: Improper Control of Dynamically-Managed Code Resources (The product does not properly restrict reading from or writing to dynamically-managed code resources such as variables, objects, classes, attributes, functions, or executable instructions or statements.).
How can I check npm dependencies for CVE-2021-21413?
Run the dependency tree command: 'npm ls isolated-vm'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-mmhj-4w6j-76h7",
  "modified" : "2021-03-30T22:27:45Z",
  "published" : "2021-04-06T17:22:55Z",
  "aliases" : [ "CVE-2021-21413" ],
  "summary" : "Misuse of `Reference` and other transferable APIs may lead to access to nodejs isolate",
  "details" : "Versions of `isolated-vm` before v4.0.0, and especially before v3.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.\n\n`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.\n\nSimilar application-specific attacks could be possible by modifying the local prototype of other API objects.\n\nAccess 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.\n\nTo address these issues the following changes were made in v4.0.0:\n- Documentation was updated with more explicit guidelines on building secure applications.\n- `Reference` instances will no longer follow prototype chains by default, nor will they invoke accessors or proxies.\n- All `isolated-vm` API prototypes are now immutable.\n- `NativeModule` constructor may only be invoked from a nodejs isolate.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:A/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "isolated-vm"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.0.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/laverdet/isolated-vm/security/advisories/GHSA-mmhj-4w6j-76h7"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-21413"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/laverdet/isolated-vm/commit/2646e6c1558bac66285daeab54c7d490ed332b15"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/laverdet/isolated-vm/commit/27151bfecc260e96714443613880e3b2e6596704"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/laverdet/isolated-vm/blob/main/CHANGELOG.md#v400"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-913" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-03-30T22:27:45Z",
    "nvd_published_at" : "2021-03-30T23:15:00Z"
  }
}