-
Notifications
You must be signed in to change notification settings - Fork 325
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
Redirect of CID-in-subdomain and DNSLink websites #667
Comments
I think it makes sense to reason about CID-in-subdomain/DNSLinked websites and path-based ( If asset is referred via IPFS path ( |
( E ) We’ve got all of ( F ) Relay on containerized first-party isolation. Firefox only (but I do think Brave is working on it for Chromium). ( G ) Allow redirects without prompting for confirmation for some content types like |
Regarding ( C ): The issues you mention are all addressable: Use a placeholder domain for the origin with a wildcard certificate. The extension redirects to |
Regarding ( B ): How would that work for sub-resources loaded on a HTTPS page? The pageAction doesn’t display for these today (#662) and it would be really confusing to prompt people to redirect a sub-resource to the local gateway. This would completely break DTube among other CDN-like use cases. |
OK, I think I just thought of something that should work for every browser: ( H ) Use what I said above for ( C ) except don’t use |
@da2x good feedback, thank you!
I am afraid it won't work. Only
Use of this requires opening a new tab, which significantly limits the usefulness of this API for background requests. Still, a good idea for isolating
Should not be a problem. As noted in #662 (comment) we can apply rules to all sub-resources loaded in a tab. In this case, Sub-resources would not be redirected on CID-in-subdomain and DNSLink websites (unless we allow for (G) below).
Indeed, we can detect
Somehow related research happens in comments of ipfs/in-web-browsers#137, but service worker route is not robust enough yet. There are pending issues related to keeping worker alive and cross-vendor incompatibilities like bug-1376309. When issues are solved it may be a solution (with some ugly limitations), but before it is ready, it looks like the best we can do is (B) and (F) on Firefox. |
( I ) Redirect by default but enforce stricter security policies. Most of the websites that are out there today are static blogs and the like with no need for a strict origin policy. The local gateway can enforce better security in modern browsers by purging data on every load by adding the |
( J ) RFC 7838 may offer an alternative solution for DNS-to-IPFS that is currently handled by DNSLink. A HTTP servers could announce IPFS support by including either of the following headers:
The browser could then switch to loading content from the local gateway as the original origin. This depends on browser support to allow extensions to handle Alternate Service announcement keywords like ipfs and ipns, however. |
|
Initial version at https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy read:
Which meant it would be treated the same as Just as you noted, browser vendors follow more conservative approach from https://www.w3.org/TR/secure-contexts/#is-origin-trustworthy:
https://www.w3.org/TR/secure-contexts/#localhost:
Safari does not even allow Some takeaways:
|
I'm not sure what the coverage is in other OSes, but |
@lgierth correct, we identified cross-platform issues in ipfs/in-web-browsers#109 and decided to try something else. The |
*.localhost behaves according to the RFC for it’s special use domain. (Meaning it doesn’t do squat by default.) However, this isn’t a problem as the extension or a browser proxy configuration can be setup to handle *.,localhost which I assumed was the idea to begin with. |
@lidel any progress on using ipns://example.com or ipfs://b32cidv1 directly in browsers? The Beaker Browser’s use of dat://hash have saved them a lot of trouble in this area. |
@da2x we created a prototype using experimental WebExtension API libdweb/#protocol-api to deliver persistent The HTTP Proxy workaround discussed here aims to improve things much sooner, as we can deliver it without making any changes to browsers. |
Ok, I believe with the latest Beta (v2.7.5.762) we have almost all the pieces of the UX for ( B ):
What is missing: in case of DNSLink websites, we want to tweak this behaviour and disable redirect of DNSLink websites by default. People will still be able to opt-in via toggle introduced in (#687) and a global one in Preferences if they choose to do so, but the default should not change the Origin. Tracked in: #701 |
I'm not arguing against the decision and preserving the origin boundaries is super important. However, this change also kills IPFS' browser intgration for any purpose other than direct file swapping. Without DNSLink there is no way to publish a website and simultaniously let IPFS Companion users automatically access it on IPFS without manual intervention and a willingness of users to sacrifice security. Is there a detailed roadmap or plan for future browser integration? or a plan to produce a prototype browser like the Beaker Browser? |
@da2x the plan for mainstream browsers is to disable redirect of DNSLink websites until support for localhost HTTP Proxy and
Now that you mentioned it, I see how users may see this as a regression and start asking myself: is the cure is worse than the disease? Namely:
|
I’ve used static.example.com and video.example.com to serve media assets on www.example.com over IPFS or fallback to HTTP for users without IPFS Companion. DNSLink with automated redirection to localhost in a secure context is the glue that holds that together. How would you load this over IPFS?
How about an opt-in signal by extending the existing DNS prefetch mechanism?
IPFS Companion could resolve that domain as an DNSLink IPNS name and load it via the local gateway. Browsers will just resolve the normal DNS name for this origin and ignore the extra attribute. It significantly reduces unnecessary DNSLink lookup requests too.
I though IPNS:// couldn’t work? The origin has to be lower-case, right? —and I’ve not even seen a proposal to transition to lowercased base32 encode IPNS names. |
@lidel what about proposal J above? It’s what the Tor browser uses to upgrade a .com to a .onion (cutting the need to route traffic through an exit node after the first visit to the web server. It’s a mechanism where the origin is preserved ( |
This should continue to work. I clarified in #701 that the idea is to disable redirect only for the root document (
Yes, Origin need to be case-insensitive, and existing PeerIDs in Base58 are not. We had some discussions this week to take ipfs/kubo#5287 over the finish line by wrapping PeerID in CID with a special codec. That way it could be represented in Base32 like everything else.
WebExtension is unable to register handler for |
As of 2019-10 |
We decided (#701 (comment)) to experiment with temporary measures until we have native support for subdomain gateway in go-ipfs (ipfs/kubo#6498) that works with
Update: we restored redirect by default in #831, but there is now a toggle on Preferences screen to control DNSLink redirect behavior. |
PSA: 📢
|
I believe this is closed by v2.11.0.904, but let's keep this issue open until Stable v2.11. |
v2.11.0 hit the Stable channel and is ready for go-ipfs 0.5, which will be released in a few weeks. For now, one can give it a try with go-ipfs 0.5.0-rc1. Download it from here or use Docker. Testing ephemeral container: $ docker run --rm -it --net=host ipfs/go-ipfs:v0.5.0-rc1 Keeping this open until go-ipfs 0.5.0 ships with ipfs-desktop (ipfs/ipfs-desktop#1392) |
|
Problem
There is an open problem of handling CID in Subdomain. CID-in-subdomain gives a website Origin-based isolation if loaded from public gateway, but we continue to have a single Origin for all websites if it is redirected and loaded from local gateway (
/ipfs/<cid>
).Current status:
IPFS Companion extension DOES NOT redirect from
cidv1b32.ipfs.foo.tld
tohttp://127.0.0.1:8080/ipfs/cidv1b32
because that would decrease security guarantees (example)However, we DO redirect DNSLinked websites eg. https://docs.ipfs.io to http://127.0.0.1:8080/ipns/docs.ipfs.io/ because at the time nobody relied on Origin-based guarantees on IPFS websites.
I feel we should come up with a solution that is addressing both use cases, as having different behavior is confusing.
Short Term Fix
In the short term we have two options: either redirect or not.
( A ) 💢 Redirect to
http://127.0.0.1:8080/ip(f|n)s/..
even IF it would decrease Origin-based guarantees( B ) 👼 (@lidel's plan) DO NOT redirect to
http://127.0.0.1:8080/ip(f|n)s/..
by default, but give opt-in option to open at local gatewayOpen from Local Gateway
– displays a warning dialog informing about Origin limitation of local gateway and if user accepts the risk opens the website fromhttp://127.0.0.1:8080/ip(f|n)s/..
(easy to reason about, so far my favourite, UX can be improved by supporting (F) in Firefox 🍏 )Enable redirect to Local Gateway
- a permanent opt-in to redirect this specific website (may be hard to get the UX right, we may add this as a part of Redirect opt-out per website #633)*.ipfs.localhost
and*.ipns.localhost
we could restore the redirect by default (because it no longer breaks the origin) – see details in Redirect of CID-in-subdomain and DNSLink websites #667 (comment)I lean on the safe side (B). Below are other options.
Other Ideas
( C ) 💢 "A mess": redirect to a custom hostname for localhost HTTP gateway
*.ipfs.foo.tld
→127.0.0.1
(Hostnames for localhost HTTP gateway in-web-browsers#109)( D ) 👼 "Ideal": redirect to native protocol handler
( H ) 🤔 Service Worker pulls data from 127.0.0.1 and serves it from the
<CID>.ipfs.local.dweb.link
Origin. It would be origin-white-washing everything on the fly. Should work the same as js.ipfs.io does today except the worker talks to loopback only.( F ) (Firefox only)
Open from Local Gateway
in (B) could open in a new tab with isolation provided bybrowser.contextualIdentities
API (see #194)( G ) Like (B) but we could allow redirects for some content types like images or videos. Rationale: subresources are easy to detect via
ResourceType
– we can detectimage
andvideo
that way. (Other ways to tell the content-type: look at extension [naive] or fetch a few bytes and do mime-sniff on them [expensive])??? (ideas are welcome)
The text was updated successfully, but these errors were encountered: