Packages / vite / Security

HighVulnerabilityGHSA-353f-5xf4-qw67CVE-2023-34092Published 6 Jun 2023

Vite Server Options (server.fs.deny) can be bypassed using double forward-slash (//)

Affected releases · vite

  • 4.x4.0.0 – 4.3.8Fixed in 4.3.9
  • 3.x3.0.2 – 3.2.6Fixed in 3.2.7
  • 2.x2.0.0 – 2.9.15Fixed in 2.9.16
  • 0.20.x and older0.1.0 – 0.20.10No fix, no longer updated

On 4.x, the newest line:

npm install vite@4.3.9
8.x
  1. Not affected

    8.0.0 – 8.3.5

    34 releases, latest

4.x
  1. Affected

    4.0.0 – 4.0.4

    5 releases

  2. Fixed

    4.0.5

    1 release

  3. Affected

    4.1.0 – 4.1.4

    5 releases

  4. Fixed

    4.1.5

    1 release

  5. Affected

    4.2.0 – 4.2.2

    3 releases

  6. Fixed

    4.2.3

    1 release

  7. Affected

    4.3.0 – 4.3.8

    9 releases

  8. Fixed

    4.3.9 – 4.5.14

    28 releases

3.x
  1. Not affected

    3.0.0 – 3.0.1

    2 releases

  2. Affected

    3.0.2 – 3.2.6

    24 releases

  3. Fixed

    3.2.7 – 3.2.11

    4 releases

2.x
  1. Affected

    2.0.0 – 2.9.15

    94 releases

  2. Fixed

    2.9.16 – 2.9.18

    3 releases

0.x
  1. Affected

    0.1.0 – 0.20.10

    78 releases

440 stable releases of vite, oldest to newest, one row per major.

Is your project affected?

Paste your package.json, or type the range you declare for vite. It is read in your browser and sent nowhere.

What happens

The issue involves a security vulnerability in Vite where the server options can be bypassed using a double forward slash (//). This vulnerability poses a potential security risk as it can allow unauthorized access to sensitive directories and files.

Steps to Fix. Update Vite: Ensure that you are using the latest version of Vite. Security issues like this are often fixed in newer releases.\n2. Secure the server configuration: In your vite.config.js file, review and update the server configuration options to restrict access to unauthorized requests or directories.

Impact

Only users explicitly exposing the Vite dev server to the network (using --host or the server.host config option) are affected and only files in the immediate Vite project root folder could be exposed.\n\n### Patches\nFixed in vite@4.3.9, vite@4.2.3, vite@4.1.5, vite@4.0.5 and in the latest minors of the previous two majors, vite@3.2.7 and vite@2.9.16.

Details

Vite serves the application with under the root-path of the project while running on the dev mode. By default, Vite uses the server option fs.deny to protect sensitive files. But using a simple double forward-slash, we can bypass this restriction. \n\n### PoC\n1. Create a new latest project of Vite using any package manager. (here I'm using react and vue templates and pnpm for testing)\n2. Serve the application on dev mode using pnpm run dev.\n3. Directly access the file via url using double forward-slash (//) (e.g: //.env, //.env.local)\n4. The server option fs.deny was successfully bypassed.

Proof Images: proof-1\nproof-2