2026-09-10 02:49:42 -04:00
# OnionWire threat model (v1)
OnionWire is a two-party chat over Tor onion services. There is no chat server.
2026-09-11 13:15:51 -04:00
Wire format: [PROTOCOL.md ](PROTOCOL.md ). In-house review notes:
[SECURITY_AUDIT.md ](SECURITY_AUDIT.md ) — **not ** a public third-party audit.
2026-09-10 02:49:42 -04:00
## 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
2026-09-10 16:53:03 -04:00
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.
2026-09-10 02:49:42 -04:00
## Rotating the onion does not revoke a friend
2026-09-10 16:53:03 -04:00
`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.
2026-09-10 02:49:42 -04:00
2026-09-12 13:00:18 -04:00
## 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.
2026-09-10 02:49:42 -04:00
## Fail closed
feat(outbox): local retry queue for chat sends
Queue a chat send locally when the peer's v3 onion is unreachable and retry
it with exponential backoff (30s doubling, capped at 30 min, 8 attempts then
terminal Failed). Still peer-to-peer: no server, no store-and-forward relay,
no new frame prefix — every attempt is a fresh Noise IK handshake.
- src/outbox.rs: Outbox + Deliverer + ArtiDeliverer, pure backoff_secs(),
is_permanent_send_error(), background worker (15s scan).
- store: `outbox` table (no body column — the body is read from the joined
messages row, under that row's existing AEAD + AAD), append_message_id(),
queue/due/pending/mark_* helpers, reset_sending_outbox(), wipe.
- Node::send() returns Result<OutboxStatus, String> (Sent/Queued) instead of
Err on transport failure; protocol errors still fail immediately and are
never queued.
- Retry triggers: timer, unlock/foreground (spawn_flush_all), and "that peer
was just seen" (handshake or connect_onion -> spawn_flush_friend).
- File transfer and payment/rcp frames stay fail-closed.
- docs/PROTOCOL.md + docs/THREAT_MODEL.md: replace the no-queue statements;
add the seizure/cadence delta to the threat model.
src/tui.rs gets one forced arm change (Ok(()) -> Ok(_)); UI surfacing is
child card t_d9a5b065.
2026-09-12 13:35:10 -04:00
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.
2026-09-10 02:49:42 -04:00
2026-09-10 14:50:01 -04:00
## 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.
2026-09-13 23:25:25 -04:00
## 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). 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 ](WALLET.md ).
wallet: no-spend mode + view-only detection over RPC
/tip needs monero-wallet-rpc `transfer`, which a view-only wallet cannot do.
With ONIONWIRE_WALLET_NO_SPEND=1 (`1`/`true`/`yes`/`on`) `Wallet::transfer`
refuses locally, before any RPC dial, and /pay + receipt verification are
unchanged.
When a transfer does fail, ask the documented signal before surfacing the raw
wallet error: `query_key` key_type=spend_key answers
WALLET_RPC_ERROR_CODE_WATCH_ONLY (-29) on a view-only wallet
(wallet_rpc_server.cpp on_query_key). Both paths return one sentence —
"wallet is in view-only/no-spend mode — /tip is disabled; /pay and receipt
verification still work". Fail closed: if the probe cannot answer, the wallet's
own error stands; no fabricated detection.
New docs/WALLET.md: --generate-from-view-key / generate_from_keys watch-only
setup, --rpc-login Digest, why loopback still needs auth, the local
spend-authority warning, and the detection trade-off (a spend-capable wallet
answers the probe with its spend key, which is discarded). Linked from
docs/THREAT_MODEL.md.
2026-09-12 12:59:49 -04:00
2026-09-10 14:50:01 -04:00
## 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
2026-09-11 23:49:29 -04:00
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.
2026-09-10 14:50:01 -04:00
2026-09-11 13:15:51 -04:00
## Network (UDP / clearnet)
The application does not open UDP sockets and does not resolve friends via
2026-09-13 23:25:25 -04:00
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. 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.
2026-09-11 13:15:51 -04:00
2026-09-11 23:42:48 -04:00
## 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.
2026-09-10 02:49:42 -04:00
## Out of v1
feat(outbox): local retry queue for chat sends
Queue a chat send locally when the peer's v3 onion is unreachable and retry
it with exponential backoff (30s doubling, capped at 30 min, 8 attempts then
terminal Failed). Still peer-to-peer: no server, no store-and-forward relay,
no new frame prefix — every attempt is a fresh Noise IK handshake.
- src/outbox.rs: Outbox + Deliverer + ArtiDeliverer, pure backoff_secs(),
is_permanent_send_error(), background worker (15s scan).
- store: `outbox` table (no body column — the body is read from the joined
messages row, under that row's existing AEAD + AAD), append_message_id(),
queue/due/pending/mark_* helpers, reset_sending_outbox(), wipe.
- Node::send() returns Result<OutboxStatus, String> (Sent/Queued) instead of
Err on transport failure; protocol errors still fail immediately and are
never queued.
- Retry triggers: timer, unlock/foreground (spawn_flush_all), and "that peer
was just seen" (handshake or connect_onion -> spawn_flush_friend).
- File transfer and payment/rcp frames stay fail-closed.
- docs/PROTOCOL.md + docs/THREAT_MODEL.md: replace the no-queue statements;
add the seizure/cadence delta to the threat model.
src/tui.rs gets one forced arm change (Ok(()) -> Ok(_)); UI surfacing is
child card t_d9a5b065.
2026-09-12 13:35:10 -04:00
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.