Repository navigation
feat: implement skew protection - #11987
Conversation
🦋 Changeset detectedLatest commit: d9bb954 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 |
|
Woohoo! Thank you for implementing this 🥳 |
| value: 'document' | ||
| }, | ||
| headers: { | ||
| 'Set-Cookie': `__vdpl=${process.env.VERCEL_DEPLOYMENT_ID}; Path=/${builder.config.kit.paths.base}; SameSite=Strict; Secure; HttpOnly` |
There was a problem hiding this comment.
previously you deleted the cookie for the version.json route - is that not necessary after all? Not necessary because it's not a document request?
There was a problem hiding this comment.
correct — we only care about non-document requests for this file. AFAICT there's no way to set multiple cookies (you can't do set-cookie: [...], and if you add a header in multiple continue routes the last one wins), so we had to get rid of it
There was a problem hiding this comment.
wait, no, hang on... this is a problem — the version.json will be requested with the old deployment ID. gah
There was a problem hiding this comment.
(this seemed to work in my testing, because the cookie was still in my browser from the earlier iteration 🤦 )
There was a problem hiding this comment.
I've 'fixed' this by setting the second set-cookie header on the response for the entry point, since we know it will happen before the client hydrates. Since adapters don't have access to the build manifest, this involves some hackery, but hopefully we can remove it in future once the Build Output API supports setting multiple set-cookie headers in a single response.
Co-authored-by: Ben McCann <[email protected]>
Fixes #17730 Skew Protection currently scans `immutable/entry` for `start.*` to attach the cookie that exempts `version.json` from deployment pinning. Single bundles have no such directory, so adaptation fails after the client/server builds succeed. Inline bundles likewise have no external entry request. The separate-response workaround introduced in #11987 was necessary because the legacy route headers map could not express multiple cookies. Vercel's current [Build Output API](https://vercel.com/docs/build-output-api/configuration#routes) supports appending response headers with multiple values, and the adapter already uses routing transforms. This removes the obsolete entry scan and appends both independent `Set-Cookie` values on the existing document route. The deployment cookie and the more-specific empty version cookie retain their scopes and security attributes; the exemption is now installed on the HTML response rather than a later JavaScript response. Branching the scan for each bundle strategy would retain unnecessary dependence on output filenames and entry requests, especially since inline output files are removed by #16025. This covers split, single, and inline output, SSR and prerendered documents, and custom `paths.base`/`appDir`, without changing ISR dispatch, immutable caching, filesystem routing, or missing-asset handling. - [Ported reproduction using the reported versions](https://www.sveltelab.dev/#code=N4IgdA5glgLlEDsD2AnApiAXKAZlANhtiAMZIIxoUDOWIyAJmgPoC2SDArodQDoL8AxAAIA8pxgAHCfzBIJ0mLIBuaFCTT5ZCNDHxQcAT1kB3FAEMEEQin4B6MNVX5KAWgDWsewCNOBBvxCYgDKsgAiwczBMKho-AAqABacrN7UYAzegQgiAKIIyrJUhQhgxWAAVPwAhGUFZQAe5qyShDV1ymCU1EoCOcIAarBxBcNgZAh4EGAAVulwrGg9zZKuVaOU4%2BRTXfNQi8sta-wgAL6nADQg1OpYoAxQ6CQxKIZ3IOaSkmCJMKz47zwhHeE0oNDoAB5qgwkM9DJI0MJfv8AHz8CHI-DCfCWCAAXl4ICohLRAhgGLQ5gYpN4SnJixg5mEJES5hQ1F0BJAEhwrgAHIThHYaXSIQymQhmmgucooGgTJJUEoQMzyGCYFyTFAGDBEnimLKNK4tTrEhdhFAELAoOZ8K5qCRbdKAIyC4WBUXi4SSxZcygNGD2x1tFWgqgawkOp1ukW0gCkTk0lE8MB%2BlIYcY9ELsiXTIoh3g4hmEDHMjPtzmTsFcknQ%2BCQVNcpcZXMSSFUthAsfJD2Uwh6hkIXIe1Fa5kMmFVFHDfC7CcraBTYELDEMcezvfzdhXhlJ2cxpLOlxAKHk3XeDyeLzexAA1JJzBA0I4F4CCERQGHwZgQBjnSiAHVNDIRZhBiYRggXABpWB93-dFJBRIZqFgYQISZRJ0BwVsYCkahMDsOxExcZ8DTsGESGoOwUxJYjNjIiiqJTbNzBRMCkGEdAqTA3MS1hFJwzLKByGzRCTnOK5bxxQwzxfJMPxAIEFK-GBaB-CEHRQKBJBgbFcT9WcRUIXTgGZRJ-HQBBhFOYQ8WEAASWskEkagAAoAEoAG50SIkgtJ0mkEGAAABSymBQMyLKoDzTnE854quMAEEkVhbmIJSQTVGc6CoaAdHtGAtOePFCs4EYjyuB8SHcR9nzmcg32BYgVLUkBgA9QkfTiLBhEJFNXGdAB2QaAGYAAZCQuDqQA7FDyEJSdCTGsBltdEAprJQlaygZQy26ydSrQDbaUJGB4X23qQHYLgQ2O5VNO01SFuEdrNuVA1nsJWVKBLNBCnWjrlV8fxPpAAZcgAJQAYVyAAZKIoNyADmAABQh0R4lyKH4gASVEAA5ZhcnxgBBAAhWHcjCPFnUGSGYfhsJchR2HRAATQAWWJ%2BJmBx6mGFaZh0Cc4RvsRYH8ACAG3q29BZXlUGxeEWs-rlExJsB2W0AfdBQbotAPFQ6hDAQEhCQ9S5poNMJtaoJhTblWdJ1ek7lWC-W5jsKlPkoFBXA7DQtB6wkAFYwAATjANa7pOkB3YXT2aODkAACYwBG50o41mW449qixZrfBODyit5NBsPM%2BjzXrgXcv075Fbs9d07zoenS68jlOm7pL7hlBgA2dOwBD82yVihBx4qmaxgmHZVMa5Ssu-EB9kVFATP7BcU2s4QcFPVhhAAcnj%2BTE9gOwxcP7yrRaJUXt%2BvAdCh7Z4B3vekAPw-L%2Bv-g0AaNfdJMBwOYbggC0CPzQM-SY8BXKmVaMXS0%2BFhAAG19Ypg8gAXWsl5OKVx9ZbGgdMOYC9MrTmXqvO%2B3sdJqF3vvI%2BJ8SKeyob7f2ahA5X2yH-ABD8QEuBeh6FMztAbMLUJOERKAPIxxiAoCQzthC%2BAQAwQg0QLCUAgBOI%2BKErCEEPtZC2-BTjXynqpWe8BZjUAauld8pD1StRdsqP%2BYIGBO0umABw%2BtDYwDsCYl%2BRCLECGlrHECkh3woFEDpYSCAXGmUjIVKAzxnqHT0RPOKpwgA) <!-- svelte-triage-bot:feedback-baseline:1b737b13847ffb736fce6d2d743115473b9b1dfe --> --------- Co-authored-by: svelte-triage-bot <[email protected]>
closes #10947
This implements Vercel Skew Protection. Tested manually
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