MetaMask / metamask-sdk

The simplest yet most secure way to connect your blockchain-based applications to millions of MetaMask Wallet users.
https://metamask.io/sdk/
Other
188 stars 115 forks source link

feat: fake metamask wallet detection #1074

Closed EdouardBougon closed 1 month ago

EdouardBougon commented 1 month ago

I’ve discovered an issue with the SDK (pure JavaScript and wagmi). The SDK tests the boolean window.ethereum.isMetaMask to detect if the extension is installed. However, some other extensions use the same boolean to imitate MetaMask (e.g., Uniswap, Zerion, Rabby, etc.), and it works…

Screenshot 2024-10-14 at 11 09 05

So, if the MetaMask extension is not installed, but one of those wallets is, the SDK will open the “fake” extension instead of the connection modal. Wagmi has a similar detection on their side, but they don’t take into account the “Uniswap Wallet.”

I also created a PR on Wagmi to add Uniswap to their detection test.

Here’s a demo video.

https://github.com/user-attachments/assets/be461d80-436b-475c-9fd5-9c692b9010bd

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 92.30769% with 1 line in your changes missing coverage. Please review.

Project coverage is 78.05%. Comparing base (9866480) to head (0714d59). Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
packages/sdk/src/utils/get-browser-extension.ts 92.30% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1074 +/- ## ========================================== + Coverage 78.02% 78.05% +0.03% ========================================== Files 179 179 Lines 4164 4175 +11 Branches 1023 1026 +3 ========================================== + Hits 3249 3259 +10 - Misses 915 916 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud