Vulnerabilities in pkg:npm/babel-traverse

PACKAGE
Advisory Identifier: GHSA-67hx-6x53-jw92
Advisory Summary

CVE-2023-45133 is a CRITICAL (CVSS 9.3) babel vulnerable to arbitrary code vulnerability (CWE-184: Incomplete List of Disallowed Inputs) affecting @babel/traverse libraries in the npm ecosystem. The issue involves babel vulnerable to arbitrary code execution when compiling specifically crafted malicious code. Remediation is available by upgrading affected packages to version 7.23.2, 8.0.0-alpha.4.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/babel-traverse

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/babel-traverse. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-67hx-6x53-jw92 CVE-2023-45133 CRITICAL Babel vulnerable to arbitrary code execution when compiling specifically crafted malicious code

CVE-2023-45133 at a Glance

CVE Identifier CVE-2023-45133
GHSA Identifier GHSA-67hx-6x53-jw92
Severity CRITICAL
CVSS v3.1 Base Score 9.3
CWE Classification CWE-184: Incomplete List of Disallowed Inputs
Affected Product @babel/traverse
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 9.3

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

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

How to Fix CVE-2023-45133

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

@babel/traverse fixed: 7.23.2
npm install @babel/traverse@7.23.2
@babel/traverse fixed: 8.0.0-alpha.4
npm install @babel/traverse@8.0.0-alpha.4
babel-traverse fixed: Latest secure release
npm install babel-traverse@Latest secure release
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 @babel/traverse

How to Check if You Are Affected

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

npm ls @babel/traverse

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

Note: The npm ls @babel/traverse 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-184: Incomplete List of Disallowed Inputs, where the product implements a protection mechanism that relies on a list of inputs (or properties of inputs) that are not allowed by policy or otherwise require other action to neutralize before additional processing takes place, but the list is incomplete. In @babel/traverse, 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

### Impact Using Babel to compile code that was specifically crafted by an attacker can lead to arbitrary code execution during compilation, when using plugins that rely on the `path.evaluate()`or `path.evaluateTruthy()` internal Babel methods. Known affected plugins are: - `@babel/plugin-transform-runtime` - `@babel/preset-env` when using its [`useBuiltIns`](https://babeljs.io/docs/babel-preset-env#usebuiltins) option - Any "polyfill provider" plugin that depends on `@babel/helper-define-polyfill-provider`, such as `babel-plugin-polyfill-corejs3`, `babel-plugin-polyfill-corejs2`, `babel-plugin-polyfill-es-shims`, `babel-plugin-polyfill-regenerator` No other plugins under the `@babel/` namespace are impacted, but third-party plugins might be. **Users that only compile trusted code are not impacted.** ### Patches The vulnerability has been fixed in `@babel/traverse@7.23.2`. Babel 6 does not receive security fixes anymore (see [Babel's security policy](https://github.com/babel/babel/security/policy)), hence there is no patch planned for `babel-traverse@6`. ### Workarounds - Upgrade `@babel/traverse` to v7.23.2 or higher. You can do this by deleting it from your package manager's lockfile and re-installing the dependencies. `@babel/core` >=7.23.2 will automatically pull in a non-vulnerable version. - If you cannot upgrade `@babel/traverse` and are using one of the affected packages mentioned above, upgrade them to their latest version to avoid triggering the vulnerable code path in affected `@babel/traverse` versions: - `@babel/plugin-transform-runtime` v7.23.2 - `@babel/preset-env` v7.23.2 - `@babel/helper-define-polyfill-provider` v0.4.3 - `babel-plugin-polyfill-corejs2` v0.4.6 - `babel-plugin-polyfill-corejs3` v0.8.5 - `babel-plugin-polyfill-es-shims` v0.10.0 - `babel-plugin-polyfill-regenerator` v0.5.3

CVE-2023-45133 Affected @babel/traverse Versions

3 component(s)
Fixed Versions:
7.23.28.0.0-alpha.4
Product / Package Ecosystem Affected Versions Fixed Version
@babel/traverse
npm
< 7.23.2
7.23.2
@babel/traverse
npm
≥ 8.0.0-alpha.0
< 8.0.0-alpha.4
8.0.0-alpha.4
babel-traverse
npm

References

Frequently Asked Questions

What is CVE-2023-45133?
CVE-2023-45133 is a security vulnerability in @babel/traverse involving Babel vulnerable to arbitrary code execution when compiling specifically crafted malicious code under CWE-184: Incomplete List of Disallowed Inputs.
Which @babel/traverse versions are affected?
Affected versions include releases prior to 7.23.2, 8.0.0-alpha.4 across affected packages: @babel/traverse, babel-traverse.
What version fixes CVE-2023-45133?
Upgrading to 7.23.2, 8.0.0-alpha.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @babel/traverse affected?
Yes, @babel/traverse is affected in releases prior to 7.23.2, 8.0.0-alpha.4. Upgrade your dependency to 7.23.2, 8.0.0-alpha.4 or later.
Is babel-traverse affected?
Yes, babel-traverse is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What is the CVSS score of CVE-2023-45133?
CVE-2023-45133 has a CVSS v3.1 base score of 9.3 (CRITICAL) with vector string CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H.
What CWE is associated with CVE-2023-45133?
CVE-2023-45133 is classified under CWE-184: Incomplete List of Disallowed Inputs (The product implements a protection mechanism that relies on a list of inputs (or properties of inputs) that are not allowed by policy or otherwise require other action to neutralize before additional processing takes place, but the list is incomplete.).
How can I check npm dependencies for CVE-2023-45133?
Run the dependency tree command: 'npm ls @babel/traverse'. 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-67hx-6x53-jw92",
  "modified" : "2024-04-04T14:26:10Z",
  "published" : "2023-10-16T13:55:36Z",
  "aliases" : [ "CVE-2023-45133" ],
  "summary" : "Babel vulnerable to arbitrary code execution when compiling specifically crafted malicious code",
  "details" : "### Impact\n\nUsing Babel to compile code that was specifically crafted by an attacker can lead to arbitrary code execution during compilation, when using plugins that rely on the `path.evaluate()`or `path.evaluateTruthy()` internal Babel methods.\n\nKnown affected plugins are:\n- `@babel/plugin-transform-runtime`\n- `@babel/preset-env` when using its [`useBuiltIns`](https://babeljs.io/docs/babel-preset-env#usebuiltins) option\n- Any \"polyfill provider\" plugin that depends on `@babel/helper-define-polyfill-provider`, such as `babel-plugin-polyfill-corejs3`, `babel-plugin-polyfill-corejs2`, `babel-plugin-polyfill-es-shims`, `babel-plugin-polyfill-regenerator`\n\nNo other plugins under the `@babel/` namespace are impacted, but third-party plugins might be.\n\n**Users that only compile trusted code are not impacted.**\n\n### Patches\n\nThe vulnerability has been fixed in `@babel/traverse@7.23.2`.\n\nBabel 6 does not receive security fixes anymore (see [Babel's security policy](https://github.com/babel/babel/security/policy)), hence there is no patch planned for `babel-traverse@6`.\n\n### Workarounds\n\n- Upgrade `@babel/traverse` to v7.23.2 or higher. You can do this by deleting it from your package manager's lockfile and re-installing the dependencies. `@babel/core` >=7.23.2 will automatically pull in a non-vulnerable version.\n- If you cannot upgrade `@babel/traverse` and are using one of the affected packages mentioned above, upgrade them to their latest version to avoid triggering the vulnerable code path in affected `@babel/traverse` versions:\n  - `@babel/plugin-transform-runtime` v7.23.2\n  - `@babel/preset-env` v7.23.2\n  - `@babel/helper-define-polyfill-provider` v0.4.3\n  - `babel-plugin-polyfill-corejs2` v0.4.6\n  - `babel-plugin-polyfill-corejs3` v0.8.5\n  - `babel-plugin-polyfill-es-shims` v0.10.0\n  - `babel-plugin-polyfill-regenerator` v0.5.3",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@babel/traverse"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "7.23.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@babel/traverse"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "8.0.0-alpha.0"
      }, {
        "fixed" : "8.0.0-alpha.4"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "babel-traverse"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "< 7.23.2"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/babel/babel/security/advisories/GHSA-67hx-6x53-jw92"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-45133"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/babel/babel/pull/16033"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/babel/babel/commit/b13376b346946e3f62fc0848c1d2a23223314c82"
  }, {
    "type" : "WEB",
    "url" : "https://babeljs.io/blog/2023/10/16/cve-2023-45133"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/babel/babel"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/babel/babel/releases/tag/v7.23.2"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/babel/babel/releases/tag/v8.0.0-alpha.4"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2023/10/msg00026.html"
  }, {
    "type" : "WEB",
    "url" : "https://www.debian.org/security/2023/dsa-5528"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-184", "CWE-697" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-10-16T13:55:36Z",
    "nvd_published_at" : "2023-10-12T17:15:09Z"
  }
}