The vulnerability allows an attacker to read arbitrary files on a developer's machine if the Vite dev server is exposed to the network. This is due to a missing security check in the WebSocket handling logic.
The attack path begins when an attacker connects to the Vite dev server's WebSocket, bypassing standard browser Origin-based security by omitting the header. From there, they can send a specially crafted message to invoke the DevEnvironment.fetchModule method. This method is intended for Hot Module Replacement (HMR) but was insecurely exposed.
The fetchModule method, in turn, calls the internal loadAndTransform function to retrieve the requested module's content. The core of the vulnerability lies here: the loadAndTransform function did not enforce the server.fs.allow filesystem access control policy when called from the WebSocket path. This allowed an attacker to request any file on the system using a file:// URL, and Vite would read and return its contents.
The patch addresses this in two ways: first, it disables the fetchModule method for all default client-side environments, effectively closing the primary attack vector. Second, it refactors the loadAndTransform function to always perform the filesystem access check unless explicitly told not to via a new skipFsCheck flag, which is only intended for trusted server-to-server communication.