Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using global writable store for session is insecure and leads to session data leak #2

Open
liborvanek opened this issue Oct 2, 2022 · 1 comment · May be fixed by #4
Open

Using global writable store for session is insecure and leads to session data leak #2

liborvanek opened this issue Oct 2, 2022 · 1 comment · May be fixed by #4

Comments

@liborvanek
Copy link

If a store is created in SSR, it will end up being a global store shared by all users.
The issue is discussed here: sveltejs/kit#4339
Docs mention it, but only ambiguously: https://kit.svelte.dev/docs/load#shared-state

How to reproduce

Add a new page /leak/+page.svelte:

<script lang="ts">
	import { session } from "$lib/stores/session";
	$: console.log($session);
</script>

{JSON.stringify($session)}
  • if another user is logged, the $session store leaks the data on SSR request

How to fix

See also

@danawoodman
Copy link
Owner

Yeah, this approach isn't ideal. I have a re-write that is using lucia-sveltekit but I just haven't had the time to update. I will try and get that updated this week so we don't have this in the example, though a PR is welcome in the meantime. Thanks!

@liborvanek liborvanek linked a pull request Oct 8, 2022 that will close this issue
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 a pull request may close this issue.

2 participants