CVE-2024-23331: Vite Vite Dev Server Option `server.fs.deny` Vulnerability

HIGH
Advisory Identifier: GHSA-c24v-8rfc-w8vw
CVSS 7.5
CWE-284 CWE-200 CWE-178
Published
Advisory Summary

CVE-2024-23331 is a HIGH (CVSS 7.5) vite dev server option `server.fs.deny` vulnerability (CWE-284: Improper Access Control) affecting Vite libraries in the npm ecosystem. The issue involves vite dev server option `server.fs.deny` can be bypassed when hosted on case-insensitive filesystem. Remediation is available by upgrading affected packages to version 2.9.17, 3.2.8, 4.5.2, 5.0.12.

CVE-2024-23331 at a Glance

CVE Identifier CVE-2024-23331
GHSA Identifier GHSA-c24v-8rfc-w8vw
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-284: Improper Access Control
Affected Product Vite
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.5

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:U/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 Unchanged (S:U)
Confidentiality High (C:H)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2024-23331

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.17
npm install vite@2.9.17
vite fixed: 3.2.8
npm install vite@3.2.8
vite fixed: 4.5.2
npm install vite@4.5.2
vite fixed: 5.0.12
npm install vite@5.0.12
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-2024-23331, 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.17), 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-284: Improper Access Control, where the product does not restrict or incorrectly restricts access to a resource from an unauthorized actor. 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

### Summary [Vite dev server option](https://vitejs.dev/config/server-options.html#server-fs-deny) `server.fs.deny` can be bypassed on case-insensitive file systems using case-augmented versions of filenames. Notably this affects servers hosted on Windows. This bypass is similar to https://nvd.nist.gov/vuln/detail/CVE-2023-34092 -- with surface area reduced to hosts having case-insensitive filesystems. ### Patches Fixed in vite@5.0.12, vite@4.5.2, vite@3.2.8, vite@2.9.17 ### Details Since `picomatch` defaults to case-sensitive glob matching, but the file server doesn't discriminate; a blacklist bypass is possible. See `picomatch` usage, where `nocase` is defaulted to `false`: https://github.com/vitejs/vite/blob/v5.1.0-beta.1/packages/vite/src/node/server/index.ts#L632 By requesting raw filesystem paths using augmented casing, the matcher derived from `config.server.fs.deny` fails to block access to sensitive files. ### PoC **Setup** 1. Created vanilla Vite project using `npm create vite@latest` on a Standard Azure hosted Windows 10 instance. - `npm run dev -- --host 0.0.0.0` - Publicly accessible for the time being here: http://20.12.242.81:5173/ 2. Created dummy secret files, e.g. `custom.secret` and `production.pem` 3. Populated `vite.config.js` with ```javascript export default { server: { fs: { deny: ['.env', '.env.*', '*.{crt,pem}', 'custom.secret'] } } } ``` **Reproduction** 1. `curl -s http://20.12.242.81:5173/@fs//` - Descriptive error page reveals absolute filesystem path to project root 2. `curl -s http://20.12.242.81:5173/@fs/C:/Users/darbonzo/Desktop/vite-project/vite.config.js` - Discoverable configuration file reveals locations of secrets 3. `curl -s http://20.12.242.81:5173/@fs/C:/Users/darbonzo/Desktop/vite-project/custom.sEcReT` - Secrets are directly accessible using case-augmented version of filename **Proof** ![Screenshot 2024-01-19 022736](https://user-images.githubusercontent.com/907968/298020728-3a8d3c06-fcfd-4009-9182-e842f66a6ea5.png) ### Impact **Who** - Users with exposed dev servers on environments with case-insensitive filesystems **What** - Files protected by `server.fs.deny` are both discoverable, and accessible

CVE-2024-23331 Affected Vite Versions

4 component(s)
Fixed Versions:
2.9.173.2.84.5.25.0.12
Product / Package Ecosystem Affected Versions Fixed Version
vite
npm
≥ 2.7.0
< 2.9.17
2.9.17
vite
npm
≥ 3.0.0
< 3.2.8
3.2.8
vite
npm
≥ 4.0.0
< 4.5.2
4.5.2
vite
npm
≥ 5.0.0
< 5.0.12
5.0.12

References

Frequently Asked Questions

What is CVE-2024-23331?
CVE-2024-23331 is a security vulnerability in Vite involving Vite dev server option `server.fs.deny` can be bypassed when hosted on case-insensitive filesystem under CWE-284: Improper Access Control.
Which Vite versions are affected?
Affected versions include releases prior to 2.9.17, 3.2.8, 4.5.2, 5.0.12 across affected packages: vite.
What version fixes CVE-2024-23331?
Upgrading to 2.9.17, 3.2.8, 4.5.2, 5.0.12 (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.17, 3.2.8, 4.5.2, 5.0.12. Upgrade your dependency to 2.9.17, 3.2.8, 4.5.2, 5.0.12 or later.
What is the CVSS score of CVE-2024-23331?
CVE-2024-23331 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N.
What CWE is associated with CVE-2024-23331?
CVE-2024-23331 is classified under CWE-284: Improper Access Control (The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.).
How can I check npm dependencies for CVE-2024-23331?
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-c24v-8rfc-w8vw",
  "modified" : "2024-01-19T21:58:47Z",
  "published" : "2024-01-19T21:58:47Z",
  "aliases" : [ "CVE-2024-23331" ],
  "summary" : "Vite dev server option `server.fs.deny` can be bypassed when hosted on case-insensitive filesystem",
  "details" : "### Summary\n[Vite dev server option](https://vitejs.dev/config/server-options.html#server-fs-deny) `server.fs.deny` can be bypassed on case-insensitive file systems using case-augmented versions of filenames. Notably this affects servers hosted on Windows.\n\nThis bypass is similar to https://nvd.nist.gov/vuln/detail/CVE-2023-34092 -- with surface area reduced to hosts having case-insensitive filesystems.\n\n### Patches\nFixed in vite@5.0.12, vite@4.5.2, vite@3.2.8, vite@2.9.17\n\n### Details\nSince `picomatch` defaults to case-sensitive glob matching, but the file server doesn't discriminate; a blacklist bypass is possible. \n\nSee `picomatch`  usage, where `nocase` is defaulted to `false`: https://github.com/vitejs/vite/blob/v5.1.0-beta.1/packages/vite/src/node/server/index.ts#L632\n\nBy requesting raw filesystem paths using augmented casing, the matcher derived from `config.server.fs.deny` fails to block access to sensitive files. \n\n### PoC\n**Setup**\n1. Created vanilla Vite project using `npm create vite@latest` on a Standard Azure hosted Windows 10 instance. \n    - `npm run dev -- --host 0.0.0.0`\n    - Publicly accessible for the time being here: http://20.12.242.81:5173/ \n2. Created dummy secret files, e.g. `custom.secret` and `production.pem`\n3. Populated `vite.config.js` with\n```javascript\nexport default { server: { fs: { deny: ['.env', '.env.*', '*.{crt,pem}', 'custom.secret'] } } }\n```\n\n**Reproduction**\n1. `curl -s http://20.12.242.81:5173/@fs//`\n    - Descriptive error page reveals absolute filesystem path to project root\n2. `curl -s http://20.12.242.81:5173/@fs/C:/Users/darbonzo/Desktop/vite-project/vite.config.js`\n    - Discoverable configuration file reveals locations of secrets\n3. `curl -s http://20.12.242.81:5173/@fs/C:/Users/darbonzo/Desktop/vite-project/custom.sEcReT`\n    - Secrets are directly accessible using case-augmented version of filename\n\n**Proof**\n![Screenshot 2024-01-19 022736](https://user-images.githubusercontent.com/907968/298020728-3a8d3c06-fcfd-4009-9182-e842f66a6ea5.png)\n\n### Impact\n**Who**\n- Users with exposed dev servers on environments with case-insensitive filesystems\n\n**What**\n- Files protected by `server.fs.deny` are both discoverable, and accessible",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "vite"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.7.0"
      }, {
        "fixed" : "2.9.17"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 2.9.16"
    }
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "vite"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.0.0"
      }, {
        "fixed" : "3.2.8"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 3.2.7"
    }
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "vite"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0"
      }, {
        "fixed" : "4.5.2"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 4.5.1"
    }
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "vite"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "5.0.0"
      }, {
        "fixed" : "5.0.12"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 5.0.11"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/vitejs/vite/security/advisories/GHSA-c24v-8rfc-w8vw"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-34092"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-23331"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/vitejs/vite/commit/0cd769c279724cf27934b1270fbdd45d68217691"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/vitejs/vite/commit/91641c4da0a011d4c5352e88fc68389d4e1289a5"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/vitejs/vite/commit/a26c87d20f9af306b5ce3ff1648be7fa5146c278"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/vitejs/vite/commit/eeec23bbc9d476c54a3a6d36e78455867185a7cb"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/vitejs/vite"
  }, {
    "type" : "WEB",
    "url" : "https://vitejs.dev/config/server-options.html#server-fs-deny"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-178", "CWE-200", "CWE-284" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-01-19T21:58:47Z",
    "nvd_published_at" : "2024-01-19T20:15:14Z"
  }
}