{"eip":5593,"title":"Restrict Ethereum Provider API Injection","description":"Wallet guidance for restricting Ethereum Provider API access to secure contexts for improved privacy and security for wallet users.","authors":["Yan Zhu (@diracdeltas)","Brian R. Bondy (@bbondy)","Andrea  Brancaleoni (@thypon)","Kyle Den Hartog (@kdenhartog)"],"status":"Stagnant","type":"Standards Track","category":"Interface","created":"2022-09-05","requires":[1193],"discussionsTo":"https://ethereum-magicians.org/t/rfc-limiting-provider-object-injection-to-secure-contexts/10670","repo":"EIPs","label":"EIP-5593","officialUrl":"https://eips.ethereum.org/EIPS/eip-5593","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-5593.md","url":"https://eips.huatuo.xyz/eip-5593/","tldr":{"en":"Wallet guidance to inject window.ethereum only into secure (HTTPS or localhost) first-party pages, keeping it away from insecure pages and third-party iframes such as ads.","ja":"window.ethereum を安全な（HTTPS または localhost の）ファーストパーティのページにのみ注入し、安全でないページや広告などのサードパーティ iframe からは遠ざけるための、ウォレット向けガイダンス。","ko":"window.ethereum을 안전한(HTTPS 또는 localhost) 퍼스트파티 페이지에만 주입하고, 안전하지 않은 페이지나 광고 같은 서드파티 iframe에는 주입하지 않도록 하는 지갑용 가이드.","zh":"给钱包的指导：只向安全（HTTPS 或 localhost）的第一方页面注入 window.ethereum，使其远离不安全页面以及广告等第三方 iframe。"},"tags":["wallet","provider","browser","privacy","security"],"explainers":{"en":{"lang":"en","tldr":"Wallet guidance to inject window.ethereum only into secure (HTTPS or localhost) first-party pages, keeping it away from insecure pages and third-party iframes such as ads.","tags":["wallet","provider","browser","privacy","security"],"related":[1193,6963,2255],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-5593/","markdown":"## What problem does it solve?\n\nBrowser wallets traditionally inject the provider object (`window.ethereum`, defined by [EIP-1193](/eip-1193/)) into almost every page and frame. That object lets a page ask for accounts and request signatures or transactions, so it is a \"powerful\" API in the same sense as camera or geolocation access.\n\nInjecting it everywhere has two downsides:\n\n- **Attack surface.** A malicious advertisement loaded in an iframe on a legitimate dApp can talk to the wallet and try to trick the user into approving something.\n- **Fingerprinting.** Any page can detect that the visitor is a Web3 user just by checking for the provider.\n\nThe web platform already solves this for other powerful APIs with W3C *secure contexts*. EIP-5593 asks wallets to apply the same boundary to the Ethereum provider.\n\n## How it works\n\nThe proposal is a set of rules for wallets, not a new API:\n\n- The provider is only exposed when the page is a *potentially trustworthy origin*, which you can check with `window.isSecureContext`. HTTPS pages qualify, and so does `http://localhost`.\n- In any frame where `window.isSecureContext` is `false`, `window.ethereum` must be `undefined`.\n- **Third-party iframes** (a different origin from the top-level page, including subdomains) get no provider by default. Wallets may offer an opt-in path, for example via the iframe `allow` attribute and the Permissions API, subject to user approval.\n- **Same-origin iframes with `sandbox`** are blocked, unless the sandbox includes `allow-same-origin`.\n- Private/incognito windows may still get the provider.\n\nSome of the required test cases from the spec:\n\n| Top level | Frame | Result |\n| --- | --- | --- |\n| `http://a.com` | none | blocked (insecure) |\n| `https://a.com` | none | allowed |\n| `https://a.com` | `https://a.com` | allowed |\n| `https://a.com` | `https://b.com` | blocked (third party) |\n| `https://a.com` | `https://sub.a.com` | blocked (third party) |\n| `https://a.com` | `https://a.com` with bare `sandbox` | blocked |\n\nFor local development, wallets should offer a \"developer mode\" toggle, off by default, that relaxes the check only for `http://localhost` in browsers that do not already treat localhost as secure.\n\n## Sample code\n\nHow a wallet content script could decide whether to inject (simplified illustration of the rules):\n\n```ts\nfunction shouldInjectProvider(win: Window): boolean {\n  // 1. Must be a secure context (HTTPS, or localhost)\n  if (!win.isSecureContext) return false;\n\n  // 2. Top-level window: OK\n  if (win === win.top) return true;\n\n  // 3. Iframe: must be same-origin with the top-level page\n  try {\n    if (win.location.origin !== win.top!.location.origin) return false;\n  } catch {\n    return false; // cross-origin access throws -\u003e third party\n  }\n\n  // 4. Same-origin but sandboxed without allow-same-origin -\u003e blocked.\n  // A sandbox without allow-same-origin gives the frame an opaque origin,\n  // so its origin reads as \"null\".\n  if (win.origin === \"null\") return false;\n\n  return true;\n}\n\nif (shouldInjectProvider(window)) {\n  (window as any).ethereum = createProvider();\n}\n```\n\nOn the dApp side, nothing changes except that you should handle a missing provider gracefully:\n\n```ts\nif (!window.isSecureContext || !(window as any).ethereum) {\n  showMessage(\"Open this dApp over HTTPS to connect a wallet.\");\n}\n```\n\n## Things to know\n\n- **Status: Stagnant.** It is guidance for wallet authors and is not a finalised standard; wallets may or may not follow it.\n- A dApp served over plain HTTP, or embedded as a cross-origin iframe, should expect no provider under these rules.\n- Extending the developer toggle beyond localhost is discouraged, since attackers could talk users into enabling it.\n- [EIP-6963](/eip-6963/) addresses a different provider problem (several wallets competing for `window.ethereum`); the two are complementary.\n"},"ja":{"lang":"ja","tldr":"window.ethereum を安全な（HTTPS または localhost の）ファーストパーティのページにのみ注入し、安全でないページや広告などのサードパーティ iframe からは遠ざけるための、ウォレット向けガイダンス。","tags":["wallet","provider","browser","privacy","security"],"related":[1193,6963,2255],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-5593/","markdown":"## 何を解決するのか\n\nブラウザウォレットは従来、プロバイダーオブジェクト（[EIP-1193](/eip-1193/) で定義された `window.ethereum`）をほぼすべてのページとフレームに注入してきました。このオブジェクトは、ページがアカウントを要求したり、署名やトランザクションをリクエストしたりできるようにするため、カメラや位置情報へのアクセスと同じ意味で「強力な」API です。\n\nどこにでも注入することには 2 つの欠点があります。\n\n- **攻撃対象領域。** 正規の dApp 上の iframe に読み込まれた悪意のある広告が、ウォレットと通信し、ユーザーをだまして何かを承認させようとする可能性があります。\n- **フィンガープリンティング。** どのページも、プロバイダーの有無を確認するだけで、訪問者が Web3 ユーザーだと検出できます。\n\nWeb プラットフォームは、他の強力な API についてはすでに W3C の*セキュアコンテキスト*でこの問題を解決しています。EIP-5593 は、ウォレットが Ethereum プロバイダーにも同じ境界を適用することを求めます。\n\n## 仕組み\n\nこの提案は新しい API ではなく、ウォレット向けのルール集です。\n\n- プロバイダーは、ページが*潜在的に信頼できるオリジン*である場合にのみ公開されます。これは `window.isSecureContext` で確認できます。HTTPS のページが該当し、`http://localhost` も該当します。\n- `window.isSecureContext` が `false` のフレームでは、`window.ethereum` は `undefined` でなければなりません。\n- **サードパーティの iframe**（トップレベルページとオリジンが異なるもの。サブドメインを含む）には、デフォルトではプロバイダーが提供されません。ウォレットは、たとえば iframe の `allow` 属性と Permissions API を通じて、ユーザーの承認を条件にオプトインの経路を提供してもかまいません。\n- **`sandbox` 付きの同一オリジン iframe** は、sandbox に `allow-same-origin` が含まれていない限りブロックされます。\n- プライベート/シークレットウィンドウでは、引き続きプロバイダーが提供されてもかまいません。\n\n仕様で必須とされているテストケースの一部:\n\n| トップレベル | フレーム | 結果 |\n| --- | --- | --- |\n| `http://a.com` | なし | ブロック（安全でない） |\n| `https://a.com` | なし | 許可 |\n| `https://a.com` | `https://a.com` | 許可 |\n| `https://a.com` | `https://b.com` | ブロック（サードパーティ） |\n| `https://a.com` | `https://sub.a.com` | ブロック（サードパーティ） |\n| `https://a.com` | `https://a.com`（値なしの `sandbox` 付き） | ブロック |\n\nローカル開発のために、ウォレットは「開発者モード」のトグル（デフォルトはオフ）を提供すべきです。これは、localhost をまだセキュアとして扱わないブラウザで、`http://localhost` に限ってチェックを緩めるものです。\n\n## サンプルコード\n\nウォレットのコンテンツスクリプトが注入するかどうかを判断する方法の例です（ルールを簡略化した説明用のコード）:\n\n```ts\nfunction shouldInjectProvider(win: Window): boolean {\n  // 1. Must be a secure context (HTTPS, or localhost)\n  if (!win.isSecureContext) return false;\n\n  // 2. Top-level window: OK\n  if (win === win.top) return true;\n\n  // 3. Iframe: must be same-origin with the top-level page\n  try {\n    if (win.location.origin !== win.top!.location.origin) return false;\n  } catch {\n    return false; // cross-origin access throws -\u003e third party\n  }\n\n  // 4. Same-origin but sandboxed without allow-same-origin -\u003e blocked.\n  // A sandbox without allow-same-origin gives the frame an opaque origin,\n  // so its origin reads as \"null\".\n  if (win.origin === \"null\") return false;\n\n  return true;\n}\n\nif (shouldInjectProvider(window)) {\n  (window as any).ethereum = createProvider();\n}\n```\n\ndApp 側では、プロバイダーがない場合を適切に処理すること以外、何も変わりません。\n\n```ts\nif (!window.isSecureContext || !(window as any).ethereum) {\n  showMessage(\"Open this dApp over HTTPS to connect a wallet.\");\n}\n```\n\n## 知っておくべきこと\n\n- **ステータス: Stagnant。** ウォレット開発者向けのガイダンスであり、確定した標準ではありません。ウォレットが従うかどうかは任意です。\n- プレーンな HTTP で配信される dApp や、クロスオリジンの iframe として埋め込まれた dApp は、これらのルールの下ではプロバイダーがないものと考えるべきです。\n- 開発者向けトグルを localhost 以外に拡張することは推奨されません。攻撃者がユーザーを説得して有効にさせる可能性があるためです。\n- [EIP-6963](/eip-6963/) は別のプロバイダー問題（複数のウォレットが `window.ethereum` を取り合う問題）に対処するものです。両者は補完的です。\n"},"ko":{"lang":"ko","tldr":"window.ethereum을 안전한(HTTPS 또는 localhost) 퍼스트파티 페이지에만 주입하고, 안전하지 않은 페이지나 광고 같은 서드파티 iframe에는 주입하지 않도록 하는 지갑용 가이드.","tags":["wallet","provider","browser","privacy","security"],"related":[1193,6963,2255],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-5593/","markdown":"## 어떤 문제를 해결하나요?\n\n브라우저 지갑은 전통적으로 프로바이더 객체([EIP-1193](/eip-1193/)에서 정의한 `window.ethereum`)를 거의 모든 페이지와 프레임에 주입해 왔습니다. 이 객체는 페이지가 계정을 요청하고 서명이나 트랜잭션을 요청할 수 있게 하므로, 카메라나 위치 정보 접근과 같은 의미에서 \"강력한\" API입니다.\n\n어디에나 주입하면 두 가지 단점이 있습니다.\n\n- **공격 표면.** 정상적인 dApp의 iframe에 로드된 악성 광고가 지갑과 통신하며 사용자를 속여 무언가를 승인하게 만들려 할 수 있습니다.\n- **핑거프린팅.** 어떤 페이지든 프로바이더가 있는지만 확인하면 방문자가 Web3 사용자임을 알아낼 수 있습니다.\n\n웹 플랫폼은 다른 강력한 API에 대해서는 이미 W3C *보안 컨텍스트*로 이 문제를 해결했습니다. EIP-5593은 지갑이 이더리움 프로바이더에도 같은 경계를 적용하도록 요청합니다.\n\n## 어떻게 동작하나요?\n\n이 제안은 새로운 API가 아니라 지갑을 위한 규칙 모음입니다.\n\n- 프로바이더는 페이지가 *잠재적으로 신뢰할 수 있는 오리진*일 때만 노출되며, 이는 `window.isSecureContext`로 확인할 수 있습니다. HTTPS 페이지가 해당하고 `http://localhost`도 해당합니다.\n- `window.isSecureContext`가 `false`인 모든 프레임에서 `window.ethereum`은 `undefined`여야 합니다.\n- **서드파티 iframe**(최상위 페이지와 오리진이 다른 경우, 서브도메인 포함)에는 기본적으로 프로바이더가 제공되지 않습니다. 지갑은 예를 들어 iframe의 `allow` 속성과 Permissions API를 통해 사용자 승인을 전제로 한 옵트인 경로를 제공할 수 있습니다.\n- **`sandbox`가 있는 동일 오리진 iframe**은 sandbox에 `allow-same-origin`이 포함되지 않은 한 차단됩니다.\n- 프라이빗/시크릿 창에서는 여전히 프로바이더가 제공될 수 있습니다.\n\n사양에서 요구하는 테스트 케이스 일부입니다.\n\n| 최상위 | 프레임 | 결과 |\n| --- | --- | --- |\n| `http://a.com` | 없음 | 차단(안전하지 않음) |\n| `https://a.com` | 없음 | 허용 |\n| `https://a.com` | `https://a.com` | 허용 |\n| `https://a.com` | `https://b.com` | 차단(서드파티) |\n| `https://a.com` | `https://sub.a.com` | 차단(서드파티) |\n| `https://a.com` | 값 없는 `sandbox`가 있는 `https://a.com` | 차단 |\n\n로컬 개발을 위해 지갑은 기본값이 꺼짐인 \"개발자 모드\" 토글을 제공해야 합니다. 이는 localhost를 아직 안전한 곳으로 취급하지 않는 브라우저에서 `http://localhost`에 대해서만 검사를 완화합니다.\n\n## 샘플 코드\n\n지갑 콘텐츠 스크립트가 주입 여부를 판단하는 방법의 예시입니다(규칙을 단순화한 설명용 코드).\n\n```ts\nfunction shouldInjectProvider(win: Window): boolean {\n  // 1. Must be a secure context (HTTPS, or localhost)\n  if (!win.isSecureContext) return false;\n\n  // 2. Top-level window: OK\n  if (win === win.top) return true;\n\n  // 3. Iframe: must be same-origin with the top-level page\n  try {\n    if (win.location.origin !== win.top!.location.origin) return false;\n  } catch {\n    return false; // cross-origin access throws -\u003e third party\n  }\n\n  // 4. Same-origin but sandboxed without allow-same-origin -\u003e blocked.\n  // A sandbox without allow-same-origin gives the frame an opaque origin,\n  // so its origin reads as \"null\".\n  if (win.origin === \"null\") return false;\n\n  return true;\n}\n\nif (shouldInjectProvider(window)) {\n  (window as any).ethereum = createProvider();\n}\n```\n\ndApp 쪽에서는 프로바이더가 없는 경우를 적절히 처리해야 한다는 점 외에는 달라지는 것이 없습니다.\n\n```ts\nif (!window.isSecureContext || !(window as any).ethereum) {\n  showMessage(\"Open this dApp over HTTPS to connect a wallet.\");\n}\n```\n\n## 알아둘 점\n\n- **상태: Stagnant.** 지갑 개발자를 위한 가이드이며 확정된 표준이 아닙니다. 지갑이 따를 수도, 따르지 않을 수도 있습니다.\n- 일반 HTTP로 제공되거나 크로스 오리진 iframe으로 삽입된 dApp은 이 규칙 아래에서는 프로바이더가 없다고 예상해야 합니다.\n- 개발자 토글을 localhost 이외로 확장하는 것은 권장되지 않습니다. 공격자가 사용자를 설득해 켜게 만들 수 있기 때문입니다.\n- [EIP-6963](/eip-6963/)은 다른 프로바이더 문제(여러 지갑이 `window.ethereum`을 두고 경쟁하는 문제)를 다룹니다. 둘은 서로 보완적입니다.\n"},"zh":{"lang":"zh","tldr":"给钱包的指导：只向安全（HTTPS 或 localhost）的第一方页面注入 window.ethereum，使其远离不安全页面以及广告等第三方 iframe。","tags":["wallet","provider","browser","privacy","security"],"related":[1193,6963,2255],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-5593/","markdown":"## 它解决什么问题？\n\n浏览器钱包传统上会向几乎所有页面和框架注入 provider 对象（`window.ethereum`，由 [EIP-1193](/eip-1193/) 定义）。该对象允许页面请求账户并请求签名或交易，因此它与摄像头或地理位置访问一样，是一种\"强大\"的 API。\n\n到处注入有两个缺点：\n\n- **攻击面。** 在合法 dApp 的 iframe 中加载的恶意广告可以与钱包通信，试图诱骗用户批准某些操作。\n- **指纹识别。** 任何页面只需检查 provider，就能检测出访问者是 Web3 用户。\n\nWeb 平台已经通过 W3C 的*安全上下文*为其他强大的 API 解决了这个问题。EIP-5593 要求钱包对以太坊 provider 应用同样的边界。\n\n## 它如何运作\n\n该提案是一套给钱包的规则，而不是新的 API：\n\n- 只有当页面是*潜在可信的源*时才暴露 provider，这可以通过 `window.isSecureContext` 检查。HTTPS 页面符合条件，`http://localhost` 也符合。\n- 在任何 `window.isSecureContext` 为 `false` 的框架中，`window.ethereum` 必须为 `undefined`。\n- **第三方 iframe**（与顶层页面的源不同，包括子域名）默认不提供 provider。钱包可以提供选择启用的途径，例如通过 iframe 的 `allow` 属性和 Permissions API，并需经用户批准。\n- **带有 `sandbox` 的同源 iframe** 会被阻止，除非该 sandbox 包含 `allow-same-origin`。\n- 隐私/无痕窗口仍可获得 provider。\n\n规范中要求的部分测试用例：\n\n| 顶层 | 框架 | 结果 |\n| --- | --- | --- |\n| `http://a.com` | 无 | 阻止（不安全） |\n| `https://a.com` | 无 | 允许 |\n| `https://a.com` | `https://a.com` | 允许 |\n| `https://a.com` | `https://b.com` | 阻止（第三方） |\n| `https://a.com` | `https://sub.a.com` | 阻止（第三方） |\n| `https://a.com` | `https://a.com`，带无值的 `sandbox` | 阻止 |\n\n对于本地开发，钱包应提供一个\"开发者模式\"开关，默认关闭，仅在尚未把 localhost 视为安全的浏览器中，对 `http://localhost` 放宽检查。\n\n## 示例代码\n\n钱包内容脚本可以如何决定是否注入（规则的简化示意）：\n\n```ts\nfunction shouldInjectProvider(win: Window): boolean {\n  // 1. Must be a secure context (HTTPS, or localhost)\n  if (!win.isSecureContext) return false;\n\n  // 2. Top-level window: OK\n  if (win === win.top) return true;\n\n  // 3. Iframe: must be same-origin with the top-level page\n  try {\n    if (win.location.origin !== win.top!.location.origin) return false;\n  } catch {\n    return false; // cross-origin access throws -\u003e third party\n  }\n\n  // 4. Same-origin but sandboxed without allow-same-origin -\u003e blocked.\n  // A sandbox without allow-same-origin gives the frame an opaque origin,\n  // so its origin reads as \"null\".\n  if (win.origin === \"null\") return false;\n\n  return true;\n}\n\nif (shouldInjectProvider(window)) {\n  (window as any).ethereum = createProvider();\n}\n```\n\n在 dApp 一侧，除了应当妥善处理 provider 缺失的情况外，没有任何变化：\n\n```ts\nif (!window.isSecureContext || !(window as any).ethereum) {\n  showMessage(\"Open this dApp over HTTPS to connect a wallet.\");\n}\n```\n\n## 需要注意\n\n- **状态：Stagnant。** 这是给钱包作者的指导，并非最终确定的标准；钱包可能遵循，也可能不遵循。\n- 通过普通 HTTP 提供的 dApp，或作为跨源 iframe 嵌入的 dApp，在这些规则下应预期没有 provider。\n- 不鼓励把开发者开关扩展到 localhost 之外，因为攻击者可能说服用户启用它。\n- [EIP-6963](/eip-6963/) 解决的是另一个 provider 问题（多个钱包争抢 `window.ethereum`）；两者互为补充。\n"}}}
