Skip to content

Update dependency vitest to v4 [SECURITY] - #2846

Closed
renovate[bot] wants to merge 1 commit into
masterfrom
renovate/npm-vitest-vulnerability
Closed

renovate[bot] wants to merge 1 commit into
masterfrom
renovate/npm-vitest-vulnerability

Conversation

@renovate

@renovate renovate Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Note

This PR body was truncated due to platform limits.

This PR contains the following updates:

Package Change Age Confidence
vitest (source) ^3.0.0 → ^4.0.0 age confidence

Vitest: Path Traversal / Arbitrary File Read via @​vitest/mocker Redirect Mock

CVE-2026-84373 / GHSA-82fw-gwwq-j7x9

More information

Details

Summary

@vitest/mocker registers a redirect mock's target path without validating it
against the dev server's file-serving allowlist. An attacker who can reach the
dev server's WebSocket can register a redirect mock pointing outside the project
root; when the mocked module is requested, the plugin's load hook returns
readFile(<attacker path>) as the module source, disclosing local files.

This is exploitable without authentication only through the public
mockerPlugin / standalone interceptorPlugin exports (used by third-party dev
servers), which register the handler on Vite's unauthenticated HMR socket.
Vitest's own browser mode registers mocks over a token-authenticated RPC and
is not remotely reachable by default (see Scope).

Affected code

packages/mocker/src/node/interceptorPlugin.ts.

The load hook is the file-read sink:

if (mock.type === 'redirect') {
  return readFile(mock.redirect, 'utf-8')
}

mock.redirect is derived from client input at registration time with no
boundary check:

if (event.type === 'redirect') {
  const redirectUrl = new URL(event.redirect)
  event.redirect = join(server.config.root, redirectUrl.pathname)
}
registry.register(event)

There is no server.fs.allow / server.fs.deny check and no assertion that the
resolved path stays within the project root.

Registration paths and trust boundaries
  • Public mockerPlugin / interceptorPlugin (unauthenticated). In
    configureServer, the plugin registers server.ws.on('vitest:interceptor:register', …)
    on Vite's HMR WebSocket. That socket performs no token, Origin, or same-origin
    check, so any client that can reach it can register a redirect mock. This is
    the path the "unauthenticated" impact applies to.
  • Vitest browser mode (authenticated). Mocks register over the browser RPC
    (registerMock), which sits behind a per-run token (isValidApiRequest, a
    random api.token). The interceptor's configureServer socket is not used for
    registration here (in v5 it does not run at all, as the plugin is injected per
    environment). The same missing boundary check exists on the authenticated RPC
    path, but reaching it requires the token, so it is not a remote-unauthenticated
    read.
Path handling

new URL(redirect).pathname combined with join(root, pathname) does not
confine reads to the root:

  • Special/hierarchical schemes (file:, http:) are normalized by WHATWG URL,
    so .. segments are collapsed and the result stays under the root. Payloads of
    the form file:///../../etc/passwd do not escape.
  • A non-special (opaque) scheme preserves .. in pathname, so
    join(root, "../../…/etc/passwd") resolves outside the root and reads an
    arbitrary file.

Even without escaping the root, the missing server.fs check allows reading any
in-root file the dev server would otherwise refuse to serve (for example an
in-root .env or source that is denied by server.fs.deny).

Scope / preconditions
  • This is a development-server issue. The dev server binds to localhost by
    default and is not reachable from the network unless the developer exposes it
    (server.host / 0.0.0.0, a LAN bind, or a proxy).
  • A raw (non-browser) client against a reachable server bypasses browser origin
    and CORS protections entirely and can both register the mock and read the
    response.
  • A browser-based drive-by against a localhost server is substantially mitigated
    by Vite defaults: the default CORS origin allowlist is limited to localhost
    origins, and server.allowedHosts blocks DNS-rebinding, so a cross-origin page
    cannot read the file contents back.
Impact

Disclosure of local files readable by the dev-server process (source, in-root
.env/secrets, and, via the opaque-scheme payload, files outside the project
root). No integrity or availability impact.

Affected versions

Present since @vitest/mocker was introduced.

  • Affected: @vitest/mocker >= 2.1.0 (shipped in vitest and
    @vitest/browser >= 2.1.0), through 4.1.x and the 5.0.0 pre-releases.
  • Fixed: Vitest 4.1.11 and 5.0.0. Older majors (2.1.x, 3.x) are not
    maintained and are not planned to receive the fix.
Fix

Validate the resolved redirect target against Vite's file-serving allowlist
(isFileLoadingAllowed) before registering it, at every registration site, and
stop registering the interceptor WebSocket events in Vitest's browser mode
(mocks there flow through the authenticated RPC).

Severity

  • CVSS Score: 5.9 / 10 (Medium)
  • Vector String: CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


Release Notes

vitest-dev/vitest (vitest)

v4.1.11

Compare Source

   🐞 Bug Fixes
    View changes on GitHub

v4.1.10

Compare Source

   🐞 Bug Fixes
    View changes on GitHub

v4.1.9

Compare Source

🐞 Bug Fixes
  • Fix importOriginal with optimizer and query import [backport to v4] - by Hiroshi Ogawa, David Harris, Codexand Vladimir in #​10546 (a5180)
  • browser:
    • Wait for orchestrator readiness before resolving browser sessions [backport to v4] - by Vladimir and Séamus O'Connor in #​10555 (7fb29)
    • Wait for iframe tester readiness before preparing [backport to v4] - by Vladimir and Séamus O'Connor in #​10497 and #​10556 (fbc62)
  • mocker:
    • Hoist vi.mock() for vite-plus/test imports [backport to v4] - by Hiroshi Ogawa, LongYinan, Claude Opus 4.8 and Vladimir in #​10548 (2c955)
  • pool:
    • Prevent test run hang on worker crash [backport to v4] - by Ari Perkkiö and Jattioui Ismail in #​10543 and #​10564 (934b0)
View changes on GitHub

v4.1.8

Compare Source

   🐞 Bug Fixes
    View changes on GitHub

v4.1.7

Compare Source

   🐞 Bug Fixes
    View changes on GitHub

v4.1.6

Compare Source

   🐞 Bug Fixes
   🏎 Performance
    View changes on GitHub

v4.1.5

Compare Source

   🚀 Experimental Features
   🐞 Bug Fixes
    View changes on GitHub

v4.1.4

Compare Source

   🚀 Experimental Features
   🐞 Bug Fixes
    View changes on GitHub

v4.1.3

Compare Source

   🚀 Experimental Features
   🐞 Bug Fixes
    View changes on GitHub

v4.1.2

Compare Source

This release bumps Vitest's flatted version and removes version pinning to resolve flatted's CVE related issues (#​9975).

   🐞 Bug Fixes
    View changes on GitHub

v4.1.1

Compare Source

   🚀 Features
   🐞 Bug Fixes
    View changes on GitHub

v4.1.0

Compare Source

Vitest 4.1 is out!

This release page lists all changes made to the project during the 4.1 beta. To get a review of all the new features, read our blog post.

   🚀 Features
   🐞 Bug Fixes

[!IMPORTANT]
✂ PR body was truncated to here.


Configuration

📅 Schedule: (UTC)

  • Branch creation
    • At any time (no schedule defined)
  • Automerge
    • At any time (no schedule defined)

🚦 Automerge: Enabled.

♻ 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 was generated by Mend Renovate. View the repository job log.

@renovate renovate Bot added the dependencies Pull requests that update a dependency file label Sep 9, 2026
@renovate
renovate Bot enabled auto-merge (squash) September 9, 2026 18:32
@github-actions

github-actions Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

🏎️ Benchmark Comparison

Benchmark Control (p50) Experiment (p50) Δ
🟢 js small 11.50 ms 11.10 ms -3.5%
🟢 js medium 5.35 ms 5.24 ms -2.1%
⚪ js large 2.10 ms 2.09 ms -0.5%
⚪ gjs small 865.18 µs 858.24 µs -0.8%
⚪ gjs medium 430.89 µs 430.85 µs -0.0%
⚪ gjs large 171.15 µs 170.52 µs -0.4%
⚪ gts small 858.38 µs 859.54 µs +0.1%
⚪ gts medium 430.74 µs 429.02 µs -0.4%
⚪ gts large 171.48 µs 169.86 µs -0.9%

🟢 faster · 🔴 slower · 🟠 slightly slower · ⚪ within 2%

Full mitata output
clk: ~3.55 GHz
cpu: AMD EPYC 9V74 80-Core Processor
runtime: node 24.21.0 (x64-linux)

benchmark                   avg (min … max) p75 / p99    (min … top 1%)
------------------------------------------- -------------------------------
js small (control)            13.39 ms/iter  15.45 ms  █                   
                       (9.18 ms … 25.79 ms)  24.28 ms ▅██                  
                    (  6.37 mb …  10.20 mb)   7.22 mb ████▆▆█▆▃█▆▁▁▁▁▁█▃▃▁▃

js small (experiment)         11.51 ms/iter  11.78 ms  █                   
                       (9.82 ms … 17.33 ms)  16.84 ms ▇█▅▇█▇    ▅          
                    (  6.28 mb …   8.52 mb)   6.89 mb ██████▃█▁▆█▁▁▁▁▁▃▃▁▁▃

                             ┌                                            ┐
                             ╷ ┌──────────┬─────┐                         ╷
          js small (control) ├─┤          │     ├─────────────────────────┤
                             ╵ └──────────┴─────┘                         ╵
                               ╷┌───┬┐              ╷
       js small (experiment)   ├┤   │├──────────────┤
                               ╵└───┴┘              ╵
                             └                                            ┘
                             9.18 ms           16.73 ms            24.28 ms

summary
  js small (experiment)
   1.16x faster than js small (control)

------------------------------------------- -------------------------------
js medium (control)            5.81 ms/iter   5.95 ms  █▃                  
                       (4.95 ms … 11.50 ms)   8.98 ms ███▄                 
                    (  2.83 mb …   4.87 mb)   3.56 mb ████▅▅▃▅▄▄▂▄▁▂▃▄▂▁▁▁▃

js medium (experiment)         5.97 ms/iter   5.88 ms  ▃█                  
                       (4.59 ms … 13.49 ms)  12.45 ms ▇██                  
                    (  2.25 mb …   4.93 mb)   3.51 mb ████▆▅▃▃▁▃▂▁▁▃▁▂▁▁▃▂▂

                             ┌                                            ┐
                               ╷┌───┬┐                ╷
         js medium (control)   ├┤   │├────────────────┤
                               ╵└───┴┘                ╵
                             ╷  ┌────┬                                    ╷
      js medium (experiment) ├──┤    │────────────────────────────────────┤
                             ╵  └────┴                                    ╵
                             └                                            ┘
                             4.59 ms            8.52 ms            12.45 ms

summary
  js medium (control)
   1.03x faster than js medium (experiment)

------------------------------------------- -------------------------------
js large (control)             2.29 ms/iter   2.20 ms ▂█                   
                        (1.97 ms … 5.32 ms)   5.11 ms ██                   
                    ( 56.43 kb …   2.84 mb)   1.44 mb ██▅▂▃▂▂▂▂▂▁▁▁▁▁▁▁▁▁▁▁

js large (experiment)          2.29 ms/iter   2.17 ms ██                   
                        (1.96 ms … 5.81 ms)   5.13 ms ██                   
                    (269.35 kb …   3.28 mb)   1.45 mb ██▅▂▂▂▂▂▂▂▁▂▁▁▁▁▂▁▁▁▁

                             ┌                                            ┐
                             ╷┌───┬                                       ╷
          js large (control) ├┤   │───────────────────────────────────────┤
                             ╵└───┴                                       ╵
                             ╷┌───┬                                       ╷
       js large (experiment) ├┤   │───────────────────────────────────────┤
                             ╵└───┴                                       ╵
                             └                                            ┘
                             1.96 ms            3.54 ms             5.13 ms

summary
  js large (experiment)
   1x faster than js large (control)

------------------------------------------- -------------------------------
gjs small (control)          954.27 µs/iter 876.16 µs █                    
                      (836.52 µs … 5.28 ms)   4.63 ms █                    
                    (549.04 kb …   1.60 mb)   1.05 mb █▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁

gjs small (experiment)       949.44 µs/iter 869.78 µs █                    
                      (835.79 µs … 5.60 ms)   4.68 ms █                    
                    (798.53 kb …   2.14 mb)   1.06 mb █▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁

                             ┌                                            ┐
                             ┌┬                                          ╷
         gjs small (control) ││──────────────────────────────────────────┤
                             └┴                                          ╵
                             ┌┬                                           ╷
      gjs small (experiment) ││───────────────────────────────────────────┤
                             └┴                                           ╵
                             └                                            ┘
                             835.79 µs           2.76 ms            4.68 ms

summary
  gjs small (experiment)
   1.01x faster than gjs small (control)

------------------------------------------- -------------------------------
gjs medium (control)         471.74 µs/iter 436.94 µs █                    
                      (417.25 µs … 5.05 ms)   2.52 ms █                    
                    (405.38 kb …   1.20 mb) 542.03 kb █▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁

gjs medium (experiment)      488.20 µs/iter 438.51 µs █                    
                      (416.56 µs … 4.93 ms)   1.74 ms █                    
                    (539.66 kb …   1.04 mb) 540.84 kb █▃▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁

                             ┌                                            ┐
                             ┌┬                                           ╷
        gjs medium (control) ││───────────────────────────────────────────┤
                             └┴                                           ╵
                             ┌─┬                         ╷
     gjs medium (experiment) │ │─────────────────────────┤
                             └─┴                         ╵
                             └                                            ┘
                             416.56 µs           1.47 ms            2.52 ms

summary
  gjs medium (control)
   1.03x faster than gjs medium (experiment)

------------------------------------------- -------------------------------
gjs large (control)          186.92 µs/iter 174.48 µs  ▆█                  
                      (166.03 µs … 4.26 ms) 212.96 µs  ██▆                 
                    (216.09 kb … 808.86 kb) 216.55 kb ▂███▅▄▆▄▂▂▂▁▁▁▁▁▁▁▁▁▁

gjs large (experiment)       188.19 µs/iter 174.56 µs  █                   
                      (165.70 µs … 4.42 ms) 222.25 µs  ██                  
                    (181.23 kb …   1.26 mb) 216.66 kb ▂██▇▄▅▃▂▁▁▁▁▁▁▁▁▁▁▁▁▁

                             ┌                                            ┐
                             ╷  ┌─────────────┬                    ╷
         gjs large (control) ├──┤             │────────────────────┤
                             ╵  └─────────────┴                    ╵
                             ╷  ┌──────────────┬                          ╷
      gjs large (experiment) ├──┤              │──────────────────────────┤
                             ╵  └──────────────┴                          ╵
                             └                                            ┘
                             165.70 µs         193.98 µs          222.25 µs

summary
  gjs large (control)
   1.01x faster than gjs large (experiment)

------------------------------------------- -------------------------------
gts small (control)          945.07 µs/iter 869.27 µs █                    
                      (835.17 µs … 5.59 ms)   4.68 ms █                    
                    (  1.06 mb …   2.22 mb)   1.06 mb █▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁

gts small (experiment)       933.85 µs/iter 868.89 µs █                    
                      (837.35 µs … 5.42 ms)   4.65 ms █                    
                    (636.23 kb …   2.16 mb)   1.06 mb █▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁

                             ┌                                            ┐
                             ┌┬                                           ╷
         gts small (control) ││───────────────────────────────────────────┤
                             └┴                                           ╵
                             ┌┬                                           ╷
      gts small (experiment) ││───────────────────────────────────────────┤
                             └┴                                           ╵
                             └                                            ┘
                             835.17 µs           2.76 ms            4.68 ms

summary
  gts small (experiment)
   1.01x faster than gts small (control)

------------------------------------------- -------------------------------
gts medium (control)         466.85 µs/iter 436.75 µs ▂█                   
                      (417.60 µs … 4.90 ms) 839.59 µs ██                   
                    (121.31 kb …   1.10 mb) 541.20 kb ██▃▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁

gts medium (experiment)      466.63 µs/iter 435.44 µs █                    
                      (417.15 µs … 4.98 ms)   1.24 ms █                    
                    (539.30 kb …   1.11 mb) 540.25 kb █▅▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁

                             ┌                                            ┐
                             ┌──┬                   ╷
        gts medium (control) │  │───────────────────┤
                             └──┴                   ╵
                             ┌──┬                                         ╷
     gts medium (experiment) │  │─────────────────────────────────────────┤
                             └──┴                                         ╵
                             └                                            ┘
                             417.15 µs          830.50 µs           1.24 ms

summary
  gts medium (experiment)
   1x faster than gts medium (control)

------------------------------------------- -------------------------------
gts large (control)          187.84 µs/iter 174.83 µs  █▃                  
                      (166.11 µs … 4.54 ms) 229.54 µs  ██                  
                    (216.09 kb … 776.85 kb) 216.60 kb ▄██▆▅▅▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁

gts large (experiment)       187.16 µs/iter 173.42 µs  █                   
                      (165.21 µs … 4.43 ms) 230.78 µs  █▃                  
                    (215.70 kb …   1.03 mb) 216.39 kb ▃██▃▅▃▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁

                             ┌                                            ┐
                              ╷ ┌────────────┬                           ╷
         gts large (control)  ├─┤            │───────────────────────────┤
                              ╵ └────────────┴                           ╵
                             ╷ ┌────────────┬                             ╷
      gts large (experiment) ├─┤            │─────────────────────────────┤
                             ╵ └────────────┴                             ╵
                             └                                            ┘
                             165.21 µs         198.00 µs          230.78 µs

summary
  gts large (experiment)
   1x faster than gts large (control)

@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch from 60025c0 to 49f4a9d Compare September 13, 2026 21:41
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch 3 times, most recently from 552a343 to 720d00d Compare October 1, 2026 15:32
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch 4 times, most recently from a498208 to e01e6ab Compare October 12, 2026 01:43
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch 10 times, most recently from b04f60e to 476bf85 Compare October 23, 2026 19:16
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch from 476bf85 to f67c852 Compare October 23, 2026 19:18
auto-merge was automatically disabled October 23, 2026 20:49

Pull request was closed

@NullVoxPopuli
NullVoxPopuli deleted the renovate/npm-vitest-vulnerability branch October 23, 2026 20:50
@renovate

renovate Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

Renovate Ignore Notification

Because you closed this PR without merging, Renovate will ignore this update. You will not get PRs for any future 4.x releases. But if you manually upgrade to 4.x then Renovate will re-enable minor and patch updates automatically.

If you accidentally closed this PR, or if you changed your mind: rename this PR to get a fresh replacement PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant