Repository navigation
breaking: reject query parameters beginning with x-sveltekit- - #17125
Conversation
commented
Sep 17, 2026
|
Install the latest version of pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/b9ed29b0a20fa97bbbd9fc540b3ef279d03c41f5Open in |
commented
Sep 17, 2026
🦋 Changeset detectedLatest commit: b9ed29b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
| async function load_data(url, invalid) { | ||
| for (const key of url.searchParams.keys()) { | ||
| if (key.startsWith('x-sveltekit-')) { | ||
| throw new Error(`Cannot use reserved query parameter "${key}"`); |
There was a problem hiding this comment.
Could throw a SvelteKitError(400, ...) here to match the server.
There was a problem hiding this comment.
SvelteKitError on the client is a bit of a funny one in that it requires an HTTP status code even though no request is taking place — we haven't really figured out hard and fast rules about when which representation is appropriate but there are more throw new Error(...) occurrences in this file than throw new SvelteKitError(...) so I think it's probably okay to keep it as-is
| * @returns {Promise<import('types').ServerNodesResponse | import('types').ServerRedirectNode>} | ||
| */ | ||
| async function load_data(url, invalid) { | ||
| for (const key of url.searchParams.keys()) { |
There was a problem hiding this comment.
Does this make more sense as a dev-only check like before?
There was a problem hiding this comment.
This is a belt-and-braces thing, but if you were to render a link from untrusted data you could end up preventing a client-side navigation from correctly invalidating stuff. Even though it's not really a vulnerability (at the very least, using untrusted data in this manner falls outside our threat model) it's probably good to prevent it in production rather than merely steering people away from it in dev
This is a belt-and-braces thing more than anything — it gives us the ability to add more
x-sveltekit-params in future if we need them, and also makes it impossible to accidentally changeloadinvalidation behaviour on client-side navigation.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.Edits