Skip to content

Harden wallet security - #8

Open
pinebit wants to merge 1 commit into
octra-labs:mainfrom
pinebit:secure-destruct
Open

Harden wallet security#8
pinebit wants to merge 1 commit into
octra-labs:mainfrom
pinebit:secure-destruct

Conversation

@pinebit

@pinebit pinebit commented Apr 6, 2026

Copy link
Copy Markdown

Summary

Security hardening for sensitive memory handling across the wallet codebase.

  • Zero sensitive strings in Wallet destructorpriv_b64, pub_b64, master_seed_b64, and mnemonic are now wiped on destruction, not just sk/pk
  • Zero decoded key material — all base64_decode results containing private keys are zeroed after use (including on error paths) in load_wallet_encrypted, load_wallet_legacy, import_wallet, and recover_hd_index
  • Zero JSON-internal copies — sensitive fields inside the parsed JSON object are zeroed via get_ref<string&>() before the object is destroyed
  • Secure file removal — legacy plaintext wallet is now overwritten with zeros before unlinking (secure_remove)
  • Zero crypto intermediates — ECDH raw shared secret (stealth.hpp), Ed25519-to-Curve25519 hash (crypto_utils.hpp), and PVAC keygen seed/decoded key (pvac_bridge.hpp)
  • Platform-native secure_zero — uses SecureZeroMemory (Windows), memset_s (macOS), or explicit_bzero (glibc 2.25+) instead of a volatile loop that compilers may optimize away; inspired by Bitcoin Core https://raw.githubusercontent.com/bitcoin/bitcoin/master/src/support/cleanse.h
  • Compiler hardening flags — added -Wextra, -Werror=format-security, -Wshadow globally; suppressed vendored code warnings for tweetnacl and pvac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant