Skip to content

security(wallet): password API accepts &str — caller cannot zeroize original allocation #221

Description

@AlphaB135

Severity: HIGH

Location

crates/wallet/src/keystore.rs line 886, crates/wallet/src/backup.rs line 107

Description

Public API functions accept passwords as &str. The caller's original String, readline buffer, or stack frame cannot be zeroed by this library — the plaintext password persists in heap allocations, CLI readline buffers, and stack frames across the process lifetime.

Fix

Accept SecretString or Zeroizing<String> at the API boundary:

use secrecy::{SecretString, ExposeSecret};

pub fn encrypt_keystore(data: &[u8], password: &SecretString) -> Result<EncryptedKeystore> {
    let pass = password.expose_secret().as_bytes();
    // password is automatically zeroized when SecretString is dropped
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions