Skip to content

Threat Model

Backdit separates long-lived Account Keys from replaceable per-machine Device Keys:

  • 24-Word BIP-39 Seed: Generated with 256 bits of CSPRNG entropy (bip39::WordCount::Words24).
  • HKDF-SHA256 Domain Separation: Expands the seed with salt backdit/key-hierarchy into five 32-byte keys: account-signing (Ed25519 AccountId), file-root (XChaCha20-Poly1305), storage-recipient (X25519 HPKE), recovery (Capsules & PackIndex), and locator (blind DHT lookup).
  • Device Authorization (DeviceCertificate): Each node generates an install-local Ed25519 keypair (identity.bundle) signed by AccountId (365d expiry, DeviceRevocation supported). Compromising a device does not expose the 24-word mnemonic unless the mnemonic was left on that disk.
  • Memory Hygiene: AccountKeys, ApiToken, and transient mnemonic structs wrap zeroize::Zeroize on drop and print [REDACTED] in Debug.

2. Confidentiality, Integrity & Local-Path Guards

Section titled “2. Confidentiality, Integrity & Local-Path Guards”
  • Per-Stripe Nonce Derivation: Each file draws a random 24-byte base nonce and XORs its 32-bit chunk_index per stripe (derive_chunk_nonce) before XChaCha20-Poly1305 encryption. PackIndex is encrypted separately.
  • Host Memory vs. Disk Boundary: Hosts verify Proof-of-Possession, receive incoming shards into OS-locked LockedBuffer memory (mlock / VirtualLock, failing closed if locking fails and zeroizing on drop; covers the LockedBuffer allocation itself rather than external library stack copies or full-system dumps), and seal them via RFC 9180 HPKE to the owner’s storage-recipient key (BKDTSEAL) before writing BKDTHOST to disk (with optional local host_store.key wrapping).
  • Local-Path Privacy: TABLE_LOCAL_SOURCES is strictly local to metadata.redb and never serialized into Recovery Capsules.
  • Protected-Root & Symlink Guards: upload-local skips symlinks (is_symlink()) and validates canonical paths. download-local rejects .. traversal, refuses overwriting existing files unless overwrite = true, and returns 403 Forbidden if a target resolves inside Backdit’s data_dir, chunks_dir, or config directory.
  • Admission PoW & Connection Caps: Handshakes require pow_difficulty = 16 (8..=24), bounded connection limits (96 in / 96 out on Desktop, 1024 in / 256 out on Bootstrap/Seed), 75% soft watermarks protecting the 48-peer sticky cohort, and InboundConnectionSubnetGuard (<= 4 concurrent inbound connections per public IPv4 /24 or IPv6 /48 and <= 24 combined over /p2p-circuit relays, closing excess connections via swarm.close_connection while exempting network.friends, bootnodes, and loopback/private addresses when allow_local_network = true).
  • Kademlia Routing Diversity: KademliaSubnetGuard (4,096-subnet LRU) enforces <= 2 distinct peers per public /24 or /48 before kademlia.add_address (exempting network.friends, bootnodes, and loopback/private when allow_local_network = true).
  • Inbound Host Starter-Pool, Capsule, Dust & RPC Guards (HostService):
    • Per-Subnet Starter-Pool Cap (InboundSubnetGuard, 4,096-subnet LRU): Caps aggregate unbacked debt across all accounts observed from any single public /24 or /48 (ConnectedPoint) at 512 MiB (max_bootstrap_debt_bytes), and caps /p2p-circuit relayed debt at (bootstrap_pool_cap / 4).max(512 MiB) (bypassing loopback/private when allow_local_network = true, and exempting [[economy.trusted_accounts]] and network.friends).
    • Unbacked StoreCapsule Flood Cap: Reciprocating partners and [[economy.trusted_accounts]] stay admitted up to usable disk; unreciprocated accounts are capped at 4 distinct accounts per public /24 or /48 and share a host-wide 1% of usable_bytes (32 MiB ..= 512 MiB) unbacked capsule budget.
    • Tiny-Shard (“Dust”) Object-Count Cap: Enforces MAX_UNBACKED_OBJECTS_PER_ACCOUNT = 256 objects while unbacked and 256.max((bytes_hosted_for_peer + incoming_len) / 65_536) globally (64 KiB average object floor past 256 objects) without distorting byte-level accounting.
    • Per-Peer RPC Rate Limiting (PeerRpcRateLimiter, 2,048-peer LRU): Token-bucket throttling before disk/Merkle reads (Audit: 30 burst, 5/s; Get: 64 burst, 30/s; [[economy.trusted_accounts]] exempted), returning RemoteError::ResourceUnavailable (treated by Sentinel as unreachable without -10 corruption penalty).
  • Bounded Framing: /backdit/placement-stream/1.0.0 (BKDTNET1) caps control frames at 256 KiB (MAX_FRAME_BYTES = 262,144) and enforces 120s replay windows (30s future skew). postcard decoders enforce pre-decode byte caps and trailing-byte checks.
  • Signaling-Only Relays: Bootstrap/Seed relays limit circuits to 256 KiB / 120s (256 reservations, 64 circuits) so bulk shards never amplify relay bandwidth.
  • Anti-Sybil Placement Diversity: open uploads (under BackupPolicy::IndependentHosts) require 14 distinct AccountIds, prefer diverse observed ConnectedPoint connection networks, and cap public subnets at <= 2 shards per IPv4 /24 or IPv6 /48 (bypassed on loopback/private clusters when allow_local_network = true, with Relayed connections bucketed separately).
  • Local HTTP API Hardening: Binds 127.0.0.1:9011 by default, validates a 32-byte Bearer token (api_token) in constant time, supports one-time #code= launch exchange (60s TTL), enforces same-origin CORS + script-src 'self' CSP + X-Frame-Options: DENY, and keeps /healthz secret-free.
  1. Unaudited Cryptography & Codebase: No independent third-party audit has been completed yet.
  2. Cold-Recovery Eclipse / Rollback: If an attacker eclipses all reachable DHT providers and serves an older valid signed capsule, the clean machine cannot distinguish withholding from propagation lag without operator review of capsule_sequence and confirming_hosts (or an offline backdit recovery export).
  3. Local Wall-Clock Trust in Bilateral Accounting: balance_byte_seconds relies on local wall-clock time (dt clamped to 6h, rollback rebased). Extreme clock manipulation or DB loss without capsules alters local ledger views.
  4. Multi-Subnet Sybil Cost (open Mode): Single-subnet /24 and /48 starter-pool, capsule, connection, and Kademlia caps limit single-block amplification, and PeerRpcRateLimiter bounds Audit/Get bursts, but coordinated attackers across many rented /24//48 blocks or same-ASN hosts remain out of scope for v0.1.0 (targeted for v0.2.0). Use friends_only for strict high-trust circles.
  5. Loopback Exposure: If setting BACKDIT_API_BIND=0.0.0.0 inside Docker, always publish 127.0.0.1:9011:9011 or place it behind an authenticated TLS reverse proxy.
Threat Protection in v0.1.0 Residual Limit
Curious host reading backups Client Zstd + XChaCha20-Poly1305 (file_root) + encrypted PackIndex. Host observes approximate shard size and timing; pair with Restic/Borg/Kopia for outer wrapping.
Uploader pushing raw unsealed bytes or flooding capsules/dust HPKE Proof-of-Possession + RFC 9180 HPKE sealing in LockedBuffer RAM before disk write; /24//48 512 MiB starter cap, 4-account/1% (32-512 MiB) unbacked capsule cap, 256-object/64 KiB dust floor, and PeerRpcRateLimiter. Multi-subnet rented botnets and ASN diversity remain open for v0.2.0; use friends_only to restrict uploaders completely.
Lazy host discarding shards 64 KiB-block Merkle Proof-of-Storage + bounded full-fetch checks (-10 penalty + repair). Healthy stripes (12-13 shards) wait 24h grace before replacement.
Local path leakage to swarm TABLE_LOCAL_SOURCES stays in local redb, omitted from Recovery Capsules. Full-disk encryption (LUKS/BitLocker) protects local machine state at rest.
download-local overwriting Backdit keys/DB Canonical path guard blocks data_dir, chunks_dir, and config directory (403 Forbidden). Explicit overwrite = true can overwrite non-Backdit files in allowed folders.
Browser CSRF / XSS / DNS rebinding on :9011 127.0.0.1 bind, constant-time Bearer token, same-origin CORS, strict CSP, X-Frame-Options: DENY. Any local process able to read api_token controls the daemon.
Relay traffic amplification Signaling-only Circuit Relay v2 (256 KiB / 120s, 64 circuits). Relays still handle small control handshakes.
Malformed frames / panics MAX_FRAME_BYTES = 262,144, bounded postcard, #![deny(clippy::unwrap_used, panic)] in prod. Software is unaudited alpha; fuzz coverage lives in tests/protocol_fuzzing_test.rs.