onionwire/docs/THREAT_MODEL.md

13 KiB
Raw Permalink Blame History

OnionWire threat model (v1)

OnionWire is a two-party chat over Tor onion services. There is no chat server. Wire format: PROTOCOL.md. In-house review notes: SECURITY_AUDIT.md — not a public third-party audit.

Tor relays are not a chat server

Each install hosts its own v3 onion and dials friends’ onions through in-process Arti. Relays move cells; they never see plaintext, never store messages, and never hold a roster. Compromising a relay is not compromising OnionWire’s message store. The store is the sqlite file on the endpoint.

Location updates are not a missing-person finder

A signed loc frame (onion, ts, sig) rewrites a friend’s locator only if that friend is already in the roster, the signature verifies against the pinned pubkey, and ts is newer. There is no directory, DHT, or introduction server. If you rotated while they were offline, they cannot find you until they F3-paste your new invite. OnionWire will not hunt for a missing person.

Rotating the onion does not revoke a friend

F4 changes the locator only. The identity key is unchanged. Anyone who already has your pubkey can still prove they are talking to you, and a later invite paste with the same k updates their row. To become a new person, /wipe-all (new identity key). There is no in-band unfriend/revoke in v1.

Your store is encrypted

The sqlite store is SQLCipher (rusqlite feature bundled-sqlcipher-vendored-openssl). A 32-byte key is derived from the store passphrase with Argon2id (same params as identity backup) over a per-install 16-byte salt in store_salt, and handed to SQLCipher as a raw key (PRAGMA key = "x'…'") — no second KDF pass over it. The key is the first statement after open, so the file header, schema, identity secret key, friend public keys, locators, profiles and payment rows are all ciphertext on disk. There is no identity_sk-on-disk problem to work around because identity_sk is inside the encrypted file. A wrong or empty passphrase fails closed before any write; an encrypted store whose store_salt is missing refuses to open instead of guessing.

v0.2.1 installs have a plaintext db. The first open with the right passphrase upgrades it in place (ATTACH … KEY + sqlcipher_export after a WAL checkpoint), and swaps the file in only after the new file opens, passes integrity_check and unwraps store_meta. A wrong passphrase leaves the plaintext file untouched. The store_salt file is not secret (a salt never is).

Chat bodies carry a second, row-bound layer: ChaCha20-Poly1305 (nonce || ciphertext in messages.plaintext) with AAD owmsg1 || friend_id_le64 || dir || 0x00 || row_id_le64, plus a random 32-byte data key wrapped with Argon2id from the same passphrase (store_meta). Whole-db encryption does not stop someone who can write the file from moving one row's ciphertext into another row; the AAD does, and it stays. Unlock is fail-closed: wrong or empty passphrase does not open chat. Empty-AAD v0.2 blobs are rewrapped once on unlock; list_messages never falls back to empty AAD.

At-rest encryption is not a defense against a live compromise: while OnionWire runs, the passphrase, the db key and decrypted bodies are in process memory, and SQLCipher's page cache holds decrypted pages. It also does not stop an attacker who has your passphrase. /wipe deletes chat and payments history (overwrite message bodies, VACUUM, WAL checkpoint); roster and identity stay. It is not a forensic erase — SSD wear-leveling can keep copies. /wipe-all deletes the data dir (new identity); same disk caveat.

Fail closed

Peer onion down → a chat send is queued locally and retried (see “Local outbox (chat retry queue)”); file transfer and payment frames still fail immediately. Fingerprint mismatch vs the pinned key → hard fail, no send, never queued. Arti HS experimental: if it cannot publish, OnionWire stops; it does not fall back to C-tor.

Local outbox (chat retry queue) is local, and it re-dials on a schedule

A chat send to an unreachable onion is written to an outbox row next to its messages row and retried in the background. There is no server-side queue: a queued message is never handed to a third party, and it dies with the device. Two consequences are real and are accepted:

  • Device seizure. A pending (never-delivered) message sits in the same SQLCipher store as the rest of the history, under the same per-row AEAD and the same passphrase-derived key — no weaker, but also no shorter-lived. Seizure with the passphrase reveals messages that were never actually sent, including ones the sender may have moved on from; seizure without it reveals nothing in this store. /wipe clears outbox rows with the rest of chat history; /wipe-all removes them with the data dir. Neither is a forensic erase.
  • Retry cadence is a local traffic-analysis surface. A queued send re-dials the peer's onion on a backoff schedule while the app runs. An observer of your Tor client (or the network in front of it) sees a repeating connection attempt to one onion on a predictable cadence — it does not learn the plaintext or the recipient identity, but it can infer that you have an undelivered message for someone, and roughly when you composed it. The backoff is per-row, capped at one attempt per 30 min per message, and stops after 8 attempts or on a terminal failure.

The queue is bounded in scope: chat only. File transfer and rcp frames are one-shot, so a failed payment claim does not sit in the store being retried forever.

Profile is friend-visible, not a directory

A signed prf frame is shown to people who already have a session with you. Apply only for existing friends. There is still no name lookup, DHT, or public profile server. Anyone who already has a Noise session can see the profile you send them; that is not confidentiality against that friend.

Payments are opt-in; spend is a local authority

Chat does not need a wallet. Payment frames (inv, rcp, tip) are signed claims over Noise: a signature proves which friend sent the claim, not that money moved. verified=1 only after a conjunctive match — one get_transfers row with the same non-empty txid, amount, and address. RPC down, error, or no exact row → stay verified=0. Subaddress reuse is the user’s wallet policy.

Default: no spend. No seed and no spend key on the device. Receive can use the profile xmr_addr, or a view-only wallet (create_address / get_transfers only). /tip is off (ONIONWIRE_WALLET_NO_SPEND, or a watch-only wallet detected over RPC via query_key spend_key → -29).

Spend is opt-in, at wallet create or restore, not a hidden default. A seed-backed spend-capable wallet makes OnionWire a local spend authority for that file: anyone with the wallet passphrase or the wallet-RPC credentials can move the balance, and /tip is a supported way for a chat peer to get paid. The spend-authority warning is unavoidable at that create/restore step. Loopback binding is not an authorization boundary. Back up the seed; do not leave a spend-capable wallet on a device you do not trust; a separate hot wallet with a small balance is the sane spend shape, not savings.

The app talks to monero-wallet-rpc over loopback HTTP Digest only (--rpc-login required; open RPC refused). That process may be one the user already runs, or one the app spawns. Wallet RPC is never dialed over clearnet or over .onion — a remote wallet RPC would move spend authority off the box through a channel the messenger’s --password gate does not cover.

Chain source is the user’s choice

Scan, receipt verification, and spend need a Monero daemon. The user picks one; the app does not pick a public remote node for them.

  1. Spawn a local monerod (pruned is the on-device target). Chain traffic stays on the device. The user accepts disk (tens of GB for a pruned mainnet node), first-sync time, and — on Android — process kills: the daemon is not always running. A pruned node is not an archive. Seed restore of deep history can degrade; once the wallet has scanned, its own cache is the history. Unsynced or not running is an honest “not ready” / unverified state, not a fake success.

  2. A daemon address they supply. The wallet child points --daemon-address at that host. Trust follows the address:

    • Loopback — same privacy as (1); the user owns monerod.
    • .onion — chain traffic over Tor through a localhost SOCKS5 listener the app provides for the wallet child (not the messenger’s Arti connect(), and not a C-tor fallback for chat). That listener is the bundled arti binary run as a child (arti proxy -p <port>) — a second, separate Tor client with its own state and cache dirs, because arti-client 0.46 exposes no SOCKS listener API. It is TCP loopback only (arti proxy -p binds 127.0.0.1/::1; arti 2.6.0 / tor-config 0.46 have no Unix-socket listen target — arti#1965), and the port is usable by any local process at the user's privilege level: it is an app-private port, not an access-controlled one. The app gates the spawn on the unlocked store and waits ≤20s for the listener to accept before starting the wallet child, so a dead proxy fails visibly instead of hanging. The SOCKS child stops with the wallet child. Tor hides the transport. The daemon operator still sees the wallet’s addresses during sync. The host is the trust boundary.
    • Clearnet — only if the user typed it. Not a default, not implied. The ISP sees Monero-node traffic; the daemon operator sees addresses. Show that trust shift before using the address.

Remote daemons are untrusted (--trusted-daemon off). Setup, view-only vs spend, and RPC credentials: WALLET.md.

Backup file is the identity

/backup writes the identity and Noise static secrets. Treat the file like onionwire.db. Restore overwrites self keys and does not rewrite the friends table.

Rate limit is availability, not anonymity

Incoming rendezvous accepts are token-bucket limited (30/60s, burst 10). Excess is dropped without handshake. That is a DoS/availability control. It does not hide that you run an onion, and it is not a traffic-analysis defense. The constants are unchanged. Clients absorb the cost: file senders pace and retry chunks to fit this budget. The accept loop does not distinguish a friend from a flood.

Network (UDP / clearnet)

The application does not open UDP sockets and does not resolve friends via system DNS. Peer dials are Arti connect((onion, 80)) only.

Wallet RPC (HTTP Digest to monero-wallet-rpc) is loopback TCP only (numeric 127.0.0.1 / ::1 preferred; localhost still does getaddrinfo). That socket is the app talking to the wallet process, not to the chain.

Chain traffic is the wallet child’s connection to a Monero daemon. It is off unless the user opted into a wallet and chose a chain source: spawned local monerod (loopback), or a daemon address they entered. A .onion daemon is reached through a localhost SOCKS5 proxy used only by that wallet child: the bundled arti binary run as arti proxy -p <port>, whose --proxy target is 127.0.0.1 and whose .onion name travels inside the SOCKS request (Monero's SOCKS5 client sends the domain-name form, so no local DNS runs on it). The messenger's in-process Arti client is never handed to the wallet child. A clearnet daemon address is an explicit user choice — a clearnet socket they asked for — not the messenger path and not a hidden default.

Do not add STUN/ICE/WebRTC, a DHT, SOCKS/C-tor fallback for peer dials, or “direct TCP when the onion is slow.” Those are the Tox-over-Tor leak class. A SOCKS listener used only by the wallet child to reach a user-chosen .onion daemon is not that class.

Peer text is untrusted display data

Chat bodies and fil names come from a Noise peer, not from the local user. They are display data, not terminal commands. A friend (or anyone who stole that session) can put ESC/CSI/OSC, C1 controls, or bidi overrides in a payload. OnionWire strips those at ingest (so sqlite history is clean) and again at TUI render (so rows written before this rule stay inert). Filenames that contain the same characters are rejected, not rewritten. This is a UI-redressing / terminal-injection boundary, not a confidentiality control: the peer already knows the plaintext they sent.

Out of v1

Prosody, XMPP, s2s, MAM, carbons, a server-side outbox / store-and-forward relay, multi-device, DHT / name server, A/V. The local retry queue of the previous section is not an outbox in the XMPP sense: it never leaves the device.