ipfs / ipfs-companion

Browser extension that simplifies access to IPFS resources on the web
https://docs.ipfs.tech/install/ipfs-companion/
Creative Commons Zero v1.0 Universal
2.05k stars 325 forks source link

Disable redirect on X-Ipfs-Path without DNSLink on the root document #1052

Open lidel opened 2 years ago

lidel commented 2 years ago

https://fleek.co is an example of interesting misconfiguration (at least today 2022-02-17):

$ ipfs resolve -r /ipns/fleek.co
Error: could not resolve name: "fleek.co" is missing a DNSLink record (https://docs.ipfs.io/concepts/dnslink/)

$ curl -Is https://fleek.co/ | grep x-ipfs-path 
x-ipfs-path: /ipfs/bafybeidwgtlx54aifd5ynwwvlozr2fuw5xrmbu3ivnwmnoxi4ewdnxty5y/

Problem

Companion will use x-ipfs-path as fallback:

https://github.com/ipfs/ipfs-companion/blob/eacee6ca786f669411c54e7cdde4c12876bf03cf/add-on/src/lib/ipfs-request.js#L310-L312

This means opening https://fleek.co with ipfs-companion will redirect user to http://bafybeidwgtlx54aifd5ynwwvlozr2fuw5xrmbu3ivnwmnoxi4ewdnxty5y.ipfs.localhost:8080

Solution

lidel commented 2 years ago

I may look into this as an excuse to fix MV2 build. cc @meandavejustice – just FYI in case this edge case comes up in MV3 work

lidel commented 1 year ago

Just flagging this is still broken, https://www.4everland.org/ gets redirected to http://bafybeia5jy6dd66beizcfk4clmobokuph7oq5jl5aobesjzyfblcjdrtma.ipfs.localhost:8080/ and user is stuck on snapshot URL, and not live URL that can get updates.

$ curl https://www.4everland.org -is | grep -i x-ipfs-path                                                                                                                                                     
x-ipfs-path: /ipfs/bafybeia5jy6dd66beizcfk4clmobokuph7oq5jl5aobesjzyfblcjdrtma/

$ dig +short TXT _dnslink.www.4everland.org
[no result]

@whizzzkid we probably should address this right after MV3 lands. It degrades UX on websites that use IPFS for hosting or provide IPFS services (but have DNSLink misconfiguration).

I would go as far as Disabling x-ipfs-path for all users by default, and also doing one-time migration, and making the below feature opt-in instead of opt-out:

2023-09-15_22-24

As it is today, makes more harm than good, unfortunately.