Vite Dev Server's CVSS 9.1 Critical Flaw Lets Attackers Inject Code via `--host`
Because `--host` is a routine part of mobile preview and LAN collaboration, this flaw turns a standard dev workflow into a remote code execution surface. With no CVE number, automated scanners may not catch it, leaving exposed dev servers vulnerable until a manual upgrade happens.
Vite's dev server generates placeholder modules for browser-externalized Node builtins and unresolved optional peer dependencies. In affected versions, the request path that becomes a module ID is concatenated directly into a JavaScript template literal. An attacker can include `${}` in that ID, turning it into a live interpolation expression that executes when the module is parsed. A payload such as `x${(globalThis.INJ=1)}y` sets a global variable, and the same pattern can run any code in the victim's browser context.
The vulnerable versions span 4.0 to 8.3.6, covering all actively maintained majors. The exposure requires the developer to start the dev server with `--host 0.0.0.0` or set `server.host`, which is common for LAN debugging and real-device previews. A reproduction on Vite 7.3.7 confirmed the injection; the fixed 7.3.8 release moves the ID into a double-quoted string literal before interpolation, ensuring `${}` stays inert.
The advisory has no CVE number yet, so npm audit and Dependabot did not flag it immediately, and scanners relying on CVE/OSV feeds may miss it. No fix exists for 4.x and 5.x, so affected projects must upgrade to a patched version or stop exposing the dev server.
The absence of a CVE number creates a window where the vulnerability is invisible to automated dependency scanners, making human attention the only defense.
The reliance on `--host` for everyday tasks like phone previews and LAN pairing means many teams are unknowingly exposing a dev server that they assume is local-only.
The fix's technique of isolating user input in a double-quoted string before template interpolation is a simple, effective pattern that highlights how easy it is to slip into template literal injection.
This vulnerability is hidden deep enough. URL parameters can be spliced into template strings, and once --host is enabled, it's like leaving the door wide open. The reproduction and self-check conditions are all provided. After reading it, the only feeling is: upgrade the version immediately.