jellydn / nft-app

How to create your own NFT and mint NFT token
https://nft-app.productsway.com/
MIT License
215 stars 98 forks source link

chore(deps): update dependency vite to v5.0.5 [security] #1068

Closed renovate[bot] closed 8 months ago

renovate[bot] commented 8 months ago

Mend Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
vite (source) 5.0.4 -> 5.0.5 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).


Release Notes

vitejs/vite (vite) ### [`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: 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.



This PR has been generated by Mend Renovate. View repository job log here.

vercel[bot] commented 8 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nft-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 6, 2023 0:42am
changeset-bot[bot] commented 8 months ago

⚠️ No Changeset found

Latest commit: 6e9e752b6d039ae2bb3ff3585b2bd25881390289

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

sweep-ai[bot] commented 8 months ago

Apply Sweep Rules to your PR?

socket-security[bot] commented 8 months ago

Updated dependencies detected. Learn more about Socket for GitHub ↗︎

Packages Version New capabilities Transitives Size Publisher
vite 5.0.4...5.0.5 None +2/-0 3.67 MB vitebot