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

Gives error without CSP style-src 'unsafe-inline' #2020

Closed
4 tasks done
ilmartyrk opened this issue Apr 12, 2019 · 13 comments
Closed
4 tasks done

Gives error without CSP style-src 'unsafe-inline' #2020

ilmartyrk opened this issue Apr 12, 2019 · 13 comments
Assignees

Comments

@ilmartyrk
Copy link

Package + Version

  • @sentry/browser

Version:

5.0.8

Description

While using example setup for angular, I get error
Refused to apply inline style because it violates the following Content Security Policy directive: "style-src .... I tried adding nonce to the sentry script tag and also added sha256- from the error message but it still occured.

My setup was easy, followed instructions on your page.
https://docs.sentry.io/platforms/javascript/angular/#angularjs-1x -> used the standalone part.
Also added urls following your CSP :
https://forum.sentry.io/t/required-content-security-policy/4484 -> updated the script-src value to add https://browser.sentry-cdn.com

Error traces back to:
sentryWrapped | @ | helpers.ts:84
that is:
return fn.apply(this, wrappedArguments);

@HazAT
Copy link
Member

HazAT commented Apr 12, 2019

So just to make clear, you fixed this by adding unsafe-inline?

@HazAT HazAT self-assigned this Apr 12, 2019
@ilmartyrk
Copy link
Author

Yes, that fixed it

@HazAT
Copy link
Member

HazAT commented Apr 16, 2019

Since this isn't really a bug with the SDK I will close this issue. I hope people running into this will find the issue. Adding this to the docs is also not crystal clear since the solution heavily depends on your individual setup.

@HazAT HazAT closed this as completed Apr 16, 2019
@ilmartyrk
Copy link
Author

@HazAT, I'll try to find the cause of this problem and when I get my head around it, I'll post the info in here :)

@teriu
Copy link

teriu commented Sep 1, 2019

I get the same error when I try to display the User Feedback Dialog! As a workaround, we're just going to load the CSS manually.

@hugmanrique
Copy link

A way to tell Sentry not to inline the CSS through a loadStyles param would be great to avoid this issue:

Sentry.showReportDialog({
  eventId: 0,
  loadStyles: false
});

@kamilogorek
Copy link
Contributor

@hugmanrique this would have to be implemented inside Sentry itself first, as the SDK just includes a script which then creates an iframe. https://github.com/getsentry/sentry

@bendehghan
Copy link

This is a big issue for Chrome's push for manifest V3. Our chrome extension uses sentry. It's stitched throughout the code and we don't want to take it out. But with manifest V3 unsafe-inline is not an option. This really needs to be fixed and quickly since there is a deadline from Chrome.

@carlin-q-scott
Copy link

carlin-q-scott commented Mar 19, 2022

Adding unsafe-inline to a CSP is not safe. So I don't think this issue is resolved.

Google Maps SDK grabs a nonce from the first <style nonce="a-nonce-hash"> and uses it on it's own inline styles.

@tj-kev
Copy link

tj-kev commented Apr 5, 2023

Is there any update on this? I have a strict CSP and adding unsafe-line should not be the solution. I am now reluctant to turn on CSP reporting to sentry as this will create a lot of entries.

@mydea
Copy link
Member

mydea commented Apr 5, 2023

For problems regarding CSP & Replay, please refer to newer issues (or create a new issue for it if no open issue matches it) - thank you! (for reference, I answered here: #6739 (comment))

@leonk
Copy link

leonk commented Oct 18, 2023

I agree with #2020 (comment) this issue is not resolved, using 'unsafe-inline' should not be a solution.

I found there is similar issue to script-src, however this can be resolved using a hash, see #8925 (not ideal, but at least it's pretty secure).

I couldn't work out a way to do the same for style-src, so from what I can see 'unsafe-inline' must be used. But perhaps a hash or nonce solution could be provided?

@mydea
Copy link
Member

mydea commented Oct 18, 2023

@leonk can you open a new issue with details on what you are doing? What is your config, which SDK, ... what functionality are you using/calling, etc? For just basic functionality without replay compression you shouldn't need to add any CSP rules. Or if you are using sveltekit, please post more details into #8925.

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

10 participants