question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Documentation should clarify that server state is not automatically per-request

See original GitHub issue

Describe the bug

External variables, stores and other states processed during Load functions will keep in memory references that will remain upon all visitors of the website that is handled by the same server node instance.

This happens with “svelte-kit dev” “svelte-kit preview” and in production, at least tested in Netlify.

I think this issue comes from the assumption than node SSR is running clean on each instance.

To Reproduce Use this basic demo repo https://github.com/Egnus/sveltekit-bug-server-XSS-repro

run npm run dev and go to localhost:3000/todos. There is a further red text block explaining what happens there

reload the page several times, and notice how the counter stays with 1 in browser but keeps growing in the Server, which is also accessible by the visitor by viewing source code or disabling Javascript so the hydratation doesn’t fix the XSS issue

Use several browsers and incognito mode to find the same values shared for all users. An experienced hacker could get access to others data by accesing those values on memory.

Expected behavior SSR runs clean in every call. (ideal safe option) forced by the sveltekit boot. OR Documentation could clearly states this issues and how to protect from XSS during Load.

Information about your SvelteKit Installation: This is happening with the latest version of SvelteKit

Severity Very severe since this is not mentioned in the documentation: https://kit.svelte.dev/docs#loading-input-context and also there is no clear mention of this memory between calls anywhere.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
Egnuscommented, Jul 7, 2021

Well I have to say that Svelte has one of the best documentations I have ever seen (together with three.js) having at least those warnings I think is the bare minimun for the mainly focused frontend developers who are facing for the first time a Fullstack experience with more control over SSR rules. Many people, me included, until not a long ago, thought that each call to a server was clean as there were no reason to believe that scoped variables would be accesible by different users and different times. And somehow I feel like this is good to mention so the people organice their code earlier knowing this surprising behaviour for pure FE devs.

1reaction
benmccanncommented, Jul 8, 2021

there were no reason to believe that scoped variables would be accesible by different users and different times

To clarify the issue here, scoped variables aren’t accessible by different users. The issue is that there’s an unscoped global variable:

https://github.com/Egnus/sveltekit-bug-server-XSS-repro/commit/05fe07de52c2a9fabf018175130b90328620973e#diff-276a0044b7db537e1835eb8b2c20368b8a7437a3fde350198bff4db2b9e418fe

Read more comments on GitHub >

github_iconTop Results From Across the Web

Language Server Protocol Specification - 3.17
This document describes the 3.17.x version of the language server protocol. An implementation for node of the 3.17.x version of the protocol can...
Read more >
Kafka 3.3 Documentation
Servers : Kafka is run as a cluster of one or more servers that can span ... This will impact JMX monitoring tools...
Read more >
SageMaker — Boto3 Docs 1.26.37 documentation
Amazon SageMaker places no restrictions on their use. ... such as automatic one-click Autopilot model deployment, will not be completed.
Read more >
RFC 2965: HTTP State Management Mechanism
The terms request-host and request-URI refer to the values the client would send to the server as, respectively, the host (but not port)...
Read more >
Mobile Device Management Protocol Reference
In this document, if any configuration option is limited to ... The server must not assume that the device will automatically poll the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found