Skip to content

Universal example has xss vulnerability #1855

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

Closed
brigand opened this issue Jul 19, 2016 · 1 comment
Closed

Universal example has xss vulnerability #1855

brigand opened this issue Jul 19, 2016 · 1 comment

Comments

@brigand
Copy link
Contributor

brigand commented Jul 19, 2016

Say the initial state is {"foo":"some string"}, you're fine, but if it's is {"foo":"</script><script>alert('xss')</script><script>"} then you're screwed.

Not an issue if you're sure it's an integer, but I've seen people use this exact pattern in other places where it could cause serious issues, so best to get it right in a common point of reference.

A simple solution is to escape the <s, but not sure if there's a better way to do it.

window.__PRELOADED_STATE__ = ${JSON.stringify(preloadedState).replace(/</g, '\\x3c')}
@steida
Copy link

steida commented Jul 23, 2016

Use serialize-javascript. Example: https://github.com/este/este/blob/443b78e894d0aa5c666b3df8a60b6bfd2397c7d3/src/server/frontend/render.js#L48

seantcoyote pushed a commit to seantcoyote/redux that referenced this issue Jan 14, 2018
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

No branches or pull requests

3 participants