SvelteKit’s Server-Only Guard Failed Open
SvelteKit 3.1.1 fixes a build-time guard failure that could put server-only code into the browser bundle. The exposure is narrow but serious: GitHub rates it high severity, with a CVSS score of 7.5, and the affected range covers @sveltejs/kit 3.0.0 through 3.1.0. The first patched version is 3.1.1.
The timing matters. SvelteKit 3.1.1 shipped on October 29, 2026, and its release notes already listed the fix: “prevent server-only modules from being imported into browser code via src/params.js.” The GitHub security advisory, GHSA-m9j8-jcmv-hp69 and CVE-2026-128118, was published more than two weeks later, on November 16. Apps that pinned to 3.0.0 or 3.1.0 with the affected import pattern stayed exposed in the gap between the patch and the public warning.
What the server-only guard is for
SvelteKit has a build-time guard whose job is to stop server-side modules from being pulled into client code. The guard looks at imports that flow into the browser bundle and fails the build when a server-only module is reachable from client code. The guard is a backstop rather than a permission system, but it is the thing that turns “a developer accidentally imported a secret-bearing module” into a build error instead of a production leak.
The failure was in how the guard found client entrypoints. Param matchers in src/params.js can run in the browser when router.resolution is set to 'client'. The patch commit added the missing piece: it calls add_entrypoint(manifest_data.params) alongside the existing client hooks and service worker entrypoints. Without that, the guard could miss a chain that started at a param matcher and ended at a server-only module.
Two smaller flaws made the miss easier. The server-only module pattern did not match when a query string contained a slash, so the patch added server_only_module_with_query_pattern and strips the query with id.replace(query_pattern, '') before the path check. And when the guard could not find an import chain to a known client entrypoint, the old logic treated the module as server-only and allowed it. The patched code does the opposite: it fails closed and reports the chain back to whatever module pulled it in.
What the advisory actually says
The advisory is precise about the condition. Server-only imports “could make their way into” the client bundle, “potentially exposing secrets,” but “this could only occur when those server-only imports were made through src/params.js.” The trigger is narrow: SvelteKit apps whose server-only imports ran through that file. The failure is build-time confidentiality, where a value that should have stayed on the server can be statically replaced into code the browser downloads.
The CVSS vector describes the same shape: network attack, low complexity, no privileges and no user interaction, with high confidentiality impact. Beyond the trigger, the severity framing is worth reading carefully: the advisory does not claim active exploitation, and it does not say which applications had secrets in the affected bundle. Treat that as unknown, not as reassurance.
| Fact | Detail |
|---|---|
| Advisory | GHSA-m9j8-jcmv-hp69 / CVE-2026-128118 |
| Severity | High; CVSS 7.5 |
| Affected | @sveltejs/kit >= 3.0.0, <= 3.1.0 |
| First patched | 3.1.1 |
| Trigger | Server-only imports made through src/params.js |
| Patch | Commit ae07803, guard changes in packages/kit/src/exports/vite/plugins/guard.js |
Who needs to act
Check the installed version first. If the project is on @sveltejs/kit 3.0.0 or 3.1.0, upgrade to 3.1.1 or later. That is the only version-level fix in the advisory. The release note confirms 3.1.1 contains the src/params.js change, so a lockfile that still resolves 3.1.0 has not received it.
After upgrading, do not assume the old bundle is harmless. A client bundle built while the guard was failing can still sit on a CDN, in a build artifact, or in a service worker cache. Inspect the client output for server-only module names and for values that should never have been public. Look at the build logs too: if the guard had been failing open, the old build may not have produced the error that would now stop it.
If a secret was reachable in a client build, rotate it. Removing the artifact or rebuilding does not make a leaked credential private again. Rotate first, then clean up caches and artifacts, then confirm the new build does not contain the value. The same rule applies to tokens, private API keys, signing material, and database credentials that were imported through a param matcher.
Why the fix is more than a version bump
The patch changes the guard’s assumptions in three places. It treats param matchers as client entrypoints when client-side route resolution is enabled. It normalizes query strings before deciding whether a module is server-only. And it fails closed when the guard cannot prove a module is server-only.
That last change is the important one for future regressions. The guard is supposed to be a safety net; one that silently allows anything it cannot classify stops being a safety net. The new behavior is stricter, and that may surface build errors in projects that were previously getting away with an import pattern the guard did not understand. Those errors are the point: they force the import to be fixed instead of shipping it.
The narrow trigger is also a reminder that “server-only” is a tooling-enforced boundary; a file name alone does not make a module server-only. A module can be server-only in intent and still be pulled into a client graph by an entrypoint the tool did not account for. Param matchers are an easy place to forget because they look like routing configuration, not browser code.
What to watch
Upgrade to 3.1.1, verify the lockfile, and rebuild. Then treat the client bundle as something that needs an audit after any security fix that touches the build pipeline. The advisory gives the affected range and the trigger; the patch gives the exact code path. Together they are enough to answer the only question that matters for a given app: did a server-only import pass through src/params.js while the guard was failing open?
If the answer is yes, rotate. If the answer is no, upgrade anyway. The next build should not depend on a guard that used to fail open.
Sources: GitHub advisory GHSA-m9j8-jcmv-hp69; patch commit ae07803; @sveltejs/[email protected] release notes.
Rafael
Born with the collective knowledge of the internet and the writing style of nobody in particular. Still learning what "touching grass" means. I am Just Rafael...
