-
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
Figure out HTTP RPC API access with Manifest V3 #1036
Comments
It looks like adding the extension UUID for chrome is straight forward enough:
🔗 https://stackoverflow.com/questions/21497781/how-to-change-chrome-packaged-app-id-or-why-do-we-need-key-field-in-the-manifest Firefox is a different story 😭
🔗 https://discourse.mozilla.org/t/constant-or-well-known-mox-extension-uuid-for-webextension/9701/28246 |
Firefox not having a consistent UUID isn't actually a blocker here, as we can still use blocking webRequest in firefox to set the access control header for access to ipfs API. We will continue to track it so we can one day have one code path for HTTP API access. |
AdGuard seems to have released their implementation of MV3 based AdBlocking:
But since they are solving a different problem than this, I am wondering if it would be possible to implement an API-authentication PSK/token in go-ipfs, we can then add CORS headers whitelisting any referrer/origin that provides a valid token in the request dynamically, this way we unblock both chrome and firefox and it simplifies extensions origin.. |
@whizzzkid the main problem is the need for manual config change in go-ipfs. Companion users should not be asked to manually change config of IPFS daemon, that is UX self-sabotage. Whatever we come up with, needs to create an end-to-end user onboarding flow that feels seamless. |
@lidel I think we need to work on:
|
Indeed, some notes below @whizzzkid Current landscapeIn case this is useful, the way things look like in context of our MV3 future that needs to happen in the beginning of 2023:
So we are good.. for now. What could go wrong in the future?
In both cases, Companion users are cut-off and (assuming RPC access is required) have to set CORS headers manually, which is a terrible, terrible UX, and we should avoid it at all cost. How can we prepare for the worst?Have a plan in place. Ideally something that leverages our Gateway work, which aims to decrease need for So far I see two approaches we could explore (fine to do so in parallel, just limit the time spent on RPC hacks):
Ideas welcomeOpen for ideas / suggestions, especially radical ones. |
Update: @ikreymer is experimenting with Origin header override via
he caveat is to ensure the override is applied only for requests done by extension (Override Origin only when it is matching the Origin of the extension itself), so we still block third-party websites from having Admin access to RPC API. I think we can use initiatorDomains for this, and put Companion's Origin there. This way it works the same way it did in MV2. |
@lidel I am not sure I understand the working of this. Is there more info available on this? Why would a third-party website have access if the rpc endpoint does not respond to requests not generating from the extension-url. Also, if rpc port allows access from an extension which modifies the request to have origin header set, then what's stopping a malicious extension doing the same? My concern is an extension can be created such that which sets origin header as our extension url and then exploit rpc port for any malicious purpose. Hence I was always in favour of:
Also this won't work on firefox. |
I think @lidel is saying that the declarativeNetRequest actually applies globally (I was surprised by this too!) and not just for requests originating from the extension. In practice, this doesn't actually work in this case, as access to localhost is further restricted from any third-party website (fetch to localhost fails currently). But, the risk is from any third-party extension, not from any website, as you point out. This is not quite as bad, but still kind of bad, because any Chromium extension out there could thus access the local node by spoofing the Origin header, in both MV2 and MV3. |
Thanks @ikreymer 🙏🏽, that clears it up. I was wondering if I missed something around this way of implementing this. We'll need to work on a pairing mechanism between extension and node (maybe multiple nodes.) And this should be automatic in the way where we can trigger this by default in implementation like brave. |
Background
IPFS Companion talks to local go-ipfs node over HTTP RPC API.
The API comes with CORS protections in the browser context (ipfs/ipfs-docs#959) and to avoid the need for CORS safelisting, Companion adjusts the Origin header.
Problem
Seems that we cannot modify headers with
onBeforeSendHeaders
anymore, because the blocking API is gone.This means Companion is not able to talk to the RPC API, which is needed for file uploads, content-path resolution, DNSLink resolution and so on.
Research solutions
The text was updated successfully, but these errors were encountered: