-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
CSP inline script violation when loading Sentry SvelteKit #8925
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
Comments
Hi @ncvc thanks for reporting! Dang, this isn't great - we totally missed this aspect when implementing #8802. I need to think about a solution here as I really don't want to revert #8802 if possible at all. Fwiw, I have no plans to touch this script any time soon so the hash should stay pretty constant (famous last words I guess). However, I'd like to avoid putting that burden of adjusting CSP on users. If you anyone has a suggestion, I'm all ears ;) |
I have an idea how we can fix this but I'm curious on the community's thoughts around the fix: We currently inject our fetch proxy script in We can get around the CSP error if we adapt the handler to:
A more brittle alternative would be to just add the script's hash to the CSP header. My concern is that users might not be happy about our SDK modifying their CSP header. To mitigate this, we can add a option (e.g. Additionally, we can also allow users passing an optional, custom nonce (or hash) to Needless to say, all of this only applies if users actually turned on CSP and a CSP header is already set on the response. |
This issue has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you remove the label "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
It’s totally preventing us to upgrade Sentry past 7.64.0, so let’s reset that clock ;-) I think allowing to pass a custom nonce/hash to sentryHandle would be a nice solution here. |
I can see that as a compromise. Less intrusive than modifying the CSP header and it gives users full control over the the used method. However, it'd require manual action to adjust CSP. I think it's something we can live with for now and possibly add an automatic option later on if there's demand for it. |
Downgraded to |
Hi, sorry for the long wait. I'm aware it's not yet fixed but very busy with other tasks. Will try to get this fixed this or next week. |
how did downgrading fixed the problem for you? I'm still having this problem after downgrading. Will wait for @Lms24 comments on addressing root cause. |
Downgrading to 7.64.0 should fix the issue as before that we didn't inject a custom |
What's the status on this issue? This is blocking us from using CSP |
My friends behold, it's the time of the year, My fellow SvelteKit users rejoice, bottom line: We're currently in fixing mode (ok actually fixing and preparing our new major) so I finally have time to look at this. ETA Soon. let's just hope the fix is better than this poem ;) |
Hi everyone, at long last we finally just merged in two options to resolve this problem. See #9969 for instructions. I'll update our docs soon, too. This fix will be released with 7.91.0 in the next hours. Thanks for your patience! |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/sveltekit
SDK Version
7.66.0
Framework Version
7.66.0
Link to Sentry event
No response
SDK Setup
Steps to Reproduce
Open the browser console and load a page where Sentry is loaded
Expected Result
No CSP errors
Actual Result
On page load, I get the following CSP error in the console:
I get this error in version
7.65.0
but not7.64.0
.I believe this was introduced in this PR, where the following script tag is injected into the head tag:
As a temporary workaround, I've added
sha256-+X7Z1KW2Vcl9pendYbp0FYL6F0HZek43aBP/14cwq+U=
to myscript-src
CSP, but ideally I wouldn't have to update this hash each time the injected script is changed.The text was updated successfully, but these errors were encountered: