rainbowkit icon indicating copy to clipboard operation
rainbowkit copied to clipboard

[security] Stop initializing WalletConnect when it's not used in the dapp

Open v1rtl opened this issue 1 year ago • 4 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

RainbowKit Version

2.1.2

wagmi Version

2.9.8

Current Behavior

Even if you're not using WalletConnect anywhere in your app, it still gets initialized. When it's initialized, it makes a few requests to the relay, which is used in WalletConnect analytics service. Basically it's spyware imposed on anyone who uses RainbowKit in their app, even if they don't opt in to it. I think this is a huge security hole, because WalletConnect gathers users' data without consent without even using their wallet lib.

image

WalletConnect shouldn't initialize before connecting to WC. This is specific to RainbowKit, as wagmi doesn't do that.

Expected Behavior

WalletConnect not being enabled if not imported. Only enable it if you import it explicitly.

Steps To Reproduce

  1. Open https://stackblitz.com/edit/vitejs-vite-rbsdea?file=src%2Fconfig.ts
  2. Open Network tab in DevTools
  3. Observe connection to the relay without doing anything, not even clicking the connect wallet button

Link to Minimal Reproducible Example (CodeSandbox, StackBlitz, etc.)

https://stackblitz.com/edit/vitejs-vite-rbsdea?file=src%2Fconfig.ts

Anything else?

No response

v1rtl avatar Jun 05 '24 14:06 v1rtl

@talentlessguy I'm also able to reproduce this with Wagmi (npm create wagmi@latest).

image

I don't think this is a RainbowKit specific issue. If this is a security concern, then it's better to raise a PR for Wagmi here.

0xmkh avatar Jun 05 '24 18:06 0xmkh

@talentlessguy I'm also able to reproduce this with Wagmi (npm create wagmi@latest).

image

I don't think this is a RainbowKit specific issue. If this is a security concern, then it's better to raise a PR for Wagmi here.

From what I understand this happens only with a Rainbow connector in wagmi. Seems like that's where the issue is happening.

v1rtl avatar Jun 05 '24 19:06 v1rtl

@talentlessguy I'll look at it again and report back 👍

0xmkh avatar Jun 05 '24 20:06 0xmkh

This happens exclusively with rainbow connector because it initializes WC

v1rtl avatar Jun 07 '24 11:06 v1rtl

Is there any solution for this? I don't want walletconnect and definitely don't want it opening up a websocket connection

floticerus avatar Jul 02 '24 02:07 floticerus

@floticerus I think if you have an injected connector it won't initialize WC at all

v1rtl avatar Jul 02 '24 03:07 v1rtl

@floticerus There isn't a way to do this unless you don't use wallets that use WC. Like @talentlessguy said you can use injected connector (injectedWallet) for now, but we're going to work on lazy loading the connectors soon.

0xmkh avatar Jul 02 '24 10:07 0xmkh

@talentlessguy WalletConnect and Wagmi team just got back to me. We could try and lazy load the connectors, but there is a problem with that. During page refresh we won't know if the user should be connected to the dApp or not and Wagmi also manages the states for that. It's best to fix these connector issues upstream instead of relying on RainbowKit, but doesn't seem that the EthereumProvider (@walletconnect/ethereum-provider) will disable tracking in the near future.

Also WalletConnect team has mentioned that you could turn off Verify API, but that's more risky. Essentially it'll be an empty iframe that doesn't do anything.

0xmkh avatar Jul 30 '24 18:07 0xmkh

@magiziz what do you mean by "fixing upsteam"? do you mean in WalletConnect? Can this be patched in wagmi somehow? But wagmi's WC connector doesn't initialize on page load, only when interacting with it.

v1rtl avatar Jul 30 '24 18:07 v1rtl

@talentlessguy Yeah upstream in WalletConnect. I'm not sure if this can be patched in Wagmi since they wouldn't know if the user is already connected whenever the page is refreshed. They also use a setup function for WalletConnect which gets the provider on mount https://github.com/wevm/wagmi/blob/main/packages/connectors/src/walletConnect.ts#L113-L124

0xmkh avatar Jul 30 '24 19:07 0xmkh

Going to close this issue for now since it's coming from walletConnect connector.

0xmkh avatar Aug 05 '24 16:08 0xmkh

@magiziz landed here because when I add rainbowWallet to the list of supported wallets for my dapp, I see RK (or some dependency?) making requests to walletconnect to verify the project ID.

Is it possible to avoid using walletconnect while still supporting Rainbow somehow?

0xGh avatar Mar 20 '25 09:03 0xGh