[Security] Bump vite from 5.2.11 to 5.4.13
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
, orumd
. In such cases, Vite replaces relative paths starting with__VITE_ASSET__
using the URL retrieved fromdocument.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)
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)
- fix: bump launch-editor-middleware to v2.9.1 (#18348) (508d9ab), closes #18348
- fix(css): fix lightningcss dep url resolution with custom root (#18125) (eae00b5), closes #18125
- fix(data-uri): only match ids starting with
data:
(#18241) (96084d6), closes #18241- fix(deps): bump tsconfck (#18322) (dc5434c), closes #18322
- fix(hmr): don't try to rewrite imports for direct CSS soft invalidation (#18252) (851b258), closes #18252
- fix(ssr): (backport #18150) fix source map remapping with multiple sources (#18204) (262a879), closes #18204
- chore: update all url references of vitejs.dev to vite.dev (#18276) (c23558a), closes #18276
- chore: update license copyright (#18278) (1864eb1), closes #18278
- docs: update homepage (#18274) (ae44163), closes #18274
5.4.8 (2024-09-25)
- fix(css): backport #18113, fix missing source file warning with sass modern api custom importer (#18 (7d47fc1), closes #18183
- fix(css): backport #18128, ensure sass compiler initialized only once (#18184) (8464d97), closes #18128 #18184
5.4.7 (2024-09-20)
... (truncated)
Commits
-
a1824c5
release: v5.4.13 -
5946215
fix: try parseserver.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!: defaultserver.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