Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚨 [security] Update nuxt 2.16.3 → 3.13.0 (major) #684

Closed
wants to merge 1 commit into from

Conversation

depfu[bot]
Copy link
Contributor

@depfu depfu bot commented Aug 29, 2024


🚨 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 upgrade. Please take a good look at what changed and the test results before merging this pull request.

What changed?

✳️ nuxt (2.16.3 → 3.13.0) · Repo

Security Advisories 🚨

🚨 nuxt vulnerable to Cross-site Scripting in navigateTo if used after SSR

Summary

The navigateTo function attempts to blockthe javascript: protocol, but does not correctly use API's provided by unjs/ufo. This library also contains parsing discrepancies.

Details

The function first tests to see if the specified URL has a protocol. This uses the unjs/ufo package for URL parsing. This function works effectively, and returns true for a javascript: protocol.

After this, the URL is parsed using the parseURL function. This function will refuse to parse poorly formatted URLs. Parsing javascript:alert(1) returns null/"" for all values.

Next, the protocol of the URL is then checked using the isScriptProtocol function. This function simply checks the input against a list of protocols, and does not perform any parsing.

The combination of refusing to parse poorly formatted URLs, and not performing additional parsing means that script checks fail as no protocol can be found. Even if a protocol was identified, whitespace is not stripped in the parseURL implementation, bypassing the isScriptProtocol checks.

Certain special protocols are identified at the top of parseURL. Inserting a newline or tab into this sequence will block the special protocol check, and bypass the latter checks.

PoC

POC - https://stackblitz.com/edit/nuxt-xss-navigateto?file=app.vue

Attempt payload X, then attempt payload Y.

Impact

XSS, access to cookies, make requests on user's behalf.

Recommendations

As always with these bugs, the URL constructor provided by the browser is always the safest method of parsing a URL.

Given the cross-platform requirements of nuxt/ufo a more appropriate solution is to make parsing consistent between functions, and to adapt parsing to be more consistent with the WHATWG URL specification.

Note

I've reported this vulnerability here as it is unclear if this is a bug in ufo or a misuse of the ufo library.

This ONLY has impact after SSR has occured, the javascript: protocol within a location header does not trigger XSS.

🚨 Nuxt vulnerable to remote code execution via the browser when running the test locally

Summary

Due to the insufficient validation of the path parameter in the NuxtTestComponentWrapper, an attacker can execute arbitrary JavaScript on the server side, which allows them to execute arbitrary commands.

Details

While running the test, a special component named NuxtTestComponentWrapper is available.

    <tbody>
    <tr class="border-0">
      <td id="L43" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="43"></td>
      <td id="LC43" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-s1">  .<span class="pl-c1">then</span>(<span class="pl-smi">r</span> <span class="pl-k">=&gt;</span> <span class="pl-smi">r</span>.<span class="pl-en">default</span>(<span class="pl-k">import</span>.meta.server ? url : window.location.href)))</span> </td>
    </tr>
</tbody>
const SingleRenderer = import.meta.test && import.meta.dev && import.meta.server && url.startsWith('/__nuxt_component_test__/') && defineAsyncComponent(() => import('#build/test-component-wrapper.mjs')

This component loads the specified path as a component and renders it.

    <tbody>
    <tr class="border-0">
      <td id="L10" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="10"></td>
      <td id="LC10" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">   <span class="pl-c1">name</span>: <span class="pl-s">'NuxtTestComponentWrapper'</span><span class="pl-kos">,</span> </td>
    </tr>

    <tr class="border-0">
      <td id="L11" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="11"></td>
      <td id="LC11" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">  </td>
    </tr>

    <tr class="border-0">
      <td id="L12" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="12"></td>
      <td id="LC12" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">   <span class="pl-k">async</span> <span class="pl-en">setup</span> <span class="pl-kos">(</span><span class="pl-s1">props</span><span class="pl-kos">,</span> <span class="pl-kos">{</span> attrs <span class="pl-kos">}</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> </td>
    </tr>

    <tr class="border-0">
      <td id="L13" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="13"></td>
      <td id="LC13" 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">query</span> <span class="pl-c1">=</span> <span class="pl-en">parseQuery</span><span class="pl-kos">(</span><span class="pl-en">parseURL</span><span class="pl-kos">(</span><span class="pl-s1">url</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-c1">search</span><span class="pl-kos">)</span> </td>
    </tr>

    <tr class="border-0">
      <td id="L14" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="14"></td>
      <td id="LC14" 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">urlProps</span> <span class="pl-c1">=</span> <span class="pl-s1">query</span><span class="pl-kos">.</span><span class="pl-c1">props</span> ? <span class="pl-en">destr</span><span class="pl-kos">&lt;</span><span class="pl-smi">Record</span><span class="pl-kos">&lt;</span><span class="pl-smi">string</span><span class="pl-kos">,</span> <span class="pl-smi">any</span><span class="pl-kos">&gt;</span><span class="pl-kos">&gt;</span><span class="pl-kos">(</span><span class="pl-s1">query</span><span class="pl-kos">.</span><span class="pl-c1">props</span> <span class="pl-k">as</span> <span class="pl-smi">string</span><span class="pl-kos">)</span> : <span class="pl-kos">{</span><span class="pl-kos">}</span> </td>
    </tr>

    <tr class="border-0">
      <td id="L15" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="15"></td>
      <td id="LC15" 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">path</span> <span class="pl-c1">=</span> <span class="pl-en">resolve</span><span class="pl-kos">(</span><span class="pl-s1">query</span><span class="pl-kos">.</span><span class="pl-c1">path</span> <span class="pl-k">as</span> <span class="pl-smi">string</span><span class="pl-kos">)</span> </td>
    </tr>

    <tr class="border-0">
      <td id="L16" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="16"></td>
      <td id="LC16" 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-c1">!</span><span class="pl-s1">path</span><span class="pl-kos">.</span><span class="pl-en">startsWith</span><span class="pl-kos">(</span><span class="pl-s1">devRootDir</span><span class="pl-kos">)</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> </td>
    </tr>

    <tr class="border-0">
      <td id="L17" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="17"></td>
      <td id="LC17" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">       <span class="pl-k">throw</span> <span class="pl-k">new</span> <span class="pl-smi">Error</span><span class="pl-kos">(</span><span class="pl-s">`[nuxt] Cannot access path outside of project root directory: \`<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">path</span><span class="pl-kos">}</span></span>\`.`</span><span class="pl-kos">)</span> </td>
    </tr>

    <tr class="border-0">
      <td id="L18" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="18"></td>
      <td id="LC18" 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>

    <tr class="border-0">
      <td id="L19" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="19"></td>
      <td id="LC19" 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">comp</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-k">import</span><span class="pl-kos">(</span><span class="pl-c">/* @vite-ignore */</span> <span class="pl-s1">query</span><span class="pl-kos">.</span><span class="pl-c1">path</span> <span class="pl-k">as</span> <span class="pl-smi">string</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">then</span><span class="pl-kos">(</span><span class="pl-s1">r</span> <span class="pl-c1">=&gt;</span> <span class="pl-s1">r</span><span class="pl-kos">.</span><span class="pl-c1">default</span><span class="pl-kos">)</span> </td>
    </tr>

    <tr class="border-0">
      <td id="L20" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="20"></td>
      <td id="LC20" 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-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">[</span> </td>
    </tr>

    <tr class="border-0">
      <td id="L21" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="21"></td>
      <td id="LC21" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">       <span class="pl-en">h</span><span class="pl-kos">(</span><span class="pl-s">'div'</span><span class="pl-kos">,</span> <span class="pl-s">'Component Test Wrapper for '</span> <span class="pl-c1">+</span> <span class="pl-s1">query</span><span class="pl-kos">.</span><span class="pl-c1">path</span><span class="pl-kos">)</span><span class="pl-kos">,</span> </td>
    </tr>

    <tr class="border-0">
      <td id="L22" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="22"></td>
      <td id="LC22" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">       <span class="pl-en">h</span><span class="pl-kos">(</span><span class="pl-s">'div'</span><span class="pl-kos">,</span> <span class="pl-kos">{</span> <span class="pl-c1">id</span>: <span class="pl-s">'nuxt-component-root'</span> <span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-kos">[</span> </td>
    </tr>

    <tr class="border-0">
      <td id="L23" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="23"></td>
      <td id="LC23" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-en">h</span><span class="pl-kos">(</span><span class="pl-s1">comp</span><span class="pl-kos">,</span> <span class="pl-kos">{</span> ...<span class="pl-s1">attrs</span><span class="pl-kos">,</span> ...<span class="pl-s1">props</span><span class="pl-kos">,</span> ...<span class="pl-s1">urlProps</span> <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">,</span> </td>
    </tr>

    <tr class="border-0">
      <td id="L24" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="24"></td>
      <td id="LC24" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">       <span class="pl-kos">]</span><span class="pl-kos">)</span><span class="pl-kos">,</span> </td>
    </tr>

    <tr class="border-0">
      <td id="L25" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="25"></td>
      <td id="LC25" 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>

    <tr class="border-0">
      <td id="L26" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="26"></td>
      <td id="LC26" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">   <span class="pl-kos">}</span><span class="pl-kos">,</span> </td>
    </tr>

    <tr class="border-0">
      <td id="L27" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="27"></td>
      <td id="LC27" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-kos">}</span><span class="pl-kos">)</span> </td>
    </tr>
</tbody>
export default (url: string) => defineComponent({

There is a validation for the path parameter to check whether the path traversal is performed, but this check is not sufficient.

    <tbody>
    <tr class="border-0">
      <td id="L16" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="16"></td>
      <td id="LC16" 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-c1">!</span><span class="pl-s1">path</span><span class="pl-kos">.</span><span class="pl-en">startsWith</span><span class="pl-kos">(</span><span class="pl-s1">devRootDir</span><span class="pl-kos">)</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> </td>
    </tr>

    <tr class="border-0">
      <td id="L17" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="17"></td>
      <td id="LC17" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">   <span class="pl-k">throw</span> <span class="pl-k">new</span> <span class="pl-smi">Error</span><span class="pl-kos">(</span><span class="pl-s">`[nuxt] Cannot access path outside of project root directory: \`<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">path</span><span class="pl-kos">}</span></span>\`.`</span><span class="pl-kos">)</span> </td>
    </tr>

    <tr class="border-0">
      <td id="L18" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="18"></td>
      <td id="LC18" 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>

    <tr class="border-0">
      <td id="L19" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="19"></td>
      <td id="LC19" 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">comp</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-k">import</span><span class="pl-kos">(</span><span class="pl-c">/* @vite-ignore */</span> <span class="pl-s1">query</span><span class="pl-kos">.</span><span class="pl-c1">path</span> <span class="pl-k">as</span> <span class="pl-smi">string</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">then</span><span class="pl-kos">(</span><span class="pl-s1">r</span> <span class="pl-c1">=&gt;</span> <span class="pl-s1">r</span><span class="pl-kos">.</span><span class="pl-c1">default</span><span class="pl-kos">)</span> </td>
    </tr>
</tbody>
const path = resolve(query.path as string)

Since import(...) uses query.path instead of the normalized path, a non-normalized URL can reach the import(...) function.
For example, passing something like ./components/test normalizes path to /root/directory/components/test, but import(...) still receives ./components/test.

By using this behavior, it's possible to load arbitrary JavaScript by using the path like the following:

data:text/javascript;base64,Y29uc29sZS5sb2coMSk

Since resolve(...) resolves the filesystem path, not the URI, the above URI is treated as a relative path, but import(...) sees it as an absolute URI, and loads it as a JavaScript.

PoC

  1. Create a nuxt project and run it in the test mode:
npx nuxi@latest init test
cd test
TEST=true npm run dev
  1. Open the following URL:
http://localhost:3000/__nuxt_component_test__/?path=data%3Atext%2Fjavascript%3Bbase64%2CKGF3YWl0IGltcG9ydCgnZnMnKSkud3JpdGVGaWxlU3luYygnL3RtcC90ZXN0JywgKGF3YWl0IGltcG9ydCgnY2hpbGRfcHJvY2VzcycpKS5zcGF3blN5bmMoIndob2FtaSIpLnN0ZG91dCwgJ3V0Zi04Jyk
  1. Confirm that the output of whoami is written to /tmp/test

Demonstration video: https://www.youtube.com/watch?v=FI6mN8WbcE4

Impact

Users who open a malicious web page in the browser while running the test locally are affected by this vulnerability, which results in the remote code execution from the malicious web page.
Since web pages can send requests to arbitrary addresses, a malicious web page can repeatedly try to exploit this vulnerability, which then triggers the exploit when the test server starts.

🚨 nuxt Code Injection vulnerability

he Nuxt dev server between versions 3.4.0 and 3.4.3 is vulnerable to code injection when it is exposed publicly.

Release Notes

Too many releases to show here. View the full release notes.

Commits

See the full diff on Github. The new version differs by more commits than we can show here.

✳️ autoprefixer (10.4.14 → 10.4.20) · Repo · Changelog

Release Notes

10.4.20

  • Fixed fit-content prefix for Firefox.

10.4.19

  • Removed end value has mixed support, consider using flex-end warning since end/start now have good support.

10.4.18

  • Fixed removing -webkit-box-orient on -webkit-line-clamp (@Goodwine).

10.4.17

  • Fixed user-select: contain prefixes.

10.4.16

10.4.15 (from changelog)

  • Fixed ::backdrop prefixes (by 一丝).
  • Fixed docs (by Christian Oliff).

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

Commits

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

✳️ postcss (8.4.21 → 8.4.41) · Repo · Changelog

Security Advisories 🚨

🚨 PostCSS line return parsing error

An issue was discovered in PostCSS before 8.4.31. It affects linters using PostCSS to parse external Cascading Style Sheets (CSS). There may be \r discrepancies, as demonstrated by @font-face{ font:(\r/*);} in a rule.

This vulnerability affects linters using PostCSS to parse external untrusted CSS. An attacker can prepare CSS in such a way that it will contains parts parsed by PostCSS as a CSS comment. After processing by PostCSS, it will be included in the PostCSS output in CSS nodes (rules, properties) despite being originally included in a comment.

Release Notes

Too many releases to show here. View the full release notes.

Commits

See the full diff on Github. The new version differs by more commits than we can show here.


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)

Copy link
Contributor Author

depfu bot commented Sep 22, 2024

Closed in favor of #686.

@depfu depfu bot closed this Sep 22, 2024
@depfu depfu bot deleted the depfu/update/yarn/nuxt-3.13.0 branch September 22, 2024 22:28
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.

0 participants