EIP-107 Safe Approval for HTML Popup Transactions (safe "eth_sendTransaction" authorization via html popup)
No call decision · Security & privacy · EIP status Stagnant · created 2016-06-05
A proposal to let a dapp call eth_sendTransaction safely without the node turning on CORS, by having the node serve an html popup that requests the user's approval for every transaction.
Why it is needed
Today, to use a dapp in a browser, the user must manually turn on the node's CORS setting. Turning on CORS lets the dapp access the node's rpc, but it also lets it send any transaction from an unlocked account without the user's consent. The user is stuck with both the inconvenience of changing node settings and the risk of having to blindly trust the dapp. To avoid this, people have resorted to cumbersome workarounds: entering simple transfers into a separate wallet like Mist, or typing complex transactions directly into the node's command line. This EIP proposes a way for a dapp to use the node's rpc safely without turning on CORS.
What changes
Today
- To use a dapp, the user must manually turn on the node's CORS
- Turning on CORS allows transactions to be sent from an unlocked account without consent
- Simple transfers had to go through a separate wallet, and complex transactions had to be typed directly into the node's command line
After EIP-107
- It loads the node-provided authorization.html as an invisible iframe to handle read-only calls
- eth_sendTransaction requests open a separate popup window showing the sender, recipient, amount, and gas fee for approval
- A dapp can use the node's rpc without turning on CORS
- If the account is locked and the node provides the personal api, the popup can temporarily unlock it by entering a password
Who is affected
- Users: You can use a dapp without turning on the CORS setting, and approve or cancel each transaction directly in a popup that shows the sender, recipient, amount, and gas fee.
- dapp developers: You need to implement postMessage-based communication code with the iframe/popup, and eth_sign cannot be called this way.
- Node and client teams: The authorization.html file must be served from the node's http endpoint.
In depth
Motivation: the CORS dilemma
Previously, for a dapp to use the node's rpc, the user had to turn on CORS, and once turned on, any dapp could send a transaction from an unlocked account without the user's consent. So users worked around this by entering simple transfers into a trusted wallet like Mist and typing complex cases directly into the node's command-line interface. This proposal aims to offer a safe, user-friendly alternative without these workarounds.
Two modes: iframe and popup window
The node serves <node url>/authorization.html over http. This file is used in two modes. The iframe mode, embedded invisibly in the dapp, performs read-only rpc calls without CORS, and the popup mode, opened as a new window, lets the user directly confirm and approve eth_sendTransaction. Both modes are served from the same domain/port as the node, so they are not restricted by CORS policy.
Calls allowed in the iframe
The javascript in iframe mode never executes calls that require an unlocked key. This is to prevent a dapp from using a hidden iframe to trick the user into clicking a confirm button. In the implementation, this is enforced via an allowedMethods list containing only read-only methods such as web3_clientVersion, eth_getBalance, eth_call, and eth_getLogs; methods not on the list are rejected with a notAllowed error.
Only eth_sendTransaction is allowed in the popup window
Popup mode only allows eth_sendTransaction. eth_sign is not allowed, because there is no safe way to show the user the meaning of what they are signing. An eth_sendTransaction request must include from, to, gas, and gasPrice, and if any is missing, an error is returned. The popup uses these values to calculate the amount to be sent and the estimated gas fee to show the user.
postMessage communication protocol
The iframe/popup first sends the string "ready" via postMessage to signal it is ready to receive messages. After that, the dapp sends requests in the form {id, payload}, and responses come back as {id, result, error}. The id is used to match requests and responses in situations where response order is not guaranteed. Because of postMessage's constraints, error is not a javascript Error object but a {message, type} form, and a type of "cancel" means the user rejected the request.
Account locking and personal api integration
The popup checks whether the node provides the personal api, and if so, prompts the user for a password when the account is locked. It unlocks the account via a personal_unlockAccount call, but limits the unlock period to a short 3 seconds, so if no transaction is sent within that window, the next transaction will ask for the password again. If the personal api is not available and the account is locked, the popup only shows a message telling the user to unlock the account manually.
Design rationale: an html file instead of oauth
The initial idea was an oauth-like protocol, but some geth contributors pointed out that this would require the node codebase to recognize dapps, which did not fit. So they chose a self-contained html file approach that could be shared across node implementations, with safety guaranteed by the browser's cross-domain policy. Using the native window.confirm for popup confirmation was also considered, but was dropped in favor of a custom popup because of an issue in some browsers where focus could land on the confirm button and get pressed automatically (Chromium bug 260653).
Current status
This EIP is in Stagnant status and was never adopted as a standard. Since it was never actually implemented or changed afterward, what is described here reflects the original 2016 proposal and differs from the standard approach used in today's wallet ecosystem.