Vite dev server option server.fs.deny can be bypassed when hosted on case-insensitive filesystem
#45
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
⚠️
dependabot-gitlabhas detected security vulnerability forvitein path:/, manifest_file:/package.jsonbut was unable to update it! ⚠️GHSA-c24v-8rfc-w8vw,CVE-2024-23331Description
Summary
Vite dev server option
server.fs.denycan 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
picomatchdefaults to case-sensitive glob matching, but the file server doesn't discriminate; a blacklist bypass is possible.See
picomatchusage, wherenocaseis defaulted tofalse: https://github.com/vitejs/vite/blob/v5.1.0-beta.1/packages/vite/src/node/server/index.ts#L632By requesting raw filesystem paths using augmented casing, the matcher derived from
config.server.fs.denyfails to block access to sensitive files.PoC
Setup
npm create vite@lateston a Standard Azure hosted Windows 10 instance.npm run dev -- --host 0.0.0.0custom.secretandproduction.pemvite.config.jswithReproduction
curl -s http://20.12.242.81:5173/@fs//curl -s http://20.12.242.81:5173/@fs/C:/Users/darbonzo/Desktop/vite-project/vite.config.jscurl -s http://20.12.242.81:5173/@fs/C:/Users/darbonzo/Desktop/vite-project/custom.sEcReTProof

Impact
Who
What
server.fs.denyare both discoverable, and accessibleReferences