Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

firefox csp issue with installGlobalHook(window)

Tags:

Curious (and hard to diagnose) issue. I've added a CSP to my site, and it is working just fine, with 1 error which seems to only appear on Firefox (guessing it is a Mozilla CSP implementation anomaly). I'm not really sure, however, how to even really dig deeper into diagnosing this at this point. It does not appear to be hindering any functionality - everything seems to work, but I see the error popping on Firefox (and its reporting is quite spammy, which I could deal with in other ways, but would rather root cause and handle).

Here's the error (which appears on virtually every single page of the site):

Content Security Policy: The page’s settings blocked the loading of a resource 
at self (“script-src https://code.jquery.com/”). Source: ;(function 
installGlobalHook(window) { ....

I typically load jQuery via CDN, and have no problems with it loading and running, though I did try also downloading the jQuery and loading it internally (which also worked fine).

The full CSP is:

Content-Security-Policy: 
default-src 'self'; 
base-uri 'self';
script-src 'self' https://code.jquery.com/;
form-action 'self'; 
font-src 'self' https://fonts.googleapis.com/ https://fonts.gstatic.com/;
style-src 'self' https://fonts.googleapis.com/ 
    https://code.jquery.com/
    'sha256N90MKmRow2DpYEVeqcc3uc8pOUsS4Rg4sNmkau1k0xQ=' 
    'sha256-i1EfB2+xYUUG32uDRMNI/DN/F9YIrGWOYdHENz9GKME='
    'sha256-75seZ0liXI7HbegtdV/WH+/9QQJ0CrDacBOViVFXckc='
    'sha256-2KAnfZnKiF2um1+UfXP14UfR93HoXmam2Y1ipeMWRUI='; 
frame-ancestors 'self';
report-uri /csp/csp-report

Just re-verified, only seeing the error on Firefox. I've reviewed other related issues, but nothing seems to address this issue directly (ex: CSP Violation Detected in Firefox OS validator).

Also, I'm noting the error appears in the console immediately after the page GET, but before all of the resource GETs (for scripts, css files, etc.), so I'm wondering (even more) if it could be a FF bug with CSP...?

Any thoughts or suggestions about how to proceed from this point would be very helpful - I've kind of run myself out of leads. Thanks!

** UPDATE ** - Ug. It is definitely React DevTools Firefox extension. Disable the extension, CSP violation goes away. Also, because this is a component of the extension itself, no way to use React DevTools with FireFox + CSP (with any level of security actually turned on). Blagh.

like image 911
Chris_Alexander Avatar asked Feb 12 '18 22:02

Chris_Alexander


1 Answers

Solved this in a relatively sub-optimal way (IMHO).

Firefox apparently isn't a big fan of CSP's "default-src" attribute being set to 'self', as I had it in my config. Changing the "default-src" directive to my actual host source ('localhost' for dev and the actual domain 'https://*.foobar.com' for prod), the CSP violation for installGlobalHook(window) ceased.

FYI in case anyone else runs across this error...

like image 190
Chris_Alexander Avatar answered Sep 22 '22 12:09

Chris_Alexander