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

Inline Styles with Strict Content Security Policy #23

Closed
neilchaudhuri opened this issue Sep 11, 2018 · 3 comments
Closed

Inline Styles with Strict Content Security Policy #23

neilchaudhuri opened this issue Sep 11, 2018 · 3 comments

Comments

@neilchaudhuri
Copy link

Problem or feature description:

This is just a heads-up that because the current implementation uses inline styles it violates a strict Content Security Policy (CSP) one might use to prevent XSS attacks. Some might be OK relaxing the CSP by using unsafe-inline, but that basically defeats the purpose.

All is not lost though since you can use mechanisms like a Webpack nonce. Here is an example of the way styled-components uses it.

I suggest that the documentation notes that this could be an issue for some and suggests ways to address it like incorporating a Webpack nonce (for those who use Webpack) with react-compound-slider.

Steps to reproduce (for problems):

Versions (for problems):

React-Compound-Slider: 0.15.0

React: 16.4.10

Browser: N/A

Operating System: N/A

@sghall
Copy link
Owner

sghall commented Sep 11, 2018

This is pretty interesting. I had not heard about this concern with CSS-In-JS before. I think this library is fine though because you can also just pass a className prop to style the root of the slider. Right? All the other elements are rendered by the user so they can all use class names on the individual elements. Or am I missing something?

@neilchaudhuri
Copy link
Author

If you use only class names, that's fine. The problem comes with inline style attributes and style elements, and I don't think I've seen an example that doesn't have an inline style recalculated on an event. If things can work without them, then that's cool. And if someone needs inline styles, they can relax the CSP or use some kind of nonce-based mechanism to clarify the origin of the inline style.

@sghall
Copy link
Owner

sghall commented Sep 16, 2018

Thanks again for raising awareness on this. For RCS there's only one div in the whole library (the slider div) and it can be styled using class names or inline styles. Should not be a concern.

@sghall sghall closed this as completed Sep 16, 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

2 participants