Title: CSP inline script violation when loading Sentry SvelteKit · Issue #8925 · getsentry/sentry-javascript · GitHub
Open Graph Title: CSP inline script violation when loading Sentry SvelteKit · Issue #8925 · getsentry/sentry-javascript
X Title: CSP inline script violation when loading Sentry SvelteKit · Issue #8925 · getsentry/sentry-javascript
Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using the latest SDK release https://github.com/...
Open Graph Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
X Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/8925
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"CSP inline script violation when loading Sentry SvelteKit","articleBody":"### Is there an existing issue for this?\n\n- [X] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues\n- [X] I have reviewed the documentation https://docs.sentry.io/\n- [X] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases\n\n### How do you use Sentry?\n\nSentry Saas (sentry.io)\n\n### Which SDK are you using?\n\n@sentry/sveltekit\n\n### SDK Version\n\n7.66.0\n\n### Framework Version\n\n7.66.0\n\n### Link to Sentry event\n\n_No response_\n\n### SDK Setup\n\n```\r\n Sentry.init({\r\n dsn: env.PUBLIC_SENTRY_SVELTEKIT_CLIENT_DSN,\r\n integrations: [\r\n new Sentry.BrowserTracing(),\r\n new CaptureConsoleIntegration({\r\n levels: [\"warn\", \"error\", \"assert\"],\r\n }),\r\n ],\r\n release,\r\n environment: env.PUBLIC_ENV_NAME,\r\n // Set tracesSampleRate to 1.0 to capture 100%\r\n // of transactions for performance monitoring.\r\n // We recommend adjusting this value in production\r\n tracesSampleRate: 1.0,\r\n attachStacktrace: true,\r\n ignoreErrors: [\r\n \"TypeError: Failed to fetch dynamically imported module\",\r\n \"Load failed\",\r\n \"TypeError: Load failed\",\r\n \"TypeError: Failed to fetch\",\r\n \"Failed to fetch\",\r\n \"TypeError: NetworkError when attempting to fetch resource\",\r\n \"TypeError: Importing a module script failed\",\r\n \"TypeError: error loading dynamically imported module\",\r\n ],\r\n });\r\n Sentry.setTags({\r\n server_name: env.PUBLIC_DATADOG_HOST_NAME,\r\n version: release,\r\n service: \"agent-webapp\",\r\n });\r\n```\n\n### Steps to Reproduce\n\nOpen the browser console and load a page where Sentry is loaded\n\n### Expected Result\n\nNo CSP errors\n\n### Actual Result\n\nOn page load, I get the following CSP error in the console:\r\n```\r\nRefused to execute inline script because it violates the following Content Security Policy directive: \"script-src 'self' \u003cthe rest of my script-src>\". Either the 'unsafe-inline' keyword, a hash ('sha256-+X7Z1KW2Vcl9pendYbp0FYL6F0HZek43aBP/14cwq+U='), or a nonce ('nonce-...') is required to enable inline execution.\r\n```\r\n\r\nI get this error in version `7.65.0` but not `7.64.0`.\r\n\r\nI believe this was introduced in [this PR](https://github.com/getsentry/sentry-javascript/pull/8802), where the following script tag is injected into the head tag:\r\n```\r\n\u003cscript>\r\n const f = window.fetch;\r\n if(f){\r\n window._sentryFetchProxy = function(...a){return f(...a)}\r\n window.fetch = function(...a){return window._sentryFetchProxy(...a)}\r\n }\r\n\r\n \u003c/script>\r\n```\r\n\r\nAs a temporary workaround, I've added `sha256-+X7Z1KW2Vcl9pendYbp0FYL6F0HZek43aBP/14cwq+U=` to my `script-src` CSP, but ideally I wouldn't have to update this hash each time the injected script is changed.","author":{"url":"https://github.com/ncvc","@type":"Person","name":"ncvc"},"datePublished":"2023-08-31T20:42:32Z","url":"https://github.com/getsentry/sentry-javascript/issues/8925"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c033a611-9c7f-84da-aff0-c6a5a27f1ff2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C6EE:1425F4:5F73CE:869147:6B0449D3 |
| html-safe-nonce | 54e0e0c886beb051fb18f05d7f055cc18d8637b350049bed860e67cba55eb7e5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNkVFOjE0MjVGNDo1RjczQ0U6ODY5MTQ3OjZCMDQ0OUQzIiwidmlzaXRvcl9pZCI6IjcxNjUzNzI1MjI0MzM4OTA3NzEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 77c094b335e4c9f3d93f7bff5c84b8c625f15c12331c911a6cef8494d7843bd3 |
| hovercard-subject-tag | issue:1876274074 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/8925/issue_layout |
| twitter:image | https://opengraph.githubassets.com/915355f73684654407bd7e0401b81c1bb863d0ad8c4871ac1714000ad975b818/getsentry/sentry-javascript/issues/8925 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/915355f73684654407bd7e0401b81c1bb863d0ad8c4871ac1714000ad975b818/getsentry/sentry-javascript/issues/8925 |
| og:image:alt | Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ncvc |
| hostname | github.com |
| expected-hostname | github.com |
| None | d4495c3631faba668036f176d1f5946901c5172efd73a6edb984029e7d4f8e46 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9ac4337fb7c6a5846cdfdb1a04f154d3c33ebc77 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width