browser console errors after v1.6.0 upgrade
-
@julian said in browser console errors after v1.6.0 upgrade:
Just for debugging, try to disable all of your plugins via the command line... Perhaps there's a third party plugin not playing nicely
Is there a bulk way to do it or is it all manually?
-
@julian said in browser console errors after v1.6.0 upgrade:
The main thing is that not happening on any of our environments... Which usually suggests some sort of customisation or configuration could be to blame.
Nginx config?
I commented out the security headers and reloaded nginx, but that didn't seem to change anything.
# Source of these security headers: # https://gist.github.com/plentz/6737338#file-nginx-conf-L6 # https://observatory.mozilla.org/analyze.html?host=gamingexodus.com # read more here http://tautt.com/best-nginx-configuration-for-security/ # don't send the nginx version number in error pages and Server header server_tokens off; # Redirect all port 80 requests to https server { listen 80; server_name gamingexodus.com www.gamingexodus.com; return 301 https://$host$request_uri; } # Real meat of the server block server { listen 443 ssl http2; # when serving user-supplied content, include a X-Content-Type-Options: nosniff header along with the Content-Type: header, # to disable content-type sniffing on some browsers. add_header X-Content-Type-Options nosniff; # This header enables the Cross-site scripting (XSS) filter built into most recent web browsers. # It's usually enabled by default anyway, so the role of this header is to re-enable the filter for # this particular website if it was disabled by the user. add_header X-XSS-Protection "1; mode=block"; # with Content Security Policy (CSP) enabled(and a browser that supports it(http://caniuse.com/#feat=contentsecuritypolicy), # you can tell the browser that it can only download content from the domains you explicitly allow # http://www.html5rocks.com/en/tutorials/security/content-security-policy/ # https://www.owasp.org/index.php/Content_Security_Policy # Use "Content-Security-Policy-Report-Only" to test changes add_header Content-Security-Policy "default-src 'self'; connect-src 'self' wss: https://api.github.com https://packages.nodebb.org https://bootswatch.com; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://iframely.gamingexodus.com https://storage.googleapis.com https://checkout.stripe.com https://s.imgur.com https://www.google.com https://www.gstatic.com; img-src 'self' data: https:; style-src 'self' 'unsafe-inline' https://maxcdn.bootstrapcdn.com https://fonts.googleapis.com; font-src 'self' https://maxcdn.bootstrapcdn.com https://fonts.gstatic.com; child-src https:; object-src 'none'"; # https://mozilla.github.io/server-side-tls/ssl-config-generator/ # certs sent to the client in SERVER HELLO are concatenated in ssl_certificate ssl_certificate /path/fullchain.pem; ssl_certificate_key /path/privkey.pem; ssl_session_timeout 1d; ssl_session_cache shared:SSL:50m; ssl_session_tickets off; # Diffie-Hellman parameter for DHE ciphersuites, recommended 2048 bits ssl_dhparam /etc/ssl/certs/dhparam.pem; # intermediate configuration. tweak to your needs. ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS'; ssl_prefer_server_ciphers on; # HSTS (ngx_http_headers_module is required) add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload;" always; # OCSP Stapling --- # fetch OCSP records from URL in ssl_certificate and cache them ssl_stapling on; ssl_stapling_verify on; ## verify chain of trust of OCSP response using Root CA and Intermediate certs ssl_trusted_certificate /path/fullchain.pem; # Hopefully resolve issues with image uploads client_max_body_size 20M; # Make site accessible from http://localhost/ server_name gamingexodus.com www.gamingexodus.com; # Server block from NodeBB config page proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_redirect off; # Socket.IO Support proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; location @nodebb { proxy_pass http://127.0.0.1:4567; } location ~ ^/assets/(.*) { root /var/www/nodebb/forums/; try_files /build/public/$1 /public/$1 @nodebb; } location /plugins/ { root /var/www/nodebb/forums/build/public/; try_files $uri @nodebb; } location / { proxy_pass http://127.0.0.1:4567; } location /.well-known { root /var/www/letsencrypt/; allow all; } }
-
@julian said in browser console errors after v1.6.0 upgrade:
We'll have to wait for @PitaJ to speak to that
For some reason disabling
add_header X-Content-Type-Options nosniff;
works now. BUT, why did this change with v1.6.0? I'd greatly prefer to keep that option enabled for security purposes. -
Ahhhhh, so disabling it in nginx is great and all, but Cloudflare had it on too, so it took a little bit for the changes to propagate once I turned off the Cloudflare proxy.
Anywho, this seems like a defect to me. There was some change in the MIME settings.
-
A better solution for nginx is this, which sets the content type for
.jst
toapplication/javascript
types { application/javascript jst; }
You can either put this in the
/assets...
location block if you have one, or just anywhere in the server block.I'm working on setting this content type in NodeBB as well, I'm tracking it with this issue: NodeBB/NodeBB#5934
-
@pitaj said in browser console errors after v1.6.0 upgrade:
A better solution for nginx is this, which sets the content type for
.jst
toapplication/javascript
types { application/javascript jst; }
You can either put this in the
/assets...
location block if you have one, or just anywhere in the server block.I'm working on setting this content type in NodeBB as well, I'm tracking it with this issue: NodeBB/NodeBB#5934
Thanks @PitaJ
Modified the block below to add your suggestion:
location ~ ^/assets/(.*) { root /var/www/nodebb/forums/; try_files /build/public/$1 /public/$1 @nodebb; types { application/javascript jst; } }
It caused a lot of strange display errors. I'll just leave the strict enforcement off for now and wait for the fix to be in NodeBB... It looks like everything is coming down as
application/octet-stream
?Console errors after modifying the assets block:
Refused to execute script from 'https://gamingexodus.com/assets/nodebb.min.js?v=1g9ivu2ogsa' because its MIME type ('application/octet-stream') is not executable, and strict MIME type checking is enabled. (index):1 Refused to execute script from 'https://gamingexodus.com/assets/vendor/jquery/timeago/locales/jquery.timeago.en.js' because its MIME type ('application/octet-stream') is not executable, and strict MIME type checking is enabled. (index):23 Resource interpreted as Stylesheet but transferred with MIME type application/octet-stream: "https://gamingexodus.com/assets/stylesheet.css?v=1g9ivu2ogsa". (index):46 Resource interpreted as Stylesheet but transferred with MIME type application/octet-stream: "https://gamingexodus.com/plugins/nodebb-plugin-markdown/styles/railscasts.css". (index):1087 Uncaught ReferenceError: $ is not defined at (index):1087 (anonymous) @ (index):1087 (index):1105 Uncaught ReferenceError: define is not defined at (index):1105 (anonymous) @ (index):1105 (index):1134 Uncaught ReferenceError: require is not defined at (index):1134 (anonymous) @ (index):1134```
-
The
X-Content-Type-Options
response HTTP header is a marker used by the server to indicate that the MIME types advertised in theContent-Type
headers should not be changed and be followed. This allows to opt-out of MIME type sniffing, or, in other words, it is a way to say that the webmasters knew what they were doing.... (emphasis mine)
As @pitaj issued it, we'll track its fix, but as
X-Content-Type-Options
is not likely to be used extensively, there's no need to prioritise this issue for backport intov1.6.x
. However when resolved, you can easily cherry-pick the fix into your existing installation. -
@teh_g I do admit I didn't check if it would work, you probably actually need
types { application/javascript jst js; text/css css; }
-
@julian said in browser console errors after v1.6.0 upgrade:
The
X-Content-Type-Options
response HTTP header is a marker used by the server to indicate that the MIME types advertised in theContent-Type
headers should not be changed and be followed. This allows to opt-out of MIME type sniffing, or, in other words, it is a way to say that the webmasters knew what they were doing.... (emphasis mine)
As @pitaj issued it, we'll track its fix, but as
X-Content-Type-Options
is not likely to be used extensively, there's no need to prioritise this issue for backport intov1.6.x
. However when resolved, you can easily cherry-pick the fix into your existing installation.Totally understand
I'm super paranoid and like following the theoretical best practices, but as you can see by the content security policy in my nginx config, it isn't always possible. Stupid real world not lining up with my perfect world expectations!
@pitaj said in browser console errors after v1.6.0 upgrade:
@teh_g I do admit I didn't check if it would work, you probably actually need
types { application/javascript jst js; text/css css; }
This mostly works now. The admin page still had some issues, but at least the user section is good! I will keep strict checking disabled for the time being
-
@teh_g what are the admin issues?
-
@pitaj said in browser console errors after v1.6.0 upgrade:
@teh_g what are the admin issues?
I didn't capture the browser console log, but it was more of the MIME type errors. If you don't have a test server where you can toggle on nosniff again, I can capture the errors again later. I don't want to break my forums anymore
Having the nosniff option disabled fixes it, but I'd definitely love to keep that enabled. It protects against a few malicious attacks that could potentially occur. Though they are unlikely.
-
Issue confirmed - good catch.
As far as I can see nginx doesn't touch the headers (if not explicitly told to do so) as it's just proxying stuff...
Update:
Got around the issue using:
location ~ \.jst { add_header Content-Type application/javascript; proxy_pass http://board; }
Not nice, but for now it's a solution I am able to live with on that vhost even with
nginx.conf having setadd_header X-Content-Type-Options nosniff;
-
only chrome creating issue other browser working fine please guide?