Repository navigation
fix(devtools): guard mutating RPCs to local clients - #9123
Merged
Merged
Conversation
The root vitest config only picks up *.unit.* and *.spec.*, so the devtools *.test.ts files never ran. Rename them, merge the duplicate ssrPerfMiddleware suite, and keep __snapshots__ out of the test include.
birpc awaits before invoking a function, so the request context set around the websocket handler was already cleared and every call looked remote. Build analysis therefore refused to rebuild even from localhost. Carry the context through the birpc resolver and read it before the first await.
Any client that could reach the dev server websocket, for example a LAN device when Vite runs with --host, could add or update project dependencies through DevTools. Apply the same loopback guard build analysis uses, with QWIK_DEVTOOLS_ALLOW_REMOTE_PACKAGE_MANAGEMENT=1 as an explicit opt-in.
🦋 Changeset detectedLatest commit: f4195a6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@qwik.dev/core
@qwik.dev/router
@qwik.dev/utils
eslint-plugin-qwik
create-qwik
@qwik.dev/optimizer
@qwik.dev/devtools
@qwik.dev/mcp
commit: |
4 tasks done
maiieul
approved these changes
Oct 3, 2026
Member
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What is it?
Description
DevTools already had a loopback guard for the build-analysis rebuild, but it never worked. birpc awaits before it calls the RPC function, so by then the request context set around the websocket handler was already cleared and every caller looked remote. From localhost the "Build Report" button never showed up.
The package install and update RPCs had no guard at all. If the dev server was reachable from another machine, for example a phone or laptop on the same network with
vite --host, that machine could add or update dependencies in your project from the Packages tab.This PR has three commits:
*.unit.*and*.spec.*, so 8 devtools*.test.tsfiles never ran. They are renamed (31 more tests running, all green), the duplicatessrPerfMiddlewaresuite is merged, and__snapshots__is excluded from the include so the renamed.snapfile isn't treated as a test.resolver, which runs synchronously when the message arrives, and set again around the call.getBuildAnalysisStatusnow reads it before its firstawait. The new tests go through the real RPC dispatch with a fake Vite websocket instead of mocking the context, since the mock is what hid this.plugin/src/rpc/security.tsso both features share it.QWIK_DEVTOOLS_ALLOW_REMOTE_PACKAGE_MANAGEMENT=1opts back in for setups like Docker where the browser is never on loopback.A client behind a reverse proxy on localhost still counts as local. That was already the case for build analysis and I left it alone.
Demo
Recorded against a Router SSR app with
qwikDevtools(). First onlocalhost, where rebuild and install both work, then the same page opened through the LAN IP, where both are refused with the opt-in hint.devtools-rpc-guard-demo.mp4
Checklist
pnpm change