react-colorful: Added styles do not conform to any CSP rules.
Hey I am using this cool component in my react project, but I am having an issue with the Content Security Policy.
Although I am doing client side rendering with makeStyles from material-ui, I use the nonce because I am building an app with electron and want to secure it as much as possible.
Right now I am using a nonce to only allow self styles and styles with a specific nonce. The useStyles hook created by makeStyles does add the nonce to the style because it uses JSS
The problem is that styles in react-colorful are applied to the html without JSS so no nonce is added.
Possibly related topics are: #109 #110
Any idea on how to solve the problem?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 19 (12 by maintainers)
Thanks it works. I used the setNonce. Just for the completion of the discussion, the meta propery is what is used by JSS. Not complaining. I mean there are other
metatags for the nonce as well so yeah I guess you cant support everything.Thanks for the fix.
Cheers
@omgovich The CSP helps to protect against the attacks where the malicious code or style is injected onto a page. It works as follows:
style-src nonce-Vlad42. The nonce isVlad42and it must be randomly generated and unique for each request.<style nonce="Vlad42". (the page doesn’t have access to http response, so it makes it impossible to inject style tags without having access to the original html served).I guess the solution would be to allow
makeStylesto accept an optional hash of arguments.