CVE-2022-35204: Vite Path Traversal Vulnerability

HIGH
Advisory Identifier: GHSA-mv48-hcvh-8jj8
CVSS 8.6
CWE-22
Published
Advisory Summary

CVE-2022-35204 is a HIGH (CVSS 8.6) path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Vite libraries in the npm ecosystem. The issue involves vite before v2.9.13 vulnerable to directory traversal via crafted url to victim's service. Remediation is available by upgrading affected packages to version 2.9.13, 3.0.0-beta.4.

CVE-2022-35204 at a Glance

CVE Identifier CVE-2022-35204
GHSA Identifier GHSA-mv48-hcvh-8jj8
Severity HIGH
CVSS v3.1 Base Score 8.6
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Vite
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 8.6

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

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

How to Fix CVE-2022-35204

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

vite fixed: 2.9.13
npm install vite@2.9.13
vite fixed: 3.0.0-beta.4
npm install vite@3.0.0-beta.4
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 vite

How to Check if You Are Affected

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

npm ls vite

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

Note: The npm ls vite 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-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Vite, 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

Vite before v2.9.13 was discovered to allow attackers to perform a directory traversal via a crafted URL to the victim's service.

CVE-2022-35204 Affected Vite Versions

2 component(s)
Fixed Versions:
2.9.133.0.0-beta.4
Product / Package Ecosystem Affected Versions Fixed Version
vite
npm
< 2.9.13
2.9.13
vite
npm
≥ 3.0.0-alpha.0
< 3.0.0-beta.4
3.0.0-beta.4

References

Frequently Asked Questions

What is CVE-2022-35204?
CVE-2022-35204 is a security vulnerability in Vite involving Vite before v2.9.13 vulnerable to directory traversal via crafted URL to victim's service under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Vite versions are affected?
Affected versions include releases prior to 2.9.13, 3.0.0-beta.4 across affected packages: vite.
What version fixes CVE-2022-35204?
Upgrading to 2.9.13, 3.0.0-beta.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is vite affected?
Yes, vite is affected in releases prior to 2.9.13, 3.0.0-beta.4. Upgrade your dependency to 2.9.13, 3.0.0-beta.4 or later.
What is the CVSS score of CVE-2022-35204?
CVE-2022-35204 has a CVSS v3.1 base score of 8.6 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N.
What CWE is associated with CVE-2022-35204?
CVE-2022-35204 is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.).
How can I check npm dependencies for CVE-2022-35204?
Run the dependency tree command: 'npm ls vite'. 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-mv48-hcvh-8jj8",
  "modified" : "2024-09-23T19:18:33Z",
  "published" : "2022-08-19T00:00:20Z",
  "aliases" : [ "CVE-2022-35204" ],
  "summary" : "Vite before v2.9.13 vulnerable to directory traversal via crafted URL to victim's service",
  "details" : "Vite before v2.9.13 was discovered to allow attackers to perform a directory traversal via a crafted URL to the victim's service.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "vite"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.9.13"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "vite"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.0.0-alpha.0"
      }, {
        "fixed" : "3.0.0-beta.4"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-35204"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/vitejs/vite/issues/8498"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/vitejs/vite/commit/6851009e6725b17608113a5a63474280075cae1c"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/vitejs/vite/commit/e109d64331d9fa57753832762c3573c3532a6947"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/vitejs/vite"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/vitejs/vite/releases/tag/v2.9.13"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/vitejs/vite/releases/tag/v3.0.0-beta.4"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-08-30T20:17:43Z",
    "nvd_published_at" : "2022-08-18T19:15:00Z"
  }
}