The vulnerability in Vite (GHSA-v2wj-q39q-566r) allows an attacker to bypass file access restrictions defined in server.fs.deny by appending query parameters like ?raw or ?import to the requested URL. The root cause of this issue lies in the access control logic which incorrectly performed checks against the full URL, including the query string, instead of just the file path.
The provided patch addresses this vulnerability by modifying the isServerAccessDeniedForTransform and transformMiddleware functions in packages/vite/src/node/server/middlewares/transform.ts. The fix involves using the cleanUrl() utility to strip any query parameters from the request URL before performing the access check with checkLoadingAccess(). This ensures that the server.fs.deny rules are correctly applied to the file path, regardless of any appended queries.
Therefore, during an exploit attempt, the transformMiddleware would be the primary function in the stack trace, as it's the entry point for the vulnerable logic. The isServerAccessDeniedForTransform function is a key helper function that contains the flawed access check, making it a critical indicator of the vulnerability being triggered.