Skip to content
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

Content Security Policy Error when loading scripts hosted on IPFS #1008

Open
karmanyaahm opened this issue Jun 12, 2021 · 1 comment
Open
Assignees
Labels
area/chromium Issues related to Chromium-based browsers area/firefox Issues related to Mozilla Firefox effort/hours Estimated to take one or several hours kind/bug A bug in existing code (including security flaws) need/analysis Needs further analysis before proceeding P1 High: Likely tackled by core team if no one steps up

Comments

@karmanyaahm
Copy link

karmanyaahm commented Jun 12, 2021

Describe the bug
When a website includes a script that's hosted on an DNSLink domain, and has a restrictive Content Security Policy, the scripts fail to load, and the website doesn't function properly.

To Reproduce
Steps to reproduce the behavior:

  1. Make sure IPFS Companion is enabled
  2. Go to https://cactus.chat/demo/
  3. See that the comments section, hosted at https://latest.cactus.chat/cactus.js doesn't load, because latest.cactus.chat is served over DNSLink. (CSP errors in the console)
  4. Disable IPFS Companion.
  5. Everything works well.

Expected behavior
Go to the website and all the assets load. There is no CSP error in the console.

Desktop (please complete the following information):

  • OS: Arch Linux
  • Browser: Firefox
  • Version: 90.0b5
    Chromium 91.0.4472.77 also has the same behavior.

Possible Solution
Modify CSP to gateway. I used the Mozilla Laboratory extension to modify the CSP on the website. My IPFS Gateway is at http://127.0.0.1:8080, so I added http://127.0.0.1:8080/ipns/*.cactus.chat to the script and style CSP directives (in a real solution font-src etc. should also be added). only /ipns/*.cactus.chat here because that's what the script-src and style-src already specified. IPFS Companion should do this automatically.

Another solution would be to stop intercepting URLs when scripts and stylesheets are being loaded over IPFS.

Note - I'm not associated with cactus.chat I just noticed this problem with companion, so I'm making this bug report.
Note 2 - related issues - #701 seems like the solution 2 that I said, but it seems to be closed and that behavior still doesn't happen? #624 's solution is to disable window.ipfs, but the toggle for that is locked and there seems to have been no progress on that?

@karmanyaahm karmanyaahm added the need/triage Needs initial labeling and prioritization label Jun 12, 2021
@ipfs ipfs deleted a comment from welcome bot Jun 17, 2021
@lidel
Copy link
Member

lidel commented Jun 17, 2021

Thank you for reporting this @karmanyaahm

Quick thoughts:

Update: this is limited to Firefox.

@lidel lidel added area/chromium Issues related to Chromium-based browsers area/firefox Issues related to Mozilla Firefox effort/hours Estimated to take one or several hours kind/bug A bug in existing code (including security flaws) need/analysis Needs further analysis before proceeding P1 High: Likely tackled by core team if no one steps up labels Jun 17, 2021
@lidel lidel self-assigned this Jun 17, 2021
@lidel lidel removed the need/triage Needs initial labeling and prioritization label Jun 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/chromium Issues related to Chromium-based browsers area/firefox Issues related to Mozilla Firefox effort/hours Estimated to take one or several hours kind/bug A bug in existing code (including security flaws) need/analysis Needs further analysis before proceeding P1 High: Likely tackled by core team if no one steps up
Projects
No open projects
Status: Needs Grooming
Development

No branches or pull requests

2 participants