Technical Architecture • Vault Format v4

SpyVault™ Security Architecture

An engineering specification of SpyVault's cryptographic key hierarchy, memory isolation, hardware-bound biometrics, Google Drive synchronization protocol, and explicit operating-system boundaries—written without marketing fluff or security theater.

Release: v1.0.40 Core Engine: Rust 2021 KDF: Argon2id (64 MiB, t=3, p=1) AEAD: Dual-Layer XChaCha20-Poly1305

1. Design Philosophy & Explicit Threat Boundaries

SpyVault is built around a single shared Rust library (spyvault-core) compiled natively into an egui desktop binary on Windows, macOS, and Linux, a Kotlin/JNI application on Android, and a Swift/UniFFI application on iOS. Digital Graffiti LLC operates zero servers, zero user databases, and zero telemetry endpoints.

Every security control in SpyVault is evaluated against an adversary who possesses stolen copies of all encrypted local files (local_vault.enc, backups, token caches), full read/write access to your Google Drive appDataFolder, unprivileged local multi-user access on shared systems, and complete knowledge of SpyVault's source code.

Explicit Out-of-Scope Boundaries (Zero Security Theater) No client-side application can defeat an already-compromised operating system while unlocked. SpyVault explicitly treats the following as outside software-only guarantees: (1) malware, rootkits, or same-UID code running on the host while the vault is unlocked; (2) hardware or OS keyloggers; (3) cold-boot physical RAM extraction or unencrypted OS hibernation images (always enable FileVault, BitLocker, or LUKS full-disk encryption); (4) weak user-chosen passphrases; and (5) client-side subscription checks, which gate Google Drive sync convenience only and never touch vault cryptography or local access.

2. Vault Format v4 Cryptography & Key Hierarchy

All encryption, key derivation, and random number generation run exclusively in Rust using vetted primitives from the RustCrypto ecosystem and the OS CSPRNG (OsRng).

Step 1 • Input

Unicode NFC

Passphrase normalized via unicode-normalization so macOS (NFD) and Windows/Linux/Mobile (NFC) derive identical keys.

Step 2 • KDF

Argon2id v0x13

m = 64 MiB (65,536 KiB), t = 3, p = 1 with a 16-byte CSPRNG salt yielding a 256-bit SecretKey.

Step 3 • Separation

6 HKDF Subkeys

RFC 5869 §2.3 HKDF-Expand (SHA-256) derives independent 256-bit keys per cryptographic purpose.

Step 4 • Envelope

Dual AEAD + AAD

Two nested XChaCha20-Poly1305 layers (24-byte random nonces) with canonical binary AAD header binding.

Passphrase Policy & KDF Bounds

Vault creation and passphrase rotation enforce a minimum length of 10 characters and an offline zxcvbn strength score of ≥ 3 (evaluated over the first 128 UTF-8 characters). Before allocating KDF memory on unlock, outer JSON envelope parameters are strictly validated (algorithm == "argon2id", m_cost: 19,456..=262,144 KiB, t_cost: 2..=6, p_cost: 1..=4) to prevent resource-exhaustion or downgrade attacks from crafted files. Legacy v2 and v3 vaults remain readable and automatically upgrade to v4 on passphrase unlock; unknown future versions (format_version > 4) fail closed without overwriting local or cloud files.

Domain-Separated HKDF-SHA256 Subkeys

HKDF Info Label Protected Artifact Security Role
spyvault-vault-outer-v4 local_vault.enc / SpyVault_data.enc Outer XChaCha20-Poly1305 AEAD payload with canonical binary AAD binding format version, salt, and KDF parameters.
spyvault-entry-pw-v4 encrypted_password_b64 (per entry) Inner per-entry XChaCha20-Poly1305 encryption so passwords stay ciphertext in RAM while the vault is unlocked.
spyvault-base-snapshot-v4 local_vault.base.enc Encrypted last-synced ancestor snapshot for automatic offline 3-way merge, paired with SHA-256 digests in local_state.enc.
spyvault-local-state-v1 local_state.enc Authenticated per-install high-water mark (max_serial), prior_salts, and verified Drive sync checkpoints.
spyvault-token-cache-v4 tokencache.enc (Desktop) Encrypts Google OAuth refresh/access tokens with v4 binary AAD so tampered outer headers are rejected.
spyvault-dedupe-v1 In-memory HMAC-SHA256 Keyed in-memory duplicate-entry detection during imports without exposing unkeyed password hashes.

Canonical Binary AAD Header Binding

Outer v4 vault envelopes and desktop token caches authenticate unencrypted JSON header fields inside XChaCha20-Poly1305 Additional Authenticated Data using an unambiguous, length-prefixed little-endian binary encoding: u32_le(domain.len) ∥ domain ∥ u32_le(format_version) ∥ u32_le(salt.len) ∥ salt ∥ u32_le(alg.len) ∥ alg ∥ u32_le(m_cost) ∥ u32_le(t_cost) ∥ u32_le(p_cost). Any tampering with KDF parameters, salt, or format version causes immediate AEAD tag rejection.

3. Process & Memory Hardening

  • Page-Isolated, Swap-Locked Master Key (SecretKey): The 32-byte master key is stored in a dedicated OS virtual memory page allocated via mmap (Unix) or VirtualAlloc (Windows)—never on the general Rust heap where allocator reallocations can leave copies behind. The page is locked against OS swap paging (mlock / VirtualLock), excluded from crash dumps (MADV_DONTDUMP on Linux, WerRegisterExcludedMemoryBlock on Windows), and volatile-zeroed before unlocking and unmapping.
  • Process Dump Prevention: On startup, Unix builds set RLIMIT_CORE = 0 and Linux builds set PR_SET_DUMPABLE = 0 to restrict ptrace attachment by non-root same-user processes and suppress core dumps.
  • Zeroizing JSON Engine (serde_json_zeroize): SpyVault maintains a dedicated first-party fork of serde_json that zeroizes internal parse/serialize scratch buffers on drop, paired with Zeroizing<T> wrappers on passphrases, KDF blocks, and decrypted passwords.
  • On-Demand Password Decryption: Unlocking the vault decrypts the outer structure (titles, usernames, URLs, notes, folder hierarchy), while individual passwords remain encrypted under spyvault-entry-pw-v4 until a single entry is explicitly revealed, copied, or edited.
Desktop vs. Mobile Managed-Heap Nuance On Windows, macOS, and Linux, the entire UI is pure Rust (egui), avoiding garbage-collected string heaps completely. On Android (JVM) and iOS (Swift), the master key remains inside page-locked Rust memory guarded by monotonic LOCK_EPOCH counters, and on-demand password reads return wipeable char[] (Android) or Data (iOS) buffers. However, while unlocked on mobile, entry metadata (titles, usernames, URLs, notes) and transient SwiftUI text/reveal views reside in managed runtime memory until reclaimed by GC/ARC.

4. Hardware-Bound Biometrics (Zero Passphrase Escrow)

SpyVault strictly refuses to store your Master Passphrase in software credential managers. Biometric enrollment is offered only where hardware-backed cryptographic key residency is enforced:

  • Apple Secure Enclave (iOS & macOS): Wraps a 50-byte key bundle (master_key, kdf_params) using a non-exportable P-256 ECIES key inside the Secure Enclave bound with .biometryCurrentSet, device passcode presence, and kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly.
  • Android StrongBox & Hardware TEE: Wraps the key bundle under an AES-256-GCM key in StrongBox or the hardware Trusted Execution Environment (BIOMETRIC_STRONG, per-use authentication, setUnlockedDeviceRequired(true), invalidated on new biometric enrollment). SpyVault inspects KeyInfo hardware residency at runtime and refuses software-backed keys.
  • Windows & Linux: Biometric unlock is intentionally omitted rather than falling back to OS-password-recoverable software keychains.

5. Endpoint, Persistence & Self-Destruct Controls

  • Ownership-Checked Clipboard Scrubbing: Copied secrets are tagged to exclude OS clipboard history and cloud clipboard sync (Windows ExcludeClipboardContentFromMonitorProcessing + CanIncludeInClipboardHistory=0 + CanUploadToCloudClipboard=0; macOS org.nspasteboard.ConcealedType + TransientType + AutoGeneratedType + LocalOnly; Android ClipDescription.EXTRA_IS_SENSITIVE; iOS localOnly + hardware expiration). After the configurable timeout (default 30 s, range 5–300 s), SpyVault verifies clipboard sequence/SHA-256 ownership before clearing so newer copies from other apps are untouched.
  • Screen-Capture & App-Switcher Protection: Window capture exclusion is enabled by default (WDA_EXCLUDEFROMCAPTURE on Windows, NSWindowSharingNone on macOS, FLAG_SECURE on Android, and privacy blur shields on iOS app switching and UIScreen.isCaptured). Note that macOS 15+ user-consented ScreenCaptureKit sessions and Linux Wayland/X11 compositors lack universal app-enforced window exclusion.
  • Atomic File Permissions & Opt-In Mobile Backups: Vault files are written to sibling temporary files with 0600 permissions inside 0700 directories (NSFileProtectionComplete on iOS), flushed with sync_all, and atomically renamed. Android Auto Backup and iOS iCloud Backup are disabled by default; opting in strictly allow-lists local_vault.enc only (never biometric blobs or token caches).
  • 5-Attempt Self-Destruct vs. Portable USB Lockout: On installed desktop and mobile apps, 5 consecutive failed passphrase attempts in a running session remove the local vault, token cache, and biometric enrollment to stop unattended live guessing (any Google Drive copy remains intact). In Desktop Portable USB Mode—where no cloud backup exists—the 5th failed attempt locks out the running process without deleting local_vault.enc from the flash drive.
  • Untrusted Input Hardening: CSV imports (capped at 64 MiB / 100,000 rows) and Password Safe .psafe3 imports (capped at 64 MiB, 16 MiB per field, 10,000,000 KDF iterations) execute on cancellable worker threads with intermediate record zeroization. Folder depth is bounded iteratively to MAX_FOLDER_DEPTH = 16, and URL launching permits only well-formed http / https URLs with no embedded credentials or control characters.

6. Zero-Server Cloud Sync, 3-Way Merge & Rollback Detection

Optional cloud sync writes ciphertext directly to your personal Google Drive's hidden appDataFolder using OAuth 2.0 + PKCE (S256) and constant-time state verification over a temporary 127.0.0.1 loopback listener on desktop (or native Google Sign-In on Android/iOS). SpyVault requests only the narrow https://www.googleapis.com/auth/drive.appdata scope—it cannot list, read, or modify any regular files in your Google Drive.

  • Fail-Closed Checkpoint Verification: Remote ETag fast-path checks succeed only when local_state.enc decrypts under spyvault-local-state-v1 and matches the local vault's serial number, salt, and last-synced revision. Missing or tampered state fails closed to a full bounded download (capped at 64 MiB, with pre- and post-stream revision verification) and AEAD decryption check.
  • Deterministic Entry-Level 3-Way Merge: Using the encrypted last-synced ancestor snapshot (local_vault.base.enc), SpyVault automatically merges concurrent offline edits across devices: disjoint additions, edits, and deletions combine cleanly; edit-vs-delete preserves the modified entry; and conflicting edits to the same entry retain the newer edit alongside a visible <Title> (Conflict Copy) sibling while saving encrypted .conflict-* backups.
  • Rollback & Remote Re-Key Protection: Monotonic max_serial high-water marks in local_state.enc detect if a compromised cloud account replays an older vault snapshot—or if another device changed the Master Passphrase (REMOTE_REKEYED). In either case, SpyVault stages the remote envelope as .pending_remote, blocks background uploads at the core layer so cloud data cannot be overwritten accidentally, and prompts you explicitly. Because no vendor server exists to maintain global state, rollback detection applies to devices that have previously observed the newer state (fresh installs cannot detect a prior Drive-side rollback on their own).

7. Threat Model Summary

Threat Scenario Status Controls & Architectural Notes
Stolen vault file, USB drive, or Google Drive account Mitigated Dual XChaCha20-Poly1305 AEAD layers under Argon2id (64 MiB, t = 3) + binary AAD.
Offline passphrase brute-force Mitigated Memory-hard Argon2id cost + creation policy (≥10 chars, zxcvbn ≥ 3); bounded by passphrase entropy.
Tampered header, KDF downgrade, or hostile import Mitigated Binary AAD binds version/salt/KDF; strict KDF bounds; size/iteration caps on CSV & .psafe3.
Biometric credential extraction Mitigated Zero passphrase escrow; Secure Enclave / StrongBox hardware key wrapping with residency check.
OAuth interception or over-broad Drive access Mitigated Loopback PKCE S256, CSPRNG state, and isolated drive.appdata scope.
Stale device overwriting a re-keyed cloud vault Mitigated Salt-generation tracking, core upload hold (.pending_remote), and explicit adopt/keep flow.
Desktop RAM swap or crash-dump disclosure Hardened mlock/VirtualLock isolated key page, dump exclusion, RLIMIT_CORE = 0 (use OS FDE for hibernation).
Clipboard & screen-capture snooping Hardened OS history/cloud exclusion hints, ownership-checked 30s clear, and window capture exclusion where OS permits.
Drive-side replay / rollback attack Detected High-water mark in local_state.enc halts sync on initialized devices; fresh installs have no prior state.
Active malware running as user while unlocked Out of Scope Same-UID / root code execution while unlocked compromises any local application.

8. Supply-Chain Integrity & Sandboxed Verification

Every SpyVault release binary across macOS, Windows, Linux, Android, and iOS passes mandatory automated build gates before packaging:

  • Pinned Reproducible Dependencies: Cargo.lock is committed and every release script builds with --locked. Unknown crate registries and unapproved Git sources are blocked by deny.toml (the sole Git dependency is Digital Graffiti's own revision-pinned serde_json_zeroize repository).
  • Zero Unresolved Advisories & Warnings: Release pipelines enforce cargo deny check (advisories, licenses, bans, sources), cargo audit --deny warnings, and cargo clippy --locked --workspace --all-targets --no-deps -- -D warnings.
  • Confined System Font Loading: Desktop fallback fonts for international scripts load strictly from hardcoded read-only OS system directories (/System/Library/Fonts, Windows \Fonts, /usr/share/fonts) with canonical path confinement, O_NOFOLLOW regular-file verification, and memory caps.
  • 100% Sandboxed Test Suites: All Rust unit/integration tests and mobile bridge tests execute under isolated temporary directories (test-sandbox) with mocked clipboard and Keychain backends, ensuring test runs can never touch live user vaults.