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

Ensure preloadedState is immutable on store create #85

Merged
merged 1 commit into from
Nov 26, 2018

Conversation

codinronan
Copy link
Contributor

In getStore in kea, the preloadedState is used as-is, allowing external actors to change the store underneath redux' nose. This specifically WILL happen when using Kea with Next, since the store is created once on the client and new data pushed into it via the Next.js update mechanism. The result is that react-redux believes the object has not changed, and components do not update.

Worse, the store is globally available on Window, and the result is that a malicious script would be able to change the store the app believes it is using, without its knowledge.

This change ensures that cannot happen, and retains the redux guarantee of state immutability.

In `getStore` in kea, the `preloadedState` is used as-is, allowing external actors to change the store underneath redux' nose. This specifically WILL happen when using Kea with Next, since the store is created once on the client and new data pushed into it via the Next.js update mechanism. The result is that `react-redux` believes the object has not changed, and components do not update.

Worse, the store is globally available on Window, and the result is that a malicious script would be able to change the store the app believes it is using, without its knowledge.

This change ensures that cannot happen, and retains the redux guarantee of state immutability.
@mariusandra mariusandra merged commit c481827 into keajs:master Nov 26, 2018
@mariusandra
Copy link
Member

Hey, v0.28.5 is out with the patch!

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 this pull request may close these issues.

2 participants