CVE-2024-45811 server.fs.deny bypassed when using ?import&raw in vite

Medium 4.8 Published Updated

Attackers can bypass file access restrictions in Vite to read arbitrary files from the server by appending specific query parameters.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Local or same network only
Victim action needed
A user has to click or open something
Fix
Available

What is CVE-2024-45811?

CVE-2024-45811 is a medium-severity path traversal vulnerability in vitejs vite, published on 17 Sep 2024. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.

Official description

Vite a frontend build tooling framework for javascript. In affected versions the contents of arbitrary files can be returned to the browser. `@fs` denies access to files outside of Vite serving allow list. Adding `?import&raw` to the URL bypasses this limitation and returns the file content if it exists. This issue has been patched in versions 5.4.6, 5.3.6, 5.2.14, 4.5.5, and 3.2.11. Users are advised to upgrade. There are no known workarounds for this vulnerability.

Weakness: CWE-284, CWE-200

Which versions are affected by CVE-2024-45811?

12 open source packages ship an affected version, including vite.

PackageAffectedFixed in
vite npmAll versions3.2.11
vite npmAll versions3.2.11
vite npmFrom 4.0.04.5.4
vite npmFrom 4.0.04.5.4
vite npmFrom 5.0.05.1.8
vite npmFrom 5.0.05.1.8
6 more packages
vite npmFrom 5.2.05.2.14
vite npmFrom 5.2.05.2.14
vite npmFrom 5.3.05.3.6
vite npmFrom 5.3.05.3.6
vite npmFrom 5.4.05.4.6
vite npmFrom 5.4.05.4.6

How do I fix CVE-2024-45811?

Upgrade vite to a fixed version for your release line: 3.2.11, 4.5.4, 5.1.8 or 5.2.14.

Upgrade, and resolve every user-supplied path against an allowed base folder before opening it. More about Path traversal.

Is CVE-2024-45811 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-45811 exists.

Sources

Also known as GHSA-9cwx-2883-4wfx, MINI-vr88-xv87-mjx9.

Is CVE-2024-45811 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free