Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@depfu
Copy link
Contributor

@depfu depfu bot commented Apr 4, 2025


🚨 Your current dependencies have known security vulnerabilities 🚨

This dependency update fixes known security vulnerabilities. Please see the details below and assess their impact carefully. We recommend to merge and deploy this as soon as possible!


Here is everything you need to know about this update. Please take a good look at what changed and the test results before merging this pull request.

What changed?

✳️ vite (5.4.16 → 5.4.17) · Repo · Changelog

Security Advisories 🚨

🚨 Vite allows server.fs.deny to be bypassed with .svg or relative paths

Summary

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

Impact

Only apps explicitly exposing the Vite dev server to the network (using --host or server.host config option) are affected..

Details

.svg

Requests ending with .svg are loaded at this line.

    <tbody>
    <tr class="border-0">
      <td id="L286" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="286"></td>
      <td id="LC286" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">   <span class="pl-k">const</span> <span class="pl-s1">file</span> <span class="pl-c1">=</span> <span class="pl-s1">publicFile</span> <span class="pl-c1">||</span> <span class="pl-en">cleanUrl</span><span class="pl-kos">(</span><span class="pl-s1">id</span><span class="pl-kos">)</span> </td>
    </tr>

    <tr class="border-0">
      <td id="L287" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="287"></td>
      <td id="LC287" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">   <span class="pl-k">const</span> <span class="pl-s1">content</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">fsp</span><span class="pl-kos">.</span><span class="pl-en">readFile</span><span class="pl-kos">(</span><span class="pl-s1">file</span><span class="pl-kos">)</span> </td>
    </tr>

    <tr class="border-0">
      <td id="L288" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="288"></td>
      <td id="LC288" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">   <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-en">shouldInline</span><span class="pl-kos">(</span><span class="pl-s1">environment</span><span class="pl-kos">,</span> <span class="pl-s1">file</span><span class="pl-kos">,</span> <span class="pl-s1">id</span><span class="pl-kos">,</span> <span class="pl-s1">content</span><span class="pl-kos">,</span> <span class="pl-c1">undefined</span><span class="pl-kos">,</span> <span class="pl-c1">undefined</span><span class="pl-kos">)</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> </td>
    </tr>

    <tr class="border-0">
      <td id="L289" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="289"></td>
      <td id="LC289" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">return</span> <span class="pl-en">assetToDataURL</span><span class="pl-kos">(</span><span class="pl-s1">environment</span><span class="pl-kos">,</span> <span class="pl-s1">file</span><span class="pl-kos">,</span> <span class="pl-s1">content</span><span class="pl-kos">)</span> </td>
    </tr>

    <tr class="border-0">
      <td id="L290" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="290"></td>
      <td id="LC290" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">   <span class="pl-kos">}</span> </td>
    </tr>
</tbody>
if (svgExtRE.test(id)) {

By adding ?.svg with ?.wasm?init or with sec-fetch-dest: script header, the restriction was able to bypass.

This bypass is only possible if the file is smaller than build.assetsInlineLimit (default: 4kB) and when using Vite 6.0+.

relative paths

The check was applied before the id normalization. This allowed requests to bypass with relative paths (e.g. ../../).

PoC

npm create vite@latest
cd vite-project/
npm install
npm run dev

send request to read etc/passwd

curl 'http://127.0.0.1:5173/etc/passwd?.svg?.wasm?init'
curl 'http://127.0.0.1:5173/@fs/x/x/x/vite-project/?/../../../../../etc/passwd?import&?raw'
Release Notes

5.4.17

Please refer to CHANGELOG.md for details.

Does any of this look wrong? Please let us know.

Commits

See the full diff on Github. The new version differs by 2 commits:


Depfu Status

Depfu will automatically keep this PR conflict-free, as long as you don't add any commits to this branch yourself. You can also trigger a rebase manually by commenting with @depfu rebase.

All Depfu comment commands
@​depfu rebase
Rebases against your default branch and redoes this update
@​depfu recreate
Recreates this PR, overwriting any edits that you've made to it
@​depfu merge
Merges this PR once your tests are passing and conflicts are resolved
@​depfu cancel merge
Cancels automatic merging of this PR
@​depfu close
Closes this PR and deletes the branch
@​depfu reopen
Restores the branch and reopens this PR (if it's closed)
@​depfu pause
Ignores all future updates for this dependency and closes this PR
@​depfu pause [minor|major]
Ignores all future minor/major updates for this dependency and closes this PR
@​depfu resume
Future versions of this dependency will create PRs again (leaves this PR as is)

@depfu depfu bot added the depfu label Apr 4, 2025
@sonarqubecloud
Copy link

sonarqubecloud bot commented Apr 4, 2025

@github-actions github-actions bot merged commit 8504c1a into main Apr 4, 2025
7 checks passed
@depfu depfu bot deleted the depfu/update/pnpm/vite-5.4.17 branch April 4, 2025 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant