Skip to content

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

Closed

Description

@ilmartyrk

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);

Activity

  1. HazAT commented on Apr 12, 2019

    @HazAT
    Member

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

  2. self-assigned this
    on Apr 12, 2019
  3. ilmartyrk commented on Apr 12, 2019

    @ilmartyrk
    Author

    Yes, that fixed it

  4. HazAT commented on Apr 16, 2019

    @HazAT
    Member

    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.

  5. ilmartyrk commented on Apr 16, 2019

    @ilmartyrk
    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 :)

  6. teriu commented on Sep 1, 2019

    @teriu

    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.

  7. hugmanrique commented on Oct 31, 2019

    @hugmanrique

    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
    });
  8. kamilogorek commented on Nov 8, 2019

    @kamilogorek
    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

  9. bendehghan commented on Feb 25, 2021

    @bendehghan

    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.

  10. carlin-q-scott commented on Mar 19, 2022

    @carlin-q-scott

    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.

  11. tj-kev commented on Apr 5, 2023

    @tj-kev

    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.

  12. mydea commented on Apr 5, 2023

    @mydea
    Member

    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))

  13. leonk commented on Oct 18, 2023

    @leonk

    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?

  14. mydea commented on Oct 18, 2023

    @mydea
    Member

    @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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions