Skip to content

Conversation

@renovate
Copy link
Contributor

@renovate renovate bot commented Sep 12, 2023

This PR contains the following updates:

Package Change Age Confidence
vite (source) 4.4.94.5.3 age confidence
vite (source) 4.3.54.5.3 age confidence
vite (source) 4.3.94.5.3 age confidence

GitHub Vulnerability Alerts

CVE-2023-49293

Summary

When Vite's HTML transformation is invoked manually via server.transformIndexHtml, the original request URL is passed in unmodified, and the html being transformed contains inline module scripts (<script type="module">...</script>), it is possible to inject arbitrary HTML into the transformed output by supplying a malicious URL query string to server.transformIndexHtml.

Impact

Only apps using appType: 'custom' and using the default Vite HTML middleware are affected. The HTML entry must also contain an inline script. The attack requires a user to click on a malicious URL while running the dev server. Restricted files aren't exposed to the attacker.

Patches

Fixed in [email protected], [email protected], [email protected]

Details

Suppose index.html contains an inline module script:

<script type="module">
  // Inline script
</script>

This script is transformed into a proxy script like

<script type="module" src="/index.html?html-proxy&index=0.js"></script>

due to Vite's HTML plugin:

https://github.com/vitejs/vite/blob/7fd7c6cebfcad34ae7021ebee28f97b1f28ef3f3/packages/vite/src/node/plugins/html.ts#L429-L465

When appType: 'spa' | 'mpa', Vite serves HTML itself, and htmlFallbackMiddleware rewrites req.url to the canonical path of index.html,

https://github.com/vitejs/vite/blob/73ef074b80fa7252e0c46a37a2c94ba8cba46504/packages/vite/src/node/server/middlewares/htmlFallback.ts#L44-L47

so the url passed to server.transformIndexHtml is /index.html.

However, if appType: 'custom', HTML is served manually, and if server.transformIndexHtml is called with the unmodified request URL (as the SSR docs suggest), then the path of the transformed html-proxy script varies with the request URL. For example, a request with path / produces

<script type="module" src="/@&#8203;id/__x00__/index.html?html-proxy&index=0.js"></script>

It is possible to abuse this behavior by crafting a request URL to contain a malicious payload like

"></script><script>alert('boom')</script>

so a request to http://localhost:5173/?%22%3E%3C/script%3E%3Cscript%3Ealert(%27boom%27)%3C/script%3E produces HTML output like

<script type="module" src="/@&#8203;id/__x00__/?"></script><script>alert("boom")</script>?html-proxy&index=0.js"></script>

which demonstrates XSS.

PoC

Detailed Impact

This will probably predominantly affect development-mode SSR, where vite.transformHtml is called using the original req.url, per the docs:

https://github.com/vitejs/vite/blob/7fd7c6cebfcad34ae7021ebee28f97b1f28ef3f3/docs/guide/ssr.md?plain=1#L114-L126

However, since this vulnerability affects server.transformIndexHtml, the scope of impact may be higher to also include other ad-hoc calls to server.transformIndexHtml from outside of Vite's own codebase.

My best guess at bisecting which versions are vulnerable involves the following test script

import fs from 'node:fs/promises';
import * as vite from 'vite';

const html = `
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
  </head>
  <body>
    <script type="module">
      // Inline script
    </script>
  </body>
</html>
`;
const server = await vite.createServer({ appType: 'custom' });
const transformed = await server.transformIndexHtml('/?%22%3E%3C/script%3E%3Cscript%3Ealert(%27boom%27)%3C/script%3E', html);
console.log(transformed);
await server.close();

and using it I was able to narrow down to #​13581. If this is correct, then vulnerable Vite versions are 4.4.0-beta.2 and higher (which includes 4.4.0).

CVE-2024-23331

Summary

Vite dev server option server.fs.deny can be bypassed on case-insensitive file systems using case-augmented versions of filenames. Notably this affects servers hosted on Windows.

This bypass is similar to https://nvd.nist.gov/vuln/detail/CVE-2023-34092 -- with surface area reduced to hosts having case-insensitive filesystems.

Patches

Fixed in [email protected], [email protected], [email protected], [email protected]

Details

Since picomatch defaults to case-sensitive glob matching, but the file server doesn't discriminate; a blacklist bypass is possible.

See picomatch usage, where nocase is defaulted to false: https://github.com/vitejs/vite/blob/v5.1.0-beta.1/packages/vite/src/node/server/index.ts#L632

By requesting raw filesystem paths using augmented casing, the matcher derived from config.server.fs.deny fails to block access to sensitive files.

PoC

Setup

  1. Created vanilla Vite project using npm create vite@latest on a Standard Azure hosted Windows 10 instance.
  2. Created dummy secret files, e.g. custom.secret and production.pem
  3. Populated vite.config.js with
export default { server: { fs: { deny: ['.env', '.env.*', '*.{crt,pem}', 'custom.secret'] } } }

Reproduction

  1. curl -s http://20.12.242.81:5173/@&#8203;fs//
    • Descriptive error page reveals absolute filesystem path to project root
  2. curl -s http://20.12.242.81:5173/@&#8203;fs/C:/Users/darbonzo/Desktop/vite-project/vite.config.js
    • Discoverable configuration file reveals locations of secrets
  3. curl -s http://20.12.242.81:5173/@&#8203;fs/C:/Users/darbonzo/Desktop/vite-project/custom.sEcReT
    • Secrets are directly accessible using case-augmented version of filename

Proof
Screenshot 2024-01-19 022736

Impact

Who

  • Users with exposed dev servers on environments with case-insensitive filesystems

What

  • Files protected by server.fs.deny are both discoverable, and accessible

CVE-2024-31207

Summary

Vite dev server option server.fs.deny did not deny requests for patterns with directories. An example of such a pattern is /foo/**/*.

Impact

Only apps setting a custom server.fs.deny that includes a pattern with directories, and explicitly exposing the Vite dev server to the network (using --host or server.host config option) are affected.

Patches

Fixed in [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]

Details

server.fs.deny uses picomatch with the config of { matchBase: true }. matchBase only matches the basename of the file, not the path due to a bug (https://github.com/micromatch/picomatch/issues/89). The vite config docs read like you should be able to set fs.deny to glob with picomatch. Vite also does not set { dot: true } and that causes dotfiles not to be denied unless they are explicitly defined.

Reproduction

Set fs.deny to ['**/.git/**'] and then curl for /.git/config.

  • with matchBase: true, you can get any file under .git/ (config, HEAD, etc).
  • with matchBase: false, you cannot get any file under .git/ (config, HEAD, etc).

CVE-2023-34092

The issue involves a security vulnerability in Vite where the server options can be bypassed using a double forward slash (//). This vulnerability poses a potential security risk as it can allow unauthorized access to sensitive directories and files.

Steps to Fix. Update Vite: Ensure that you are using the latest version of Vite. Security issues like this are often fixed in newer releases.\n2. Secure the server configuration: In your vite.config.js file, review and update the server configuration options to restrict access to unauthorized requests or directories.

Impact

Only users explicitly exposing the Vite dev server to the network (using --host or the server.host config option) are affected and only files in the immediate Vite project root folder could be exposed.\n\n### Patches\nFixed in vite@4.3.9, vite@4.2.3, vite@4.1.5, vite@4.0.5 and in the latest minors of the previous two majors, vite@3.2.7 and vite@2.9.16.

Details

Vite serves the application with under the root-path of the project while running on the dev mode. By default, Vite uses the server option fs.deny to protect sensitive files. But using a simple double forward-slash, we can bypass this restriction. \n\n### PoC\n1. Create a new latest project of Vite using any package manager. (here I'm using react and vue templates and pnpm for testing)\n2. Serve the application on dev mode using pnpm run dev.\n3. Directly access the file via url using double forward-slash (//) (e.g: //.env, //.env.local)\n4. The server option fs.deny was successfully bypassed.

Proof Images: proof-1\nproof-2


Release Notes

vitejs/vite (vite)

v4.5.3

Compare Source

Please refer to CHANGELOG.md for details.

v4.5.2

Compare Source

Please refer to CHANGELOG.md for details.

v4.5.1

Compare Source

Please refer to CHANGELOG.md for details.

v4.5.0

Compare Source

See 4.5.0 changelog

v4.4.12

Compare Source

Please refer to CHANGELOG.md for details.

v4.4.11

Compare Source

See 4.4.11 changelog

v4.4.10

Compare Source

Please refer to CHANGELOG.md for details.


Configuration

📅 Schedule: Branch creation - "" (UTC), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about these updates again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch 2 times, most recently from c68e12a to 71d9acf Compare November 17, 2023 10:02
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch from 71d9acf to 17bd689 Compare December 6, 2023 01:54
@renovate renovate bot changed the title chore(deps): update dependency vite to v4.3.9 [security] chore(deps): update dependency vite [security] Dec 6, 2023
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch 2 times, most recently from 7ebd699 to 918159b Compare January 20, 2024 04:06
@renovate renovate bot changed the title chore(deps): update dependency vite [security] chore(deps): update dependency vite to v4.5.2 [security] Jan 20, 2024
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch 2 times, most recently from 1666af0 to 7d47481 Compare February 4, 2024 11:29
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch from 7d47481 to 468df4a Compare February 25, 2024 11:08
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch from 468df4a to 85bb341 Compare March 12, 2024 11:45
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch 2 times, most recently from 82e9510 to 33ad7fb Compare March 24, 2024 17:02
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch from 33ad7fb to d0232a1 Compare April 3, 2024 23:07
@renovate renovate bot changed the title chore(deps): update dependency vite to v4.5.2 [security] chore(deps): update dependency vite [security] Apr 3, 2024
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch from d0232a1 to f96742c Compare April 4, 2024 01:16
@renovate renovate bot changed the title chore(deps): update dependency vite [security] chore(deps): update dependency vite to v4.5.3 [security] Apr 4, 2024
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch from f96742c to a27a977 Compare April 14, 2024 08:36
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch 2 times, most recently from 9a6d3db to 84b1323 Compare April 25, 2024 08:20
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch from 84b1323 to e9ad6bb Compare June 4, 2024 12:43
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch from e9ad6bb to c3295d4 Compare July 21, 2024 14:15
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch from c3295d4 to b7e5fe9 Compare August 6, 2024 08:50
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch 2 times, most recently from 96019f3 to 1a61e46 Compare September 3, 2024 02:05
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch from 1a61e46 to eda3c0f Compare October 9, 2024 09:06
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch from eda3c0f to c5be4fb Compare December 2, 2024 08:35
@renovate
Copy link
Contributor Author

renovate bot commented Dec 8, 2024

Autoclosing Skipped

This PR has been flagged for autoclosing. However, it is being skipped due to the branch being already modified. Please close/delete it manually or report a bug if you think this is in error.

@renovate renovate bot changed the title chore(deps): update dependency vite to v4.5.3 [security] chore(deps): update dependency vite to v4.5.3 [security] - abandoned Dec 8, 2024
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch from c5be4fb to 5c8f2ea Compare December 8, 2024 22:30
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch 3 times, most recently from 94154fb to 0987c80 Compare March 17, 2025 16:31
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch from 0987c80 to 2086993 Compare April 1, 2025 11:11
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch from 2086993 to a4352ce Compare April 8, 2025 14:17
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch from a4352ce to 35960e9 Compare April 24, 2025 06:52
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch from 35960e9 to dd98019 Compare May 19, 2025 19:59
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch 2 times, most recently from c7fdd6e to d068f1e Compare June 4, 2025 10:45
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch from d068f1e to 9961acf Compare June 22, 2025 13:08
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch from 9961acf to c2836c7 Compare July 2, 2025 18:26
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch 2 times, most recently from d74ec26 to ee61d47 Compare August 13, 2025 16:57
@renovate renovate bot changed the title fix(deps): update dependency vite to v4.5.3 [security] fix(deps): update dependency vite to v4.5.14 [security] Aug 13, 2025
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch from ee61d47 to 9b84e78 Compare August 19, 2025 16:04
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch from 9b84e78 to 7856d60 Compare August 31, 2025 10:48
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch from 7856d60 to 9d0d03b Compare September 10, 2025 06:59
@renovate renovate bot changed the title fix(deps): update dependency vite to v4.5.14 [security] fix(deps): update dependency vite [security] Sep 10, 2025
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch 3 times, most recently from f6e2794 to 50ea776 Compare September 10, 2025 22:44
@renovate renovate bot changed the title fix(deps): update dependency vite [security] fix(deps): update dependency vite to v5 [security] Sep 10, 2025
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch from 50ea776 to bc4891b Compare September 25, 2025 21:42
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch from bc4891b to f4e73de Compare October 16, 2025 01:40
@renovate renovate bot changed the title fix(deps): update dependency vite to v5 [security] fix(deps): update dependency vite to v4.5.3 [security] Oct 16, 2025
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch from f4e73de to e5e4cc3 Compare October 21, 2025 14:49
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch from e5e4cc3 to 21ba9f1 Compare November 10, 2025 20:09
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch from 21ba9f1 to 2fe25da Compare November 18, 2025 11:50
@renovate renovate bot force-pushed the renovate/npm-vite-vulnerability branch from 2fe25da to a1c7251 Compare December 3, 2025 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant