Skip to content

Commit e9f5db1

Browse files
chore(deps): update dependency vite to v5.0.5 [security] (#5325)
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [vite](https://vitejs.dev) ([source](https://github.com/vitejs/vite/tree/HEAD/packages/vite)) | [`5.0.4` -> `5.0.5`](https://renovatebot.com/diffs/npm/vite/5.0.4/5.0.5) | [![age](https://developer.mend.io/api/mc/badges/age/npm/vite/5.0.5?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/vite/5.0.5?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/vite/5.0.4/5.0.5?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/vite/5.0.4/5.0.5?slim=true)](https://docs.renovatebot.com/merge-confidence/) | ### GitHub Vulnerability Alerts #### [CVE-2023-49293](https://github.com/vitejs/vite/security/advisories/GHSA-92r3-m2mg-pj97) ### 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: ```html <script type="module"> // Inline script </script> ``` This script is transformed into a proxy script like ```html <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 ```html <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 ```html <script type="module" src="/@&#8203;id/__x00__/?"></script><script>alert("boom")</script>?html-proxy&index=0.js"></script> ``` which demonstrates XSS. ### PoC - Example 1. Serving HTML from `vite dev` middleware with `appType: 'custom'` - Go to https://stackblitz.com/edit/vitejs-vite-9xhma4?file=main.js&terminal=dev-html - "Open in New Tab" - Edit URL to set query string to `?%22%3E%3C/script%3E%3Cscript%3Ealert(%27boom%27)%3C/script%3E` and navigate - Witness XSS: - ![image](https://user-images.githubusercontent.com/2456381/287434281-13757894-7a63-4a73-b1e9-d2b024c19d14.png) - Example 2. Serving HTML from SSR-style Express server (Vite dev server runs in middleware mode): - Go to https://stackblitz.com/edit/vitejs-vite-9xhma4?file=main.js&terminal=server - (Same steps as above) - Example 3. Plain `vite dev` (this shows that vanilla `vite dev` is _not_ vulnerable, provided `htmlFallbackMiddleware` is used) - Go to https://stackblitz.com/edit/vitejs-vite-9xhma4?file=main.js&terminal=dev - (Same steps as above) - You should _not_ see the alert box in this case ### Detailed Impact This will probably predominantly affect [development-mode SSR](https://vitejs.dev/guide/ssr#setting-up-the-dev-server), 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 ```js 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 #&#8203;13581. If this is correct, then vulnerable Vite versions are 4.4.0-beta.2 and higher (which includes 4.4.0). --- ### Release Notes <details> <summary>vitejs/vite (vite)</summary> ### [`v5.0.5`](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small505-2023-12-04-small) [Compare Source](https://github.com/vitejs/vite/compare/v5.0.4...v5.0.5) - fix: emit `vite:preloadError` for chunks without deps ([#&#8203;15203](https://github.com/vitejs/vite/issues/15203)) ([d8001c5](https://github.com/vitejs/vite/commit/d8001c5)), closes [#&#8203;15203](https://github.com/vitejs/vite/issues/15203) - fix: esbuild glob import resolve error ([#&#8203;15140](https://github.com/vitejs/vite/issues/15140)) ([676804d](https://github.com/vitejs/vite/commit/676804d)), closes [#&#8203;15140](https://github.com/vitejs/vite/issues/15140) - fix: json error with position ([#&#8203;15225](https://github.com/vitejs/vite/issues/15225)) ([14be75f](https://github.com/vitejs/vite/commit/14be75f)), closes [#&#8203;15225](https://github.com/vitejs/vite/issues/15225) - fix: proxy html path should be encoded ([#&#8203;15223](https://github.com/vitejs/vite/issues/15223)) ([5b85040](https://github.com/vitejs/vite/commit/5b85040)), closes [#&#8203;15223](https://github.com/vitejs/vite/issues/15223) - fix(deps): update all non-major dependencies ([#&#8203;15233](https://github.com/vitejs/vite/issues/15233)) ([ad3adda](https://github.com/vitejs/vite/commit/ad3adda)), closes [#&#8203;15233](https://github.com/vitejs/vite/issues/15233) - fix(hmr): don't consider CSS dep as a circular dep ([#&#8203;15229](https://github.com/vitejs/vite/issues/15229)) ([5f2cdec](https://github.com/vitejs/vite/commit/5f2cdec)), closes [#&#8203;15229](https://github.com/vitejs/vite/issues/15229) - feat: add '\*.mov' to client.d.ts ([#&#8203;15189](https://github.com/vitejs/vite/issues/15189)) ([d93a211](https://github.com/vitejs/vite/commit/d93a211)), closes [#&#8203;15189](https://github.com/vitejs/vite/issues/15189) - feat(server): allow disabling built-in shortcuts ([#&#8203;15218](https://github.com/vitejs/vite/issues/15218)) ([7fd7c6c](https://github.com/vitejs/vite/commit/7fd7c6c)), closes [#&#8203;15218](https://github.com/vitejs/vite/issues/15218) - chore: replace 'some' with 'includes' in resolveEnvPrefix ([#&#8203;15220](https://github.com/vitejs/vite/issues/15220)) ([ee12f30](https://github.com/vitejs/vite/commit/ee12f30)), closes [#&#8203;15220](https://github.com/vitejs/vite/issues/15220) - chore: update the website url for homepage in package.json ([#&#8203;15181](https://github.com/vitejs/vite/issues/15181)) ([282bd8f](https://github.com/vitejs/vite/commit/282bd8f)), closes [#&#8203;15181](https://github.com/vitejs/vite/issues/15181) - chore: update vitest to 1.0.0-beta.6 ([#&#8203;15194](https://github.com/vitejs/vite/issues/15194)) ([2fce647](https://github.com/vitejs/vite/commit/2fce647)), closes [#&#8203;15194](https://github.com/vitejs/vite/issues/15194) - refactor: make HMR agnostic to environment ([#&#8203;15179](https://github.com/vitejs/vite/issues/15179)) ([0571b7c](https://github.com/vitejs/vite/commit/0571b7c)), closes [#&#8203;15179](https://github.com/vitejs/vite/issues/15179) - refactor: use dedicated regex methods ([#&#8203;15228](https://github.com/vitejs/vite/issues/15228)) ([0348137](https://github.com/vitejs/vite/commit/0348137)), closes [#&#8203;15228](https://github.com/vitejs/vite/issues/15228) - perf: remove debug only prettifyUrl call ([#&#8203;15204](https://github.com/vitejs/vite/issues/15204)) ([73e971f](https://github.com/vitejs/vite/commit/73e971f)), closes [#&#8203;15204](https://github.com/vitejs/vite/issues/15204) - perf: skip computing sourceRoot in injectSourcesContent ([#&#8203;15207](https://github.com/vitejs/vite/issues/15207)) ([1df1fd1](https://github.com/vitejs/vite/commit/1df1fd1)), closes [#&#8203;15207](https://github.com/vitejs/vite/issues/15207) </details> --- ### Configuration 📅 **Schedule**: Branch creation - "" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **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. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/SAP/ui5-webcomponents-react). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy44MS4zIiwidXBkYXRlZEluVmVyIjoiMzcuODEuMyIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
1 parent a1e89e4 commit e9f5db1

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

examples/vite-ts/package-lock.json

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

yarn.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18694,7 +18694,7 @@ __metadata:
1869418694
languageName: node
1869518695
linkType: hard
1869618696

18697-
"postcss@npm:^8.4.25, postcss@npm:^8.4.27, postcss@npm:^8.4.31, postcss@npm:^8.4.5":
18697+
"postcss@npm:^8.4.25, postcss@npm:^8.4.27, postcss@npm:^8.4.32, postcss@npm:^8.4.5":
1869818698
version: 8.4.32
1869918699
resolution: "postcss@npm:8.4.32"
1870018700
dependencies:
@@ -22627,8 +22627,8 @@ __metadata:
2262722627
linkType: hard
2262822628

2262922629
"vite@npm:^4.4.9":
22630-
version: 4.5.0
22631-
resolution: "vite@npm:4.5.0"
22630+
version: 4.5.1
22631+
resolution: "vite@npm:4.5.1"
2263222632
dependencies:
2263322633
esbuild: "npm:^0.18.10"
2263422634
fsevents: "npm:~2.3.2"
@@ -22662,17 +22662,17 @@ __metadata:
2266222662
optional: true
2266322663
bin:
2266422664
vite: bin/vite.js
22665-
checksum: 7e21e9e4b80656ae5ee61e8c5edb5e8f589139c2b22c43e89d054c65a0194f1c1ef066fbc770204173c7eb244c798265042f988adda5880ad74337a053b28b7f
22665+
checksum: 352a94b13f793e4bcbc424d680a32507343223eeda8917fde0f23c1fa1ba3db7c806dade8461ca5cfb270154ddb8895a219fdd4384519fe9b8e46d1cf491a890
2266622666
languageName: node
2266722667
linkType: hard
2266822668

2266922669
"vite@npm:^5.0.0":
22670-
version: 5.0.4
22671-
resolution: "vite@npm:5.0.4"
22670+
version: 5.0.5
22671+
resolution: "vite@npm:5.0.5"
2267222672
dependencies:
2267322673
esbuild: "npm:^0.19.3"
2267422674
fsevents: "npm:~2.3.3"
22675-
postcss: "npm:^8.4.31"
22675+
postcss: "npm:^8.4.32"
2267622676
rollup: "npm:^4.2.0"
2267722677
peerDependencies:
2267822678
"@types/node": ^18.0.0 || >=20.0.0
@@ -22702,7 +22702,7 @@ __metadata:
2270222702
optional: true
2270322703
bin:
2270422704
vite: bin/vite.js
22705-
checksum: 67a0df248af042e75b1ecbf20098096df80a1068a832c5c964a20d7c06853e12b7310989c3c273cb88a9a3a37f4bada0a2115018b36df0fc09a6b6dba9a7d5b5
22705+
checksum: 22fbaacbc87eff7d1de46104880c5d269d3bb2964957e9d13edaac819e6a90b5ce2567b5d0ba8c92a7bd5bcf0412ae7d22ce958047490931fbb466b1908ff17c
2270622706
languageName: node
2270722707
linkType: hard
2270822708

0 commit comments

Comments
 (0)