security: Stop automatically adding URLs from server-side load fetch calls to dependencies - #9945
Conversation
🦋 Changeset detectedLatest commit: 487aa22 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 |
…ve-implicit-dep-tracking
| /** | ||
| * Automatically add server-side `fetch`ed URLs to the `dependencies` map of `load` functions. This will expose secrets | ||
| * to the client if your URL contains them. | ||
| */ | ||
| trackServerFetchesPotentiallyExposingSecrets?: boolean; |
There was a problem hiding this comment.
I think we can trim the option name down to trackServerFetches — we can explain the details in the inline documentation, and the dangerZone makes it clear that this is 'know what you're doing' territory
| /** | |
| * Automatically add server-side `fetch`ed URLs to the `dependencies` map of `load` functions. This will expose secrets | |
| * to the client if your URL contains them. | |
| */ | |
| trackServerFetchesPotentiallyExposingSecrets?: boolean; | |
| /** | |
| * Mark server `load` functions that call `fetch(url)` as depending on `url`, allowing you to | |
| * call `invalidate(url)` from the client. The URL, including e.g. sensitive query parameters, | |
| * will be visible to the client. This option will be removed in version 2; use `depends` instead | |
| */ | |
| trackServerFetches?: boolean; |
There was a problem hiding this comment.
I dunno, I like explicitly requiring users to acknowledge what they're doing -- there's no guarantee they understand why this is dangerous. Happy to make the change, but I personally think the annoyance of typing a gigantic and explicit config value is worth it, especially since it's not going to be around forever.
Closes #9803. This is a breaking change for security purposes.
This PR prevents server
loadfunction from implicitly depending on URLs passed tofetch. This is because dependencies from serverloadfunctions have to be sent to the client in order to be invalidated, which can leak secrets (if they're in the search params, for example).If you understand the risk and want to keep the old behavior, you can set
config.kit.dangerZone.trackServerFetchesPotentiallyExposingSecretstotrue.TODO:
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:.