Refer to docs https://vite.dev/config/server-options.html#server-fs-allow for configurations and more details.
它说C:/Users is outside of Vite serving allow list ,那么下面给的C:/Users/TY/Desktop/cve/vite浠绘剰鏂囦欢璇讳竴鍫哻ve/vite6.2.5-project应该就是allow list,那么我们便可能通过目录穿越实现任意文件读取。
returnfunctionviteServePublicMiddleware(req, res, next) { // To avoid the performance impact of `existsSync` on every request, we check against an // in-memory set of known public files. This set is updated on restarts. // also skip import request and internal requests `/@fs/ /@vite-client` etc... if ( (publicFiles && !publicFiles.has(toFilePath(req.url!))) || isImportRequest(req.url!) || isInternalRequest(req.url!) || // for `/public-file.js?url` to be transformed urlRE.test(req.url!) ) { returnnext() } serve(req, res, next) }
returnfunctionviteServeRawFsMiddleware(req, res, next) { // In some cases (e.g. linked monorepos) files outside of root will // reference assets that are also out of served root. In such cases // the paths are rewritten to `/@fs/` prefixed paths and must be served by // searching based from fs root. if (req.url!.startsWith(FS_PREFIX)) { const url = newURL(req.url!, 'http://example.com') const pathname = decodeURI(url.pathname) // restrict files outside of `fs.allow` if ( !ensureServingAccess( slash(path.resolve(fsPathFromId(pathname))), server, res, next, ) ) { return }
let newPathname = pathname.slice(FS_PREFIX.length) if (isWindows) newPathname = newPathname.replace(/^[A-Z]:/i, '')
exportfunctionensureServingAccess( url: string, server: ViteDevServer, res: ServerResponse, next: Connect.NextFunction, ): boolean { if (isFileServingAllowed(url, server)) { returntrue } if (isFileReadable(cleanUrl(url))) { const urlMessage = `The request url "${url}" is outside of Vite serving allow list.` const hintMessage = ` ${server.config.server.fs.allow.map((i) => `- ${i}`).join('\n')} Refer to docs https://vite.dev/config/server-options.html#server-fs-allow for configurations and more details.`
server.config.logger.error(urlMessage) server.config.logger.warnOnce(hintMessage + '\n') res.statusCode = 403 res.write(renderRestrictedErrorHTML(urlMessage + '\n' + hintMessage)) res.end() } else { // if the file doesn't exist, we shouldn't restrict this path as it can // be an API call. Middlewares would issue a 404 if the file isn't handled next() } returnfalse }