roleoroleo / yi-hack-MStar

Custom firmware for Yi 1080p camera based on MStar platform
GNU General Public License v3.0
835 stars 110 forks source link

x-content-type-options: nosniff header with cloudflare tunnels #478

Closed Klay4 closed 2 months ago

Klay4 commented 1 year ago

Hi, I encountered this problem by putting the camera under a zero trust cloudflare tunnel. When I access the web page everything was black except the sidebar.

Screenshot 2022-12-29 at 19 19 41

Identification of the problem

After some digging, I found that theoretically tunnel/cloudflared/somewhere in the CF Proxy is adding the x-content-type-options: nosniff header, and those resources do exist but the origin server isn't returning the proper content types.

Content Type / Media Type (MIME Type) is the identifier for the file format/contents. The CF Proxy / somewhere is adding the nosniff header, a security feature, to stop the browser from trying to guess the content type of the file (which could be a security risk with user uploaded content and probably other reasons I don't remember/know). The root problem though is your origin server (the camera running yi-hack) isn't properly returning content types for the files.

Screenshot 2022-12-29 at 19 24 37 Screenshot 2022-12-29 at 19 31 31

WorkAround Fix

Easiest workaround fix for this is probably just to add a transform rule setting the content-type for files ending in .js

In your zone/website, Rules => Transform Rules => Create Transform Rule => Modify Response Header, then something like this:

image

Thanks to TylerO#3235 for helping me identify and solve the problem.

roleoroleo commented 1 year ago

Do you know a solution for this? Could I change something server side?

EDIT

Probably the solution is to add a mime mapping in the configuration file. If you want to try, stop the daemon, add the line .js:application/javascript to /tmp/httpd.conf (now is an empty file) and restart the daemon.

github-actions[bot] commented 3 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.