The one-sentence version
Extension wallets like MetaMask store encrypted private keys in the browser, and web pages send requests to them via an injected JavaScript interface (EIP-1193). It strikes a middle ground between usability and security: it is more secure than web wallets (the private key is not handed over to the website) but weaker than hardware wallets (the private key and malware reside on the same computer). The main threats come from four directions: fake extensions, other malicious extensions, Trojans on the computer (including clipboard hijackers), and users clicking "confirm" on malicious websites.
This article has three layers:
- Layer 1: The Intuition: A safe living inside the browser
- Layer 2: Real-World Use: Fake wallets in the app store, clipboard Trojans, and info-stealing Trojans
- Layer 3: Model, communication, and engineering details
Layer 1: The Intuition
1.1 A safe living inside the browser
An extension wallet is like a safe living inside your browser:
- The private key is stored locally, encrypted with your password;
- When a web page wants to transfer funds or sign a message, it can only request the wallet to pop up a window for you to click "confirm";
- The web page itself cannot access the private key.
1.2 But the safe and the thief live in the same building
| Thief | What they can do |
|---|---|
| Malicious web page | Can only send requests; tricking you into clicking "confirm" is its only way |
| Other malicious extensions | If they have "read and change all your data on all websites" permissions, they can tamper with web content and monitor your input |
| Trojans on the computer | Read the extension's encrypted storage files and then brute-force the password; or log keystrokes to wait for you to type your password |
| Clipboard hijacker | When you copy an address, it silently replaces it with the attacker's address |
Layer 2: Real-World Use
- Fake wallet extensions: Fake extensions with names and icons nearly identical to MetaMask or Phantom frequently appear in browser app stores. Once installed, they ask you to "import your recovery phrase," which is sent directly to the attacker. Fake download links are also common in search engine advertisements.
- Clipboard hijacking (clipper): A type of Trojan that monitors the clipboard. When it detects content that looks like a cryptocurrency address, it replaces it with the attacker's. Advanced versions generate addresses that are similar at the beginning and end to make them difficult to detect alongside address poisoning.
- Info-stealing Trojans: Many commercialized info-stealers specifically search for browser extension wallet data directories, package them, upload them, and then perform offline brute-force attacks on the wallet password. Wallets with weak passwords are quickly compromised.
- Malicious extension updates: A legitimate extension might be sold to a third party, or a developer account might be compromised, leading to a malicious update being pushed to all users automatically.
Layer 3: Principles and Engineering
3.1 The extension isolation model
| Component | Where it runs | What it can access |
|---|---|---|
| Background (Service Worker) | The extension's own origin | Encrypted keystore, extension storage |
| Popup | The extension's own origin | Communicates with the background |
| Content Script | Injected into every web page | The web page's DOM, but the JavaScript environment is isolated |
Page-injected provider (window.ethereum) |
Within the web page's environment | Can only send requests to the extension via messages |
Key point: The private key only exists within the extension's own origin; web pages and content scripts cannot touch it (see "Same-Origin Policy and Subdomain Isolation" for the application of the Same-Origin Policy in extensions).
3.2 How web pages communicate with wallets
EIP-1193 defines the window.ethereum.request({ method, params }) interface. Common methods include:
| Method | Purpose | Risk |
|---|---|---|
eth_requestAccounts |
Request connection to get address | Low, but it exposes your address |
eth_sendTransaction |
Send transaction | You must verify the to, value, and data |
personal_sign |
Sign a message | Check if the content is human-readable |
eth_signTypedData_v4 |
Sign structured data | The primary vehicle for Permit phishing (see "Blind Signing and What You See Is What You Sign") |
wallet_switchEthereumChain |
Switch network | Misleads users into operating on the wrong chain |
EIP-6963 (2023) solved another problem: when multiple wallet extensions want to write to window.ethereum, the last one installed would overwrite the previous ones, allowing malicious extensions to impersonate others. EIP-6963 changes this so each wallet broadcasts its identity via events, allowing the web page to list them for the user to choose.
3.3 Permissions are the greatest risk factor
Browser extensions can request broad permissions such as "read and change all your data on all websites." Installing an extension with this permission is equivalent to allowing it to modify any web page you open, including the DApp page where the wallet asks for your confirmation.
Suggestions:
- Use a dedicated browser profile for cryptocurrency operations; install only the wallet extension and no other extensions;
- Regularly check the permissions of installed extensions and delete those you do not use;
- Only install wallets from the official website links in the app store; do not click on search advertisements.
3.4 Requirements for developers
- The derivation of the wallet password must be sufficiently slow (high-iteration PBKDF2, scrypt, or Argon2) to make offline brute-force attacks expensive;
- The content displayed in the popup must come from the wallet's own decoding, rather than descriptive text passed from the web page;
- Signature requests must be confirmed by the user within the wallet interface; the web page cannot simulate the click.
- Manifest V3 restrictions: Prohibiting the execution of remote code reduces the attack surface for poisoning, aside from "malicious updates."
3.5 When to switch to a hardware wallet
The fundamental limitation of extension wallets is: the private key and potential malware reside on the same computer. For daily small transactions, extension wallets are very convenient. When storing larger assets, you should use the extension wallet as the "interface" for a hardware wallet (the extension is only responsible for displaying and forwarding, while the signature is completed on the hardware device); see "The Attack Surface of Hardware Wallets."
Summary
| Layer | Key points |
|---|---|
| Model | The private key is in the extension's own origin; web pages can only send requests |
| Threats | Fake extensions, malicious extensions, info-stealers, clipboard hijacking, tricking you into clicking "confirm" |
| Technology | EIP-1193 request interface; EIP-6963 prevents overwriting/impersonation |
| Suggestions | Dedicated browser profile; minimize extensions; strong passwords; use hardware wallets for large amounts |