{"slug": "vite-remote-code-execution", "title": "Vite Remote Code Execution", "summary": "Vite patched a remote code execution vulnerability in versions 8.3.7, 8.2.5 and 8.1.7, where unescaped module IDs in the `__vite-browser-external` and `__vite-optional-peer-dep` virtual modules let an attacker inject code into the dev server. The flaw only affects apps that expose the Vite dev server to the network via `--host` or the `server.host` config option, and the fix for the v8 code lives in Rolldown 1.2.17 (for Vite 8.3.7 and 8.2.5) and Rolldown 1.1.7 (for Vite 8.1.7). A proof of concept showed an injected `import '/@fs/tmp/decoy-secret.txt'` pulled a file outside the serving allow list into the module graph, after which a plain `GET /@fs/tmp/decoy-secret.txt` returned its contents.", "body_md": "## Repository navigation\n\n# Remote code execution using `__vite-browser-external` virtual module\n\nThis report was submitted with AI assistance\n\n## Description\n\n### Summary\n\nBy sending an HTTP request to the dev server, a arbitrary code execution was possible.\n\n### Impact\n\nOnly apps that match the following condition are affected:\n\n- explicitly exposes the Vite dev server to the network (using `--host` or[`server.host` config option](https://vitejs.dev/config/server-options.html#server-host) )\n\n### Details\n\nVite's resolver plugin has `__vite-browser-external:<suffix>` virtual module and `__vite-optional-peer-dep:<suffix>` virtual module. These modules embedded the module ID, which is derived from the URL, without escaping. The `<suffix>` can be any value, so any code was able to be injected in those modules.\n\nSince Vite trusts the module code, there was two problems with this injection.\n\nFirst, the modules referenced by a module are allowed for the `server.fs` check. For example, if the attacker injects `import '/path/to/some-secret-file.txt'`, `/path/to/some-secret-file.txt` can be fetched.\n\nSecond, Vite uses `eval` to extract the value in the module code for `new Worker` and `import.meta.glob`. By using that functionality, the attacker can make Vite evaluate the injected code on the server. Vite prevents some module / global variables like `exports`, `require` to avoid bugs, but because this is not a security boundary, there's a bypass like `globalThis.process.getBuiltinModule`.\n\n### PoC\n\n```\nprintf 'CANARY-SECRET-not-valid-js\\n' > /tmp/decoy-secret.txt   # outside the project\nvite\n```\n\n`/tmp/decoy-secret.txt` stands in for any sensitive file outside the allow list.\n\n1. Check that the target is correctly blocked. `GET /@fs/tmp/decoy-secret.txt` returns 403 Restricted (\"outside of Vite serving allow list\").\n2. Perform the injection. Send a request carrying the crafted id (it is shown decoded. \\n are real newlines in the sent URL, percent-encoded on the wire):\nThis pulls\n\n```\nGET /@id/__vite-browser-external:`);}});\nimport '/@fs/tmp/decoy-secret.txt';\nvar z=new Proxy({}, {get(_, key) {throw new Error(`?import\n```\n\n `/tmp/decoy-secret.txt` into the module graph.\n3. Extract the file. `GET /@fs/tmp/decoy-secret.txt` returns the content in the body (`CANARY-SECRET-not-valid-js` ).\n\n### Notes on the fixes\n\nThe vulnerable code in v8 lives in the Rolldown binary. The code is only meant to be used by Vite and thus the report is not linked to Rolldown. Vite 8.3.7 and Vite 8.2.5 relies on the fix in Rolldown 1.2.17. Vite 8.1.7 relies on the fix in Rolldown 1.1.7.", "url": "https://wpnews.pro/news/vite-remote-code-execution", "canonical_source": "https://github.com/vitejs/vite/security/advisories/GHSA-p4f5-76q4-ffq7", "published_at": "2026-11-19 07:23:41+00:00", "updated_at": "2026-11-19 07:44:34.666537+00:00", "lang": "en", "topics": ["developer-tools"], "entities": ["Vite", "Rolldown"], "also_reported_by": [], "takeaway": "Unescaped module IDs in Vite's `__vite-browser-external` and `__vite-optional-peer-dep` virtual modules allowed injected imports to bypass the `server.fs` allow list and reach `eval`-based extraction, so upgrade to Vite 8.3.7, 8.2.5 or 8.1.7 (Rolldown 1.2.17 or 1.1.7) and avoid exposing the dev serv", "recommendation": {"advice": "Upgrade to Vite 8.3.7, 8.2.5 or 8.1.7 and stop exposing the dev server via `--host`; the PoC read a file outside the allow list through an injected virtual-module import.", "playbook": "agent-security", "playbook_url": "https://wpnews.pro/playbooks/agent-security"}, "alternates": {"html": "https://wpnews.pro/news/vite-remote-code-execution", "markdown": "https://wpnews.pro/news/vite-remote-code-execution.md", "text": "https://wpnews.pro/news/vite-remote-code-execution.txt", "jsonld": "https://wpnews.pro/news/vite-remote-code-execution.jsonld"}}