fix(mount): Z-01 — zeroize decoy password in memory
This commit is contained in:
+3
-2
@@ -158,9 +158,10 @@ pub async fn mount_container(
|
|||||||
println!(" [i] Der angegebene Notfallschlüssel gehört zum Hidden-Vault (Slot 1).");
|
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.");
|
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: ")
|
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(|| {
|
let decoy_keys = meta.authenticate(&decoy_pass).ok_or_else(|| {
|
||||||
anyhow::anyhow!("Ungültiges Passwort für Standard-Vault.")
|
anyhow::anyhow!("Ungültiges Passwort für Standard-Vault.")
|
||||||
})?;
|
})?;
|
||||||
|
|||||||
@@ -219,3 +219,27 @@ async fn test_vfs_memory_lock_retention_on_clone_v03() {
|
|||||||
let _ = std::fs::remove_file(&container_path);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user