-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[CSP] "style-src" MUITabs and some other component have inline styles not nonced by the CreateEmotionCache #40435
Comments
i was wondering if there are any updates on this. 🤠 @mnajdova |
Does this mean that #38965 is resolved? Some components just need to have an inline style, for e.g. Slider, Tabs etc. Have you tried using CSPunsafe-hashes keyword to our style-src directive, or |
I'm wondering how come instead of any place where there is a style attribute being set it is not simply replaced by a first-child style element so a nonce can be applied from the emotion cache and we don't have a strict CSP breaking it. |
I use Nextjs and pass a nonce to MUI serverside like so: I am seeing inline-styles blocked by CSP in multiple components:
As it stands, I can either
|
@majoer I haven't been able to fix the Tabs one yet. But for the Paper and Accordion I've found a very hacky workaround: I've created a theme in which I override the default style prop of the Paper component:
|
Steps to reproduce
Link to live example: https://github.com/Mateo-P/nonce-problem.git
Steps:
1 cp
.env.example
to.env
2.
yarn install
3.
yarn run dev
4. open the browser console (firefox is more descriptive in this case)
Current behavior
Expected behavior
not showing the error on console browser.
Context
we are using remixjs+MUI and want to add CSP-Headers following these guides:
CSP-guide
remix-Styling
we added the nonce-value to the cache on
CreateEmotionCache.tsx
:it works with most of the components and all
sx's
but we have found that some components includingMUITabs
have a defaultstyle=""
which is not handled by the CSP nonce config followed in the documentationon MUITabs docs by inspecting the component on the browser the default
style="overflow:hidden;margin-bottom:0"
is shown.Your environment
npx @mui/envinfo
Search keywords: nonce csp inline styles MUITabs style="overflow:hidden;margin-bottom:0"
The text was updated successfully, but these errors were encountered: