react-remove-scroll: Violates safe CSPs because of dependency applying style tags
I originally submitted this issue at https://github.com/reach/reach-ui/issues/469, which uses your library as a dependency in their Dialog component.
react-remove-scroll has a dependency called react-style-singleton, of which you are also the author.
My understanding is react-style-singleton creates and modifies inline style tags after application mount. This is somewhat unsafe and if you are using a Content Security Policy (CSP), I don’t think there is any way for this library to work as expected without allowing style-src 'unsafe-inline'.
Here is the trace from my CSP error:

I may be completely missing a secure way to handle this problem.
Thoughts?
Cheers.
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 1
- Comments: 24 (9 by maintainers)
Posting to keep the issue from closing.
Thanks @TheThirdRace. I was looking at CSP rule details and it was clear that neither inline
<style/>norstyle=""would just work and totally missed the.styleoption.And so for the second option one can use
css-variableset via js + static style provided as pure css. Combine the best of both words.That is a very interesting solution and I don’t see any reason why it can’t be implemented. The underlaying
react-remove-scroll-baris doing many things - https://github.com/theKashey/react-remove-scroll-bar/blob/master/src/component.tsx#L17 - but actually it just needs to mendbodyonly style, and the functionality for “other exposed class names” is already duplication bycssVariable, which works way better and gives more control.Proposal:
react-remove-scroll-bar, with all code made imperative, removing all unnecessary functionalityreach-ui. The latter should be safe, as “extra functionality” is not used (while it should).