breaking: error on event.url, event.params and event.route access inside queries - #16452
Conversation
|
Install the latest version of pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/ba309d449a1a43d944963d88e46a72870b65e476Open in Note This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed. |
🦋 Changeset detectedLatest commit: ba309d4 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 |
event.url, event.params and event.route.id access inside queriesevent.url, event.params and event.route access inside queries
|
The last commit changes how the server recognizes query requests. Instead of loading the remote module to check the function's flavor, it checks whether the client sent |
|
Not sure if that really can be abused but that last commit could have security implications - us not just checking ourselves anymore means an attacker could send along the header to force a different path and consequently break something in a security-relevant way. |
|
I assumed so too, but I couldn't construct an exploit. The header was never verified on any branch. On version-3 every remote request already takes |
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to version-3, this PR will be updated.⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ `version-3` is currently in **pre mode** so this branch has prereleases rather than normal releases. If you want to exit prereleases, run `changeset pre exit` on `version-3`.⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ # Releases ## @sveltejs/kit@3.0.0-next.12 ### Major Changes - breaking: rename `Pathname` type to `Path` and `Asset` to `AssetPath` ([#16430](#16430)) breaking: remove leading `/` from `Path` and `AssetPath` - breaking: write tsconfig to `node_modules/$app/tsconfig` ([#16458](#16458)) - breaking: error on `event.url`, `event.params` and `event.route` access inside queries ([#16452](#16452)) - breaking: delete `$service-worker` module ([#16450](#16450)) - breaking: detect new deployments on data, remote, and form action responses, tab focus, and visibility change, and default `version.pollInterval` to 1 hour ([#16496](#16496)) ### Minor Changes - feat: add `$app/manifest` module with `immutable`, `assets`, `prerendered`, and `routes` exports ([#16372](#16372)) - feat: validate that all remote form fields were created with form.fields.foo.as(...) ([#16331](#16331)) - feat: make `$app/paths` importable in service workers ([#16441](#16441)) - feat: `$app/service-worker` module ([#16458](#16458)) - feat: better tsconfig validation ([#16458](#16458)) - fix: default cookies to `secure` to `false` during development ([#16462](#16462)) ### Patch Changes - fix: allow `undefined` values to be passed to form field `.as(...)` where applicable ([#15681](#15681)) - fix: include queries refreshed from within another query in the serialized response ([#16461](#16461)) - fix: generate sourcemaps for remote modules ([#16440](#16440)) - fix: avoid empty getElementById() call on hash routing navigation ([#16448](#16448)) - fix: warn if hook files are spelled as "hook" instead of "hooks" ([#16483](#16483)) - chore: deprecate the `alias` option ([#16470](#16470)) - fix: prevent infinite loops when server-side queries refresh each other in a cycle during the single-flight drain ([#16461](#16461)) - fix: populate `version` in service workers ([#16434](#16434)) - fix: resolve remote modules as external during dev prebundling so packages can re-export remote functions ([#16426](#16426)) - fix: refetch route-tracking server data when navigating away from an error page ([#16381](#16381)) - fix: serialize `query(...).set(...)`/`query(...).refresh()` values into the rendered HTML when called from within a query during SSR ([#16461](#16461)) - fix: fall back to the page's form actions when a sibling endpoint has no POST handler ([#16349](#16349)) - fix: return a lightweight 404 instead of rendering the error page for subresource requests ([#16463](#16463)) - fix: preserve stripped path prefixes by making trailing-slash redirects relative ([#16431](#16431)) - chore: deduplicate type-stripping logic in `tweak_types` ([#16454](#16454)) - fix: more informative error message when running a command inside a query or prerender function ([`eb5c973`](eb5c973)) ## @sveltejs/adapter-cloudflare@8.0.0-next.3 ### Patch Changes - chore: bump `@cloudflare/workers-types` to `4.20260621.1` ([#16455](#16455)) - Updated dependencies [[`adc4c5b`](adc4c5b), [`ecb0701`](ecb0701), [`4b4cc60`](4b4cc60), [`7390dbe`](7390dbe), [`2e71340`](2e71340), [`c87bc3a`](c87bc3a), [`af15c6c`](af15c6c), [`c6fa431`](c6fa431), [`bfe4dea`](bfe4dea), [`df7dc72`](df7dc72), [`5ae11a1`](5ae11a1), [`781205c`](781205c), [`c87bc3a`](c87bc3a), [`a1bfeb9`](a1bfeb9), [`c87bc3a`](c87bc3a), [`9f0127d`](9f0127d), [`4b4cc60`](4b4cc60), [`8f5b9c7`](8f5b9c7), [`c9b5544`](c9b5544), [`fe1d4a4`](fe1d4a4), [`4b4cc60`](4b4cc60), [`5f78e95`](5f78e95), [`25510fc`](25510fc), [`c99a6cf`](c99a6cf), [`17a45ca`](17a45ca), [`2ca20c3`](2ca20c3), [`eb5c973`](eb5c973)]: - @sveltejs/kit@3.0.0-next.12 ## @sveltejs/adapter-netlify@7.0.0-next.4 ### Patch Changes - fix: await `init` on every request to prevent race condition ([#16467](#16467)) - chore: bump Rolldown to `1.2.0` ([#16455](#16455)) - Updated dependencies [[`adc4c5b`](adc4c5b), [`ecb0701`](ecb0701), [`4b4cc60`](4b4cc60), [`7390dbe`](7390dbe), [`2e71340`](2e71340), [`c87bc3a`](c87bc3a), [`af15c6c`](af15c6c), [`c6fa431`](c6fa431), [`bfe4dea`](bfe4dea), [`df7dc72`](df7dc72), [`5ae11a1`](5ae11a1), [`781205c`](781205c), [`c87bc3a`](c87bc3a), [`a1bfeb9`](a1bfeb9), [`c87bc3a`](c87bc3a), [`9f0127d`](9f0127d), [`4b4cc60`](4b4cc60), [`8f5b9c7`](8f5b9c7), [`c9b5544`](c9b5544), [`fe1d4a4`](fe1d4a4), [`4b4cc60`](4b4cc60), [`5f78e95`](5f78e95), [`25510fc`](25510fc), [`c99a6cf`](c99a6cf), [`17a45ca`](17a45ca), [`2ca20c3`](2ca20c3), [`eb5c973`](eb5c973)]: - @sveltejs/kit@3.0.0-next.12 ## @sveltejs/adapter-node@6.0.0-next.6 ### Patch Changes - fix: preserve stripped path prefixes by making trailing-slash redirects relative ([#16431](#16431)) - chore: bump Rolldown to `1.2.0` ([#16455](#16455)) - Updated dependencies [[`adc4c5b`](adc4c5b), [`ecb0701`](ecb0701), [`4b4cc60`](4b4cc60), [`7390dbe`](7390dbe), [`2e71340`](2e71340), [`c87bc3a`](c87bc3a), [`af15c6c`](af15c6c), [`c6fa431`](c6fa431), [`bfe4dea`](bfe4dea), [`df7dc72`](df7dc72), [`5ae11a1`](5ae11a1), [`781205c`](781205c), [`c87bc3a`](c87bc3a), [`a1bfeb9`](a1bfeb9), [`c87bc3a`](c87bc3a), [`9f0127d`](9f0127d), [`4b4cc60`](4b4cc60), [`8f5b9c7`](8f5b9c7), [`c9b5544`](c9b5544), [`fe1d4a4`](fe1d4a4), [`4b4cc60`](4b4cc60), [`5f78e95`](5f78e95), [`25510fc`](25510fc), [`c99a6cf`](c99a6cf), [`17a45ca`](17a45ca), [`2ca20c3`](2ca20c3), [`eb5c973`](eb5c973)]: - @sveltejs/kit@3.0.0-next.12 ## @sveltejs/adapter-vercel@7.0.0-next.3 ### Patch Changes - fix: await `init` on every request to prevent race condition ([#16467](#16467)) - chore: bump Rolldown to `1.2.0` ([#16455](#16455)) - Updated dependencies [[`adc4c5b`](adc4c5b), [`ecb0701`](ecb0701), [`4b4cc60`](4b4cc60), [`7390dbe`](7390dbe), [`2e71340`](2e71340), [`c87bc3a`](c87bc3a), [`af15c6c`](af15c6c), [`c6fa431`](c6fa431), [`bfe4dea`](bfe4dea), [`df7dc72`](df7dc72), [`5ae11a1`](5ae11a1), [`781205c`](781205c), [`c87bc3a`](c87bc3a), [`a1bfeb9`](a1bfeb9), [`c87bc3a`](c87bc3a), [`9f0127d`](9f0127d), [`4b4cc60`](4b4cc60), [`8f5b9c7`](8f5b9c7), [`c9b5544`](c9b5544), [`fe1d4a4`](fe1d4a4), [`4b4cc60`](4b4cc60), [`5f78e95`](5f78e95), [`25510fc`](25510fc), [`c99a6cf`](c99a6cf), [`17a45ca`](17a45ca), [`2ca20c3`](2ca20c3), [`eb5c973`](eb5c973)]: - @sveltejs/kit@3.0.0-next.12 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Closes #16416 with the error option which seems like the right approach to me. No hard feelings if it goes.
event.url,event.paramsandevent.routenow throw on access insidequery,query.batchandquery.live, during SSR as well, matching how prerendering already treatsurl.search. The router runs on the client-sentx-sveltekit-pathnameheader to produceevent.paramsandevent.route.id, so hiding onlyurlwould leave the same footgun readable throughparams.localsviahandlestill works, but since query requests no longer carry the page URL,handlesees the URL of the remote endpoint, so that context has to come from cookies or headers.commandandformare unchanged when called directly. Remote functions called while a query is running inherit the restriction, since their results feed the same cached response.handleValidationErrorreceives an event it can readurlon, and prerendered data lookups inside queries resolve against the request URL rather thanevent.url.x-sveltekit-pathnameandx-sveltekit-searchheaders, and the server only applies them when they are present, which also fixes the query half of Remote functions fire during hydration with placeholderpage.url, causing wrong server-side route resolution #15749.event.routeandevent.urlto remote functions #14606 asserting queries can read the url is inverted, and the remote-functions docs bullet now documents the error.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