CVE-2026-128118: SvelteKit: Build-time server-only module import guard could fail, resulting in server secrets being statically replaced in client bundle
SvelteKit 3.0.0 through 3.1.0 can leak server-only code and secrets into the browser bundle when a server-only module is imported through src/params.js. The build-time guard that normally blocks this fails in that case. Upgrade @sveltejs/kit to 3.1.1.
Published Nov 16, 2026 · Analysis Nov 16, 2026
What an attacker can do
SvelteKit blocks imports of server-only modules, such as $env/static/private, from client code at build time. If a server-only import is reached through src/params.js, the guard can fail. The server value is then replaced statically into the client bundle, which is shipped to every visitor.
No attacker action is needed at runtime. Anyone who loads the site can download the JavaScript and read the leaked values. API keys, database URLs and tokens that live in private environment variables are the likely exposure, if your params matchers import them.
The fix is a build-time change, so a deployed bundle built with a vulnerable version stays exposed until you rebuild and redeploy. Rotating the secrets matters too, because the old bundle may be cached or archived.
Who is affected
@sveltejs/kit >= 3.0.0 and <= 3.1.0, and only if src/params.js (param matchers) imports server-only modules directly or indirectly. Apps that do not import server code there are not affected by this path.
Check the installed version:
npm ls @sveltejs/kit@sveltejs/kit
- Ecosystem
- npm
- Affected
- >= 3.0.0, <= 3.1.0
- Fixed in
- 3.1.1
- Check
npm ls @sveltejs/kit
How to fix it
Upgrade to @sveltejs/kit 3.1.1:
npm install @sveltejs/[email protected]The release note for 3.1.1 says it prevents server-only modules from being imported into browser code through src/params.js. The advisory lists no workaround. Rebuild and redeploy after the upgrade. If you shipped a build from an affected version that imported secrets in params.js, rotate those secrets.
How to tell if you were hit
Open src/params.js and look for imports of $env/static/private, $env/dynamic/private, $lib/server modules, or files that pull them in. Search built client assets, for example the .svelte-kit/output/client directory, for strings that should exist only on the server, such as key prefixes or internal hostnames. The advisory describes no other indicators.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
Under certain circumstances, server-only imports, which typically cannot be included in the client bundle, could make their way into it, potentially exposing secrets. This could only occur when those server-only imports were made through src/params.js.
Credited to elliott-with-the-longest-name-on-github, Rich-Harris.
Questions
- Does CVE-2026-128118 affect every SvelteKit app?
No. It needs SvelteKit 3.0.0 to 3.1.0 and server-only imports reached through src/params.js. Apps that keep params matchers free of server imports do not hit it.
- Is a rebuild needed after upgrading?
Yes. The leak happens at build time, so an old bundle keeps any secrets embedded in it. Rebuild with 3.1.1, redeploy, and rotate exposed secrets.
- Is there a workaround?
The advisory gives none. Removing server-only imports from src/params.js avoids the failing path until you upgrade.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology
More npm vulnerabilities
All npm entriesCVE-2026-128116
SvelteKit: Protocol-relative module import during server-side route resolution allows cross-origin script execution
medium5.3Nov 16, 2026CVE-2026-128119
SvelteKit: Private `query.batch` functions could collide, producing unexpected parameter / function combinations
medium5.9Nov 16, 2026CVE-2026-128120
SvelteKit: DoS while parsing form data from a remote functions `form`
high7.5Nov 16, 2026CVE-2026-128117
SvelteKit: adapter-node crashes with an unhandled URIError when `reroute` rewrites malformed pathnames
medium5.9Nov 13, 2026CVE-2026-114060
SvelteKit: URL redirection to untrusted site via enhanced form submission
low4.7Oct 23, 2026CVE-2026-114061
SvelteKit : XSS via untrusted cache-control header in prerendered page
lowOct 23, 2026
