Tresjs / leches

🍰 Tasty GUI for Vue controls
https://tresleches.tresjs.org/
MIT License
28 stars 5 forks source link

chore(deps): update dependency vite to v5.0.13 [security] #99

Open renovate[bot] opened 6 months ago

renovate[bot] commented 6 months ago

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
vite (source) 5.0.4 -> 5.0.13 age adoption passing 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 vite@5.0.5, vite@4.5.1, vite@4.4.12

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 vite@5.0.12, vite@4.5.2, vite@3.2.8, vite@2.9.17

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

What

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 vite@5.2.6, vite@5.1.7, vite@5.0.13, vite@4.5.3, vite@3.2.10, vite@2.9.18

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.


Release Notes

vitejs/vite (vite) ### [`v5.0.13`](https://togithub.com/vitejs/vite/releases/tag/v5.0.13) [Compare Source](https://togithub.com/vitejs/vite/compare/v5.0.12...v5.0.13) Please refer to [CHANGELOG.md](https://togithub.com/vitejs/vite/blob/v5.0.13/packages/vite/CHANGELOG.md) for details. ### [`v5.0.12`](https://togithub.com/vitejs/vite/releases/tag/v5.0.12) [Compare Source](https://togithub.com/vitejs/vite/compare/v5.0.11...v5.0.12) Please refer to [CHANGELOG.md](https://togithub.com/vitejs/vite/blob/v5.0.12/packages/vite/CHANGELOG.md) for details. ### [`v5.0.11`](https://togithub.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small5011-2024-01-05-small) [Compare Source](https://togithub.com/vitejs/vite/compare/v5.0.10...v5.0.11) - fix: don't pretransform classic script links ([#​15361](https://togithub.com/vitejs/vite/issues/15361)) ([19e3c9a](https://togithub.com/vitejs/vite/commit/19e3c9a)), closes [#​15361](https://togithub.com/vitejs/vite/issues/15361) - fix: inject `__vite__mapDeps` code before sourcemap file comment ([#​15483](https://togithub.com/vitejs/vite/issues/15483)) ([d2aa096](https://togithub.com/vitejs/vite/commit/d2aa096)), closes [#​15483](https://togithub.com/vitejs/vite/issues/15483) - fix(assets): avoid splitting `,` inside base64 value of `srcset` attribute ([#​15422](https://togithub.com/vitejs/vite/issues/15422)) ([8de7bd2](https://togithub.com/vitejs/vite/commit/8de7bd2)), closes [#​15422](https://togithub.com/vitejs/vite/issues/15422) - fix(html): handle offset magic-string slice error ([#​15435](https://togithub.com/vitejs/vite/issues/15435)) ([5ea9edb](https://togithub.com/vitejs/vite/commit/5ea9edb)), closes [#​15435](https://togithub.com/vitejs/vite/issues/15435) - chore(deps): update dependency strip-literal to v2 ([#​15475](https://togithub.com/vitejs/vite/issues/15475)) ([49d21fe](https://togithub.com/vitejs/vite/commit/49d21fe)), closes [#​15475](https://togithub.com/vitejs/vite/issues/15475) - chore(deps): update tj-actions/changed-files action to v41 ([#​15476](https://togithub.com/vitejs/vite/issues/15476)) ([2a540ee](https://togithub.com/vitejs/vite/commit/2a540ee)), closes [#​15476](https://togithub.com/vitejs/vite/issues/15476) ### [`v5.0.10`](https://togithub.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small5010-2023-12-15-small) [Compare Source](https://togithub.com/vitejs/vite/compare/v5.0.9...v5.0.10) - fix: omit protocol does not require pre-transform ([#​15355](https://togithub.com/vitejs/vite/issues/15355)) ([d9ae1b2](https://togithub.com/vitejs/vite/commit/d9ae1b2)), closes [#​15355](https://togithub.com/vitejs/vite/issues/15355) - fix(build): use base64 for inline SVG if it contains both single and double quotes ([#​15271](https://togithub.com/vitejs/vite/issues/15271)) ([1bbff16](https://togithub.com/vitejs/vite/commit/1bbff16)), closes [#​15271](https://togithub.com/vitejs/vite/issues/15271) ### [`v5.0.9`](https://togithub.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small509-2023-12-14-small) [Compare Source](https://togithub.com/vitejs/vite/compare/v5.0.8...v5.0.9) - fix: htmlFallbackMiddleware for favicon ([#​15301](https://togithub.com/vitejs/vite/issues/15301)) ([c902545](https://togithub.com/vitejs/vite/commit/c902545)), closes [#​15301](https://togithub.com/vitejs/vite/issues/15301) - fix: more stable hash calculation for depsOptimize ([#​15337](https://togithub.com/vitejs/vite/issues/15337)) ([2b39fe6](https://togithub.com/vitejs/vite/commit/2b39fe6)), closes [#​15337](https://togithub.com/vitejs/vite/issues/15337) - fix(scanner): catch all external files for glob imports ([#​15286](https://togithub.com/vitejs/vite/issues/15286)) ([129d0d0](https://togithub.com/vitejs/vite/commit/129d0d0)), closes [#​15286](https://togithub.com/vitejs/vite/issues/15286) - fix(server): avoid chokidar throttling on startup ([#​15347](https://togithub.com/vitejs/vite/issues/15347)) ([56a5740](https://togithub.com/vitejs/vite/commit/56a5740)), closes [#​15347](https://togithub.com/vitejs/vite/issues/15347) - fix(worker): replace `import.meta` correctly for IIFE worker ([#​15321](https://togithub.com/vitejs/vite/issues/15321)) ([08d093c](https://togithub.com/vitejs/vite/commit/08d093c)), closes [#​15321](https://togithub.com/vitejs/vite/issues/15321) - feat: log re-optimization reasons ([#​15339](https://togithub.com/vitejs/vite/issues/15339)) ([b1a6c84](https://togithub.com/vitejs/vite/commit/b1a6c84)), closes [#​15339](https://togithub.com/vitejs/vite/issues/15339) - chore: temporary typo ([#​15329](https://togithub.com/vitejs/vite/issues/15329)) ([7b71854](https://togithub.com/vitejs/vite/commit/7b71854)), closes [#​15329](https://togithub.com/vitejs/vite/issues/15329) - perf: avoid computing paths on each request ([#​15318](https://togithub.com/vitejs/vite/issues/15318)) ([0506812](https://togithub.com/vitejs/vite/commit/0506812)), closes [#​15318](https://togithub.com/vitejs/vite/issues/15318) - perf: temporary hack to avoid fs checks for /[@​react-refresh](https://togithub.com/react-refresh) ([#​15299](https://togithub.com/vitejs/vite/issues/15299)) ([b1d6211](https://togithub.com/vitejs/vite/commit/b1d6211)), closes [#​15299](https://togithub.com/vitejs/vite/issues/15299) ### [`v5.0.8`](https://togithub.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small508-2023-12-12-small) [Compare Source](https://togithub.com/vitejs/vite/compare/v5.0.7...v5.0.8) - perf: cached fs utils ([#​15279](https://togithub.com/vitejs/vite/issues/15279)) ([c9b61c4](https://togithub.com/vitejs/vite/commit/c9b61c4)), closes [#​15279](https://togithub.com/vitejs/vite/issues/15279) - fix: missing warmupRequest in transformIndexHtml ([#​15303](https://togithub.com/vitejs/vite/issues/15303)) ([103820f](https://togithub.com/vitejs/vite/commit/103820f)), closes [#​15303](https://togithub.com/vitejs/vite/issues/15303) - fix: public files map will be updated on add/unlink in windows ([#​15317](https://togithub.com/vitejs/vite/issues/15317)) ([921ca41](https://togithub.com/vitejs/vite/commit/921ca41)), closes [#​15317](https://togithub.com/vitejs/vite/issues/15317) - fix(build): decode urls in CSS files (fix [#​15109](https://togithub.com/vitejs/vite/issues/15109)) ([#​15246](https://togithub.com/vitejs/vite/issues/15246)) ([ea6a7a6](https://togithub.com/vitejs/vite/commit/ea6a7a6)), closes [#​15109](https://togithub.com/vitejs/vite/issues/15109) [#​15246](https://togithub.com/vitejs/vite/issues/15246) - fix(deps): update all non-major dependencies ([#​15304](https://togithub.com/vitejs/vite/issues/15304)) ([bb07f60](https://togithub.com/vitejs/vite/commit/bb07f60)), closes [#​15304](https://togithub.com/vitejs/vite/issues/15304) - fix(ssr): check esm file with normal file path ([#​15307](https://togithub.com/vitejs/vite/issues/15307)) ([1597170](https://togithub.com/vitejs/vite/commit/1597170)), closes [#​15307](https://togithub.com/vitejs/vite/issues/15307) ### [`v5.0.7`](https://togithub.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small507-2023-12-08-small) [Compare Source](https://togithub.com/vitejs/vite/compare/v5.0.6...v5.0.7) - fix: suppress terser warning if minify disabled ([#​15275](https://togithub.com/vitejs/vite/issues/15275)) ([3e42611](https://togithub.com/vitejs/vite/commit/3e42611)), closes [#​15275](https://togithub.com/vitejs/vite/issues/15275) - fix: symbolic links in public dir ([#​15264](https://togithub.com/vitejs/vite/issues/15264)) ([ef2a024](https://togithub.com/vitejs/vite/commit/ef2a024)), closes [#​15264](https://togithub.com/vitejs/vite/issues/15264) - fix(html): skip inlining icon and manifest links ([#​14958](https://togithub.com/vitejs/vite/issues/14958)) ([8ad81b4](https://togithub.com/vitejs/vite/commit/8ad81b4)), closes [#​14958](https://togithub.com/vitejs/vite/issues/14958) - chore: remove unneeded condition in getRealPath ([#​15267](https://togithub.com/vitejs/vite/issues/15267)) ([8e4655c](https://togithub.com/vitejs/vite/commit/8e4655c)), closes [#​15267](https://togithub.com/vitejs/vite/issues/15267) - perf: cache empty optimizer result ([#​15245](https://togithub.com/vitejs/vite/issues/15245)) ([8409b66](https://togithub.com/vitejs/vite/commit/8409b66)), closes [#​15245](https://togithub.com/vitejs/vite/issues/15245) ### [`v5.0.6`](https://togithub.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small506-2023-12-06-small) [Compare Source](https://togithub.com/vitejs/vite/compare/v5.0.5...v5.0.6) - perf: in-memory public files check ([#​15195](https://togithub.com/vitejs/vite/issues/15195)) ([0f9e1bf](https://togithub.com/vitejs/vite/commit/0f9e1bf)), closes [#​15195](https://togithub.com/vitejs/vite/issues/15195) - chore: remove unneccessary eslint-disable-next-line regexp/no-unused-capturing-group ([#​15247](https://togithub.com/vitejs/vite/issues/15247)) ([35a5bcf](https://togithub.com/vitejs/vite/commit/35a5bcf)), closes [#​15247](https://togithub.com/vitejs/vite/issues/15247) ### [`v5.0.5`](https://togithub.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small505-2023-12-04-small) [Compare Source](https://togithub.com/vitejs/vite/compare/v5.0.4...v5.0.5) - fix: emit `vite:preloadError` for chunks without deps ([#​15203](https://togithub.com/vitejs/vite/issues/15203)) ([d8001c5](https://togithub.com/vitejs/vite/commit/d8001c5)), closes [#​15203](https://togithub.com/vitejs/vite/issues/15203) - fix: esbuild glob import resolve error ([#​15140](https://togithub.com/vitejs/vite/issues/15140)) ([676804d](https://togithub.com/vitejs/vite/commit/676804d)), closes [#​15140](https://togithub.com/vitejs/vite/issues/15140) - fix: json error with position ([#​15225](https://togithub.com/vitejs/vite/issues/15225)) ([14be75f](https://togithub.com/vitejs/vite/commit/14be75f)), closes [#​15225](https://togithub.com/vitejs/vite/issues/15225) - fix: proxy html path should be encoded ([#​15223](https://togithub.com/vitejs/vite/issues/15223)) ([5b85040](https://togithub.com/vitejs/vite/commit/5b85040)), closes [#​15223](https://togithub.com/vitejs/vite/issues/15223) - fix(deps): update all non-major dependencies ([#​15233](https://togithub.com/vitejs/vite/issues/15233)) ([ad3adda](https://togithub.com/vitejs/vite/commit/ad3adda)), closes [#​15233](https://togithub.com/vitejs/vite/issues/15233) - fix(hmr): don't consider CSS dep as a circular dep ([#​15229](https://togithub.com/vitejs/vite/issues/15229)) ([5f2cdec](https://togithub.com/vitejs/vite/commit/5f2cdec)), closes [#​15229](https://togithub.com/vitejs/vite/issues/15229) - feat: add '\*.mov' to client.d.ts ([#​15189](https://togithub.com/vitejs/vite/issues/15189)) ([d93a211](https://togithub.com/vitejs/vite/commit/d93a211)), closes [#​15189](https://togithub.com/vitejs/vite/issues/15189) - feat(server): allow disabling built-in shortcuts ([#​15218](https://togithub.com/vitejs/vite/issues/15218)) ([7fd7c6c](https://togithub.com/vitejs/vite/commit/7fd7c6c)), closes [#​15218](https://togithub.com/vitejs/vite/issues/15218) - chore: replace 'some' with 'includes' in resolveEnvPrefix ([#​15220](https://togithub.com/vitejs/vite/issues/15220)) ([ee12f30](https://togithub.com/vitejs/vite/commit/ee12f30)), closes [#​15220](https://togithub.com/vitejs/vite/issues/15220) - chore: update the website url for homepage in package.json ([#​15181](https://togithub.com/vitejs/vite/issues/15181)) ([282bd8f](https://togithub.com/vitejs/vite/commit/282bd8f)), closes [#​15181](https://togithub.com/vitejs/vite/issues/15181) - chore: update vitest to 1.0.0-beta.6 ([#​15194](https://togithub.com/vitejs/vite/issues/15194)) ([2fce647](https://togithub.com/vitejs/vite/commit/2fce647)), closes [#​15194](https://togithub.com/vitejs/vite/issues/15194) - refactor: make HMR agnostic to environment ([#​15179](https://togithub.com/vitejs/vite/issues/15179)) ([0571b7c](https://togithub.com/vitejs/vite/commit/0571b7c)), closes [#​15179](https://togithub.com/vitejs/vite/issues/15179) - refactor: use dedicated regex methods ([#​15228](https://togithub.com/vitejs/vite/issues/15228)) ([0348137](https://togithub.com/vitejs/vite/commit/0348137)), closes [#​15228](https://togithub.com/vitejs/vite/issues/15228) - perf: remove debug only prettifyUrl call ([#​15204](https://togithub.com/vitejs/vite/issues/15204)) ([73e971f](https://togithub.com/vitejs/vite/commit/73e971f)), closes [#​15204](https://togithub.com/vitejs/vite/issues/15204) - perf: skip computing sourceRoot in injectSourcesContent ([#​15207](https://togithub.com/vitejs/vite/issues/15207)) ([1df1fd1](https://togithub.com/vitejs/vite/commit/1df1fd1)), closes [#​15207](https://togithub.com/vitejs/vite/issues/15207)

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 this update again.



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