feat(core): zeroize the profile/loc signing copy and the TUI passphrase buffer #47
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/zeroize-tui-profile"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
Follow-up to #46 (and stacked on it — see Base below). #46 wrapped every secret its file scope allowed; two same-class copies were out of scope:
src/profile.rs::signstill built the Ed25519 identity secret into a bare[u8; 32]on the stack (try_into→SigningKey::from_bytes), a raw non-wiping copy of the identity secret.pay::sign_bytes/qr::encodehad the same fix in #46.src/tui.rsheld the in-progress backup/restore passphrase in a plainString(Screen::Passphrase { first, buf }), so the typed passphrase stayed in a non-wiping heap buffer for the life of the screen.What changed
profile / loc
profile::signing_key_bytes(identity_sk) -> Zeroizing<[u8; 32]>is the single place the raw 32-byte copy is made;sign()uses it. It writes withcopy_from_sliceinto aZeroizing<[u8; 32]>(rather thanZeroizing::new(<[u8; 32]>::try_from(..)?)as in #46) so noCopyarray temporary is left on the stack. Type + drop behaviour are the same as the #46 pattern.src/loc.rs::signmade the same raw copy and was not in this card's list. It now calls the shared helper instead of the third hand-rolledtry_intocopy. Flagged here because the card is titled "the remaining identity-secret copies" and this was a fourth one; revert that hunk if you want it as its own card.TUI
PassphraseEntryowns the two buffers asZeroizing<String>(the hidden buffer + the first-passphrase copy kept across the two-step backup prompt).Screen::Passphrasecarries it instead offirst: Option<String>/buf: String.PassphraseEntry::close()wipes both buffers (eager zeroize + drop of the first copy) and is called on every exit path:Esc(cancel),Enter(submit — success, mismatch, RPC error) and the mismatch path insidesubmit_passphrase.Zeroizing's drop is the backstop for the paths that cannot call it (Ctrl-Q, panic).take_buf/take_first) instead of cloned into two more plainStrings, so no extra non-wiping copy exists on the submit path.Evidence
tests/zeroize.rsreferencedprofile::signing_key_bytes→error[E0425]: cannot find function ... in module profile; thesrc/tui.rsunit tests referencedPassphraseEntry→error[E0433]: cannot find type PassphraseEntry in this scope.cargo test --locked→ 206 passed / 0 failed / 3 ignored (the 3 ignored are the live-Tor tests). New: 3 intests/zeroize.rs, 3 unit tests insrc/tui.rs.cargo clippy --locked --all-targets -- -D warnings→ clean.profile_signing_key_bytes_are_zeroizing_and_wipe— type-level&Zeroizing<[u8; 32]>binding plus aManuallyDrop+drop_in_place+read_volatiledrop probe asserting the buffer is all-zero after its drop (a plain drop(k) moves the value and zeroes the copy, not the original);profile_signing_key_bytes_rejects_a_short_secretcovers 31/33-byte inputs.passphrase_buffers_are_zeroizing— asserts the field types andZeroizing<String>: ZeroizeOnDrop.closing_the_passphrase_screen_wipes_the_typed_secret— types "hunter2-secret", captures the buffer pointer+capacity, calls the screen-close path, then reads the live allocation back and asserts every byte of the capacity is zero (Vec::zeroizezeroes the whole capacity and keeps the allocation, so this is not a read of freed memory).closing_the_passphrase_screen_drops_the_first_entry_copy— the two-step backup flow's first copy is gone after close.Still not covered (unchanged from #46's list, plus one new)
snow0.10 has no zeroize support: the Noise ephemeral + derived transport keys insideHandshakeState/TransportStatecannot be wiped without upstream work.src/file.rsbuffers.src/backup.rs::BackupKeys::from_bytesstill builds[u8; 32]field values viab[a..b].try_into().unwrap()— the sameCopy-temporary shape as the copy fixed here.BackupKeysitself isZeroizeOnDropand the input plaintext isZeroizing, so only the transient array is unwiped. Left alone deliberately:src/backup.rsis rewritten by the still-open #43/#46 chain and carving a hunk out of it here would collide in exactly that function.BackupPrompt,RotatePrompt,WipePrompt,QuitPrompt) stay plainStrings: they holdBACKUP/ROTATE/WIPE/QUIT, not secrets.Base
Branch is
origin/feat/zeroize-secrets(#46) +origin/mainmerged in + this commit, because the drop probes live intests/zeroize.rs, which #46 introduces; adding the probes to a file that #46 is still writing would have merged as a conflict. Base ismainper the card, so the diff shows #43/#46's commits until those land — then it collapses tof5576e7alone. Merge #43 → #46 first.Refs #46. No
mainpush.f5576e751be3be8ffdd0