Skip to content

[Security] Bump vite from 5.2.11 to 5.4.13

Dependabot requested to merge dependabot-npm_and_yarn-vite-5.4.13 into main

Bumps vite from 5.2.11 to 5.4.13. This update includes security fixes.

Vulnerabilities fixed

Vite's server.fs.deny is bypassed when using ?import&raw

Summary

The contents of arbitrary files can be returned to the browser.

Details

@fs denies access to files outside of Vite serving allow list. Adding ?import&raw to the URL bypasses this limitation and returns the file content if it exists.

PoC

$ npm create vite@latest
$ cd vite-project/
$ npm install
$ npm run dev
$ echo "top secret content" > /tmp/secret.txt
expected behaviour
$ curl "http://localhost:5173/@​fs/tmp/secret.txt"
<body>
  <h1>403 Restricted</h1>

</tr></table>

... (truncated)

Patched versions: 5.1.8; 5.2.14; 3.2.11; 4.5.4; 5.3.6; 5.4.6 Affected versions: >= 5.0.0, = 5.4.0, <= 5.4.5

Vite DOM Clobbering gadget found in vite bundled scripts that leads to XSS

Summary

We discovered a DOM Clobbering vulnerability in Vite when building scripts to cjs/iife/umd output format. The DOM Clobbering gadget in the module can lead to cross-site scripting (XSS) in web pages where scriptless attacker-controlled HTML elements (e.g., an img tag with an unsanitized name attribute) are present.

Note that, we have identified similar security issues in Webpack: https://github.com/webpack/webpack/security/advisories/GHSA-4vvj-4cpr-p986

Details

Backgrounds

DOM Clobbering is a type of code-reuse attack where the attacker first embeds a piece of non-script, seemingly benign HTML markups in the webpage (e.g. through a post or comment) and leverages the gadgets (pieces of js code) living in the existing javascript code to transform it into executable code. More for information about DOM Clobbering, here are some references:

[1] https://scnps.co/papers/sp23_domclob.pdf [2] https://research.securitum.com/xss-in-amp4email-dom-clobbering/

Gadgets found in Vite

We have identified a DOM Clobbering vulnerability in Vite bundled scripts, particularly when the scripts dynamically import other scripts from the assets folder and the developer sets the build output format to cjs, iife, or umd. In such cases, Vite replaces relative paths starting with __VITE_ASSET__ using the URL retrieved from document.currentScript.

However, this implementation is vulnerable to a DOM Clobbering attack. The document.currentScript lookup can be shadowed by an attacker via the browser's named DOM tree element access mechanism. This manipulation allows an attacker to replace the intended script element with a malicious HTML element. When this happens, the src attribute of the attacker-controlled element is used as the URL for importing scripts, potentially leading to the dynamic loading of scripts from an attacker-controlled server.

... (truncated)

Patched versions: 5.1.8; 3.2.11; 5.2.14; 5.3.6; 5.4.6; 4.5.4 Affected versions: >= 5.0.0, = 4.0.0, < 4.5.4

Release notes

Sourced from vite's releases.

create-vite@5.4.0

Please refer to CHANGELOG.md for details.

create-vite@5.3.0

Please refer to CHANGELOG.md for details.

Changelog

Sourced from vite's changelog.

5.4.13 (2025-01-20)

5.4.12 (2025-01-20)

  • fix!: check host header to prevent DNS rebinding attacks and introduce server.allowedHosts (9da4abc)
  • fix!: default server.cors: false to disallow fetching from untrusted origins (dfea38f)
  • fix: verify token for HMR WebSocket connection (b71a5c8)
  • chore: add deps update changelog (ecd2375)

5.4.11 (2024-11-11)

  • fix(deps): update dependencies of postcss-modules (ceb15db), closes #18617

5.4.10 (2024-10-23)

  • fix: backport #18367,augment hash for CSS files to prevent chromium erroring by loading previous fil (7d1a3bc), closes #18367 #18412

5.4.9 (2024-10-14)

5.4.8 (2024-09-25)

5.4.7 (2024-09-20)

... (truncated)

Commits
  • a1824c5 release: v5.4.13
  • 5946215 fix: try parse server.origin URL (#19241)
  • f428aa9 release: v5.4.12
  • 9da4abc fix!: check host header to prevent DNS rebinding attacks and introduce `serve...
  • b71a5c8 fix: verify token for HMR WebSocket connection
  • dfea38f fix!: default server.cors: false to disallow fetching from untrusted origins
  • ecd2375 chore: add deps update changelog
  • c54c860 release: v5.4.11
  • 5f52bc8 release: v5.4.10
  • 7d1a3bc fix: backport #18367,augment hash for CSS files to prevent chromium erroring ...
  • Additional commits viewable in compare view

Merge request reports

Loading