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.
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.
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).
Unicode NFC
Passphrase normalized via unicode-normalization so macOS (NFD) and Windows/Linux/Mobile (NFC) derive identical keys.
Argon2id v0x13
m = 64 MiB (65,536 KiB), t = 3, p = 1 with a 16-byte CSPRNG salt yielding a 256-bit SecretKey.
6 HKDF Subkeys
RFC 5869 §2.3 HKDF-Expand (SHA-256) derives independent 256-bit keys per cryptographic purpose.
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 viammap(Unix) orVirtualAlloc(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_DONTDUMPon Linux,WerRegisterExcludedMemoryBlockon Windows), and volatile-zeroed before unlocking and unmapping. - Process Dump Prevention: On startup, Unix builds set
RLIMIT_CORE = 0and Linux builds setPR_SET_DUMPABLE = 0to restrictptraceattachment by non-root same-user processes and suppress core dumps. - Zeroizing JSON Engine (
serde_json_zeroize): SpyVault maintains a dedicated first-party fork ofserde_jsonthat zeroizes internal parse/serialize scratch buffers on drop, paired withZeroizing<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-v4until a single entry is explicitly revealed, copied, or edited.
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, andkSecAttrAccessibleWhenPasscodeSetThisDeviceOnly. - 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 inspectsKeyInfohardware 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; macOSorg.nspasteboard.ConcealedType+TransientType+AutoGeneratedType+LocalOnly; AndroidClipDescription.EXTRA_IS_SENSITIVE; iOSlocalOnly+ hardware expiration). After the configurable timeout (default30 s, range5–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_EXCLUDEFROMCAPTUREon Windows,NSWindowSharingNoneon macOS,FLAG_SECUREon Android, and privacy blur shields on iOS app switching andUIScreen.isCaptured). Note that macOS 15+ user-consentedScreenCaptureKitsessions 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
0600permissions inside0700directories (NSFileProtectionCompleteon iOS), flushed withsync_all, and atomically renamed. Android Auto Backup and iOS iCloud Backup are disabled by default; opting in strictly allow-listslocal_vault.enconly (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.encfrom the flash drive. - Untrusted Input Hardening: CSV imports (capped at
64 MiB/100,000rows) and Password Safe.psafe3imports (capped at64 MiB,16 MiBper field,10,000,000KDF iterations) execute on cancellable worker threads with intermediate record zeroization. Folder depth is bounded iteratively toMAX_FOLDER_DEPTH = 16, and URL launching permits only well-formedhttp/httpsURLs 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.encdecrypts underspyvault-local-state-v1and matches the local vault's serial number, salt, and last-synced revision. Missing or tampered state fails closed to a full bounded download (capped at64 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_serialhigh-water marks inlocal_state.encdetect 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.lockis committed and every release script builds with--locked. Unknown crate registries and unapproved Git sources are blocked bydeny.toml(the sole Git dependency is Digital Graffiti's own revision-pinnedserde_json_zeroizerepository). - Zero Unresolved Advisories & Warnings: Release pipelines enforce
cargo deny check(advisories, licenses, bans, sources),cargo audit --deny warnings, andcargo 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_NOFOLLOWregular-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.