CubWallet Docs
中文

Security model

CubWallet keeps private keys inside the extension. A web page can only request a signature through the approval window. This page describes the protections a user actually sees, and the boundaries a developer must respect.

Approval window

bts_requestAccounts, bts_signTransaction and bts_signAndBroadcast all open a dedicated approval window (except bts_requestAccounts when the origin is already authorized and the wallet is unlocked).

For a signing request, the window is filled from a decode of the transaction bytes plus chain lookups, not by showing the JSON the dApp sent. Accounts are resolved to names when possible, assets to symbols and precision, memos are decrypted when the wallet can, and a pool swap is re-quoted against the current pool and compared with min_to_receive. High-risk operations (for example changing authorities, or approving a proposal that does) require extra confirmation.

The user can reject or close the window. Without that confirmation, nothing is signed and nothing is broadcast.

An origin may have only one pending request at a time; a request times out after 5 minutes. Pending records live in the service worker's memory: if the browser discards the worker, the request is gone and the dApp must start again.

chain_id and expiration

Before signing, the wallet reads get_chain_id and the dynamic global properties from the current node, and checks that:

  1. The node's chain id is exactly the wallet's current network. This stops a mainnet wallet from signing a testnet transaction, or from using the wrong node.
  2. The transaction expiration is after the head-block time and after local now.
  3. The expiration is no more than 1 day after the head block (the usual chain limit) and no more than 1 hour after it (the wallet's own, stricter limit). A malicious page therefore cannot leave a long-lived signed transaction around.

The wallet sets the transaction expiration to about 10 minutes after the head block; the dApp cannot choose this value. Operation-level deadlines, such as a limit order's expiration, are still provided by the dApp and shown in the approval window.

The owner key is never available to dApps

The owner private key is stored in a vault separate from the main wallet blob. A normal unlock does not decrypt it. There is no dApp method to export, read or use the owner key directly.

Only when a transaction actually needs owner authority (for example changing the owner authority, approving a proposal with the owner role, or using the owner key because the wallet has no active key for that account) does the approval window require:

  1. the user to type the account name;
  2. the user to enter the wallet password again.

After signing, the owner key is wiped from memory. Without those two steps, signing does not proceed.

Origin and injection scope

The origin the wallet sees is port.sender.origin, filled in by the browser. The page cannot forge it. Only https origins, plus http://localhost and http://127.0.0.1 on the local machine, can connect, and only as a top-level page. Iframes and file:// cannot.

Permissions are stored per origin and network. The user can revoke a site from the wallet settings. The extension's internal message API accepts calls only from extension pages; a web page that sends chrome.runtime messages is rejected.

Watch-only accounts and permission scope

A watch-only account can appear in the connect window and in bts_accounts, but it cannot sign. Any account that must sign or encrypt a memo has to be authorized for this origin and must have the corresponding private key in the wallet. The wallet will not sign with a key of an account that this site was not granted, and will not use a public key that does not belong to an authorized account.

What developers should do