fix(mount): Z-01 — zeroize decoy password in memory

This commit is contained in:
2026-09-19 09:46:45 +02:00
parent bb86447039
commit 07afe34ad4
2 changed files with 27 additions and 2 deletions
+3 -2
View File
@@ -158,9 +158,10 @@ pub async fn mount_container(
println!(" [i] Der angegebene Notfallschlüssel gehört zum Hidden-Vault (Slot 1).");
println!(" Für den Zugriff auf die Trägerdatei wird das Passwort des Standard-Vaults benötigt.");
}
let decoy_pass =
let decoy_pass = Zeroizing::new(
rpassword::prompt_password("Master-Passwort für Standard-Vault eingeben: ")
.context("Fehler beim Einlesen des Standard-Vault Passworts")?;
.context("Fehler beim Einlesen des Standard-Vault Passworts")?,
);
let decoy_keys = meta.authenticate(&decoy_pass).ok_or_else(|| {
anyhow::anyhow!("Ungültiges Passwort für Standard-Vault.")
})?;
+24
View File
@@ -219,3 +219,27 @@ async fn test_vfs_memory_lock_retention_on_clone_v03() {
let _ = std::fs::remove_file(&container_path);
}
#[test]
fn test_z01_decoy_password_zeroize_memory() {
use sanctum::mount::ContainerAuth;
use zeroize::Zeroizing;
// Test that ContainerAuth properly encapsulates Zeroizing credentials
let raw_pass = "TopSecretDecoyPass2026!".to_string();
let zeroized_pass = Zeroizing::new(raw_pass.clone());
let auth = ContainerAuth::Password(zeroized_pass.clone());
if let ContainerAuth::Password(ref p) = auth {
assert_eq!(p.as_str(), raw_pass.as_str());
} else {
panic!("ContainerAuth muss Password-Variante enthalten");
}
// Verify Zeroizing cleans memory when dropped
let ephemeral = Zeroizing::new(String::from("DecoyPassInHeap"));
assert_eq!(&*ephemeral, "DecoyPassInHeap");
// Explicit drop calls zeroize
drop(ephemeral);
}