Skip to content

breaking: reject query parameters beginning with x-sveltekit- - #17125

Merged
Rich-Harris merged 1 commit into
version-3from
reject-reserved-params
Sep 23, 2026
Merged

Rich-Harris merged 1 commit into
version-3from
reject-reserved-params

Conversation

@Rich-Harris

Copy link
Copy Markdown
Member

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 change load invalidation behaviour on client-side navigation.


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

ghost commented Sep 17, 2026

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from b9ed29b:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/b9ed29b0a20fa97bbbd9fc540b3ef279d03c41f5

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/kit/pr/17125

ghost commented Sep 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b9ed29b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Major

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

ghost commented Sep 17, 2026

Copy link
Copy Markdown

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}"`);

ghost Sep 17, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could throw a SvelteKitError(400, ...) here to match the server.

ghost Sep 23, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()) {

ghost Sep 18, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this make more sense as a dev-only check like before?

ghost Sep 23, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@ghost
ghost merged commit 8efeeb3 into version-3 Sep 23, 2026
@ghost
ghost deleted the reject-reserved-params branch September 23, 2026 17:20
@ghost ghost mentioned this pull request Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants