SPB Git

Repository Public

memory-hygiene-services.json 7.5 KB 136 lines json

1{2  "reviewer": "manual source review (REVIEW-B)",3  "date": "2026-12-04",4  "statement": "Swift gives no control over copies of value types: `SecureMemory.zero` clears the named buffer, not the copies the compiler or the runtime may have made, and String contents cannot be cleared at all. The ratings below are the residual risk for an attacker able to read process memory (debugger on a jailbroken device, memory dump, swap is not used on iOS). No secret was found in logs, error values, UserDefaults or the pasteboard in the modules reviewed.",5  "entries": [6    {7      "secret": "Vault master key",8      "location": "Sources/QyvoraVault/Vault.swift:158",9      "representation": "SecretBytes (manually allocated, mlock best effort, memset_s in deinit); copies handed to operations as [UInt8] and zeroed with defer",10      "wiping": "wiped",11      "residual_risk": "low",12      "note": "Each operation works on an array copy that is zeroed on exit; the Swift runtime may have made further copies (copy-on-write, value captures) that are not tracked."13    },14    {15      "secret": "Vault password and PIN",16      "location": "Sources/QyvoraVault/Vault.swift:228",17      "representation": "Swift String parameters (`password`, `pin`, `current`, `new`), converted to NFKD UTF-8 bytes passed as temporaries",18      "wiping": "not wiped",19      "residual_risk": "medium",20      "note": "String storage cannot be overwritten and the UTF-8 temporaries given to KeyStretching are not named, hence not zeroed. The values stay in freed heap memory until reused. The same holds for the backup password (BackupFile.deriveKey zeroes its own byte copy, not the String)."21    },22    {23      "secret": "Key-encryption keys, Argon2 and PBKDF2 outputs, HKDF subkeys",24      "location": "Sources/QyvoraVault/VaultCrypto.swift:265",25      "representation": "[UInt8] locals",26      "wiping": "wiped",27      "residual_risk": "low",28      "note": "a, b, ikm, kek, record and MAC subkeys are zeroed with defer. CryptoKit SymmetricKey copies are managed by CryptoKit."29    },30    {31      "secret": "Device key and PIN device secret",32      "location": "Sources/QyvoraVault/Vault.swift:276",33      "representation": "[UInt8] read from the Keychain",34      "wiping": "wiped",35      "residual_risk": "low",36      "note": "Zeroed with defer; the Data returned by the Keychain API is not under the wallet's control."37    },38    {39      "secret": "Decrypted vault records (VaultRecord.payload)",40      "location": "Sources/QyvoraVault/VaultFile.swift:73",41      "representation": "immutable [UInt8] inside a struct returned to callers",42      "wiping": "partly wiped",43      "residual_risk": "medium",44      "note": "The struct member is a `let`: holders can zero only their own copy. WalletService copies the phrase and passphrase payloads into variables it zeroes (withMasterKey), but the record values returned by Vault.records live until released."45    },46    {47      "secret": "Recovery phrase as words",48      "location": "Sources/QyvoraWallet/WalletService.swift:260",49      "representation": "[String] from PhraseCodec.words, String from String(decoding:)",50      "wiping": "not wiped",51      "residual_risk": "medium",52      "note": "BIP39.seed needs the words as Strings; createWallet and revealRecoveryPhrase return [String] to the interface by design. Strings cannot be zeroed. BIP39.entropy / mnemonic zero their bit buffers and entropy."53    },54    {55      "secret": "BIP-39 seed",56      "location": "Sources/QyvoraWallet/WalletService.swift:260",57      "representation": "[UInt8]",58      "wiping": "wiped",59      "residual_risk": "low",60      "note": "Zeroed with defer in withMasterKey, install, restore and RecoverySheet.make."61    },62    {63      "secret": "Extended private keys (ExtendedKey)",64      "location": "Sources/QyvoraCore/HD/BIP32.swift:97",65      "representation": "struct with immutable [UInt8] members (`privateKey`, `chainCode`)",66      "wiping": "not wiped",67      "residual_risk": "medium",68      "note": "The master key and every intermediate key of a derivation path are values with `let` members: they cannot be zeroed and are released to the allocator as they are. HMAC outputs and derivation inputs inside derive() are zeroed. A wipeable key type (class with deinit, as SecretBytes) would remove this residue."69    },70    {71      "secret": "Signing keys (Bitcoin, Ethereum)",72      "location": "Sources/QyvoraBitcoin/Account.swift:265",73      "representation": "[UInt8] copy of ExtendedKey.privateKey",74      "wiping": "copy wiped",75      "residual_risk": "medium",76      "note": "The copy used for signing is zeroed with defer; the ExtendedKey it was read from is not (previous item)."77    },78    {79      "secret": "WIF payload",80      "location": "Sources/QyvoraBitcoin/Encoding.swift:198",81      "representation": "[UInt8]",82      "wiping": "partly wiped",83      "residual_risk": "low",84      "note": "The Base58Check payload is zeroed; the returned key and the text are the caller's."85    },86    {87      "secret": "Identity private keys",88      "location": "Sources/QyvoraIdentity/Identity.swift:306",89      "representation": "struct with immutable [UInt8] members (ML-DSA, SLH-DSA, ML-KEM, X25519 private keys)",90      "wiping": "not wiped",91      "residual_risk": "medium",92      "note": "Identity values are loaded from the vault for each operation and cannot be zeroed; the private encoding buffer is zeroed after storage. WalletService keeps `transferIdentity` in memory between the two steps of a transfer reception."93    },94    {95      "secret": "Hybrid envelope secrets",96      "location": "Sources/QyvoraIdentity/HybridEnvelope.swift:191",97      "representation": "[UInt8] (ephemeral X25519 private key, both shared secrets, payload key, HKDF input)",98      "wiping": "wiped",99      "residual_risk": "low",100      "note": "Zeroed with defer. The CryptoKit key objects created from them are managed by CryptoKit."101    },102    {103      "secret": "Backup plaintext",104      "location": "Sources/QyvoraRecovery/BackupFile.swift:171",105      "representation": "[UInt8]",106      "wiping": "wiped",107      "residual_risk": "low",108      "note": "The assembled plaintext and the key are zeroed; the ByteWriter that built the plaintext and the per-record bodies are separate arrays that are not."109    },110    {111      "secret": "Recovery sheet with private material",112      "location": "Sources/QyvoraRecovery/RecoverySheet.swift:90",113      "representation": "Codable struct holding the phrase and passphrase as String, JSON and plain-text renderings",114      "wiping": "not wiped",115      "residual_risk": "high (by design, opt-in)",116      "note": "Produced only when includePrivateMaterial is requested; whoever holds the value, its JSON or its text holds the funds. The interface must treat it like the phrase itself (no logging, no pasteboard without expiry, no screenshot)."117    },118    {119      "secret": "Secure Enclave wrapping",120      "location": "Sources/QyvoraStorage/SecureEnclaveKey.swift:121",121      "representation": "private key inside the Secure Enclave; opaque handle in the Keychain",122      "wiping": "not applicable",123      "residual_risk": "low",124      "note": "The private key never enters process memory. The inner blob (nonce and wrapped master key) is ciphertext."125    },126    {127      "secret": "Profile and caches",128      "location": "Sources/QyvoraWallet/WalletService.swift:78",129      "representation": "plain JSON on disk (account public keys, addresses, labels, endpoints, price cache)",130      "wiping": "not secret",131      "residual_risk": "low",132      "note": "Public data only, but it reveals every address of the wallet to whoever reads the file: see QYV-SVC-011."133    }134  ]135}136
Files main
Menu

Theme