From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id A61B01FF0C0 for ; Wed, 18 Nov 2026 00:44:16 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 69C91216E8; Wed, 18 Nov 2026 00:43:47 +0100 (CET) From: Thomas Lamprecht To: pve-devel@lists.proxmox.com Subject: [PATCH installer 5/5] assistant: keep the disk passphrase out of prepared ISOs Date: Wed, 18 Nov 2026 00:42:29 +0100 Message-ID: <20261117234330.801935-7-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261117234330.801935-1-t.lamprecht@proxmox.com> References: <20261117234330.801935-1-t.lamprecht@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1794959018582 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.193 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: MNQT56GMRDL2NMA4PFM7DZA56YARAYOP X-Message-ID-Hash: MNQT56GMRDL2NMA4PFM7DZA56YARAYOP X-MailFrom: t.lamprecht@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: prepare-iso refuses an answer file that enables full-disk encryption, as the ISO travels independently of the host it installs and every copy of it would carry the passphrase. Such answer files can still be fetched over the network, preferably over HTTPS, or read from a separate partition. inspect-iso redacts the encryption section, like it already does the root password. As the passphrase is all the section holds, it is redacted as a whole, also when it is malformed, for example with a misspelled key or a string in place of the section, as an ISO prepared by other means may contain. Signed-off-by: Thomas Lamprecht --- proxmox-auto-install-assistant/src/main.rs | 93 +++++++++++++++++++--- 1 file changed, 80 insertions(+), 13 deletions(-) diff --git a/proxmox-auto-install-assistant/src/main.rs b/proxmox-auto-install-assistant/src/main.rs index 931fd770..15fe3cea 100644 --- a/proxmox-auto-install-assistant/src/main.rs +++ b/proxmox-auto-install-assistant/src/main.rs @@ -490,8 +490,9 @@ ARGUMENTS: Path to the ISO to inspect. OPTIONS: - --show-sensitive Print sensitive fields (root password, subscription key, - HTTP auth token) verbatim instead of as . + --show-sensitive Print sensitive fields (root password, disk passphrase, + subscription key, HTTP auth token) verbatim instead of + as . -h, --help Print this help -V, --version Print version "#, @@ -765,6 +766,10 @@ const ANSWER_SENSITIVE_FIELDS: &[(&str, &[&str])] = &[ ("post-installation-webhook", &["auth-token", "auth_token"]), ]; +/// Answer-file sections that hold nothing but secrets, redacted as a whole whatever their shape, so +/// that a malformed one, like a misspelled key or a string in place of the section, is too. +const ANSWER_SENSITIVE_SECTIONS: &[&str] = &["disk-setup.encryption"]; + fn inspect_iso(args: &CommandInspectISOArgs) -> Result<()> { if !fs::exists(&args.input).context("checking if input ISO exists")? { bail!("input ISO {:?} does not exist", args.input); @@ -909,23 +914,43 @@ fn format_answer_toml(content: &str, redact: bool) -> Result { let mut value: toml::Value = parse_answer_toml(content).context("parsing answer file as TOML")?; if redact { + let redacted = || toml::Value::String(REDACTED.to_string()); for (section, keys) in ANSWER_SENSITIVE_FIELDS { - let Some(table) = value.get_mut(*section).and_then(|v| v.as_table_mut()) else { - continue; - }; for key in *keys { - if table.contains_key(*key) { - table.insert( - (*key).to_string(), - toml::Value::String(REDACTED.to_string()), - ); - } + let path: Vec<&str> = section.split('.').chain([*key]).collect(); + redact_answer_value(&mut value, &path, &|value| *value = redacted()); } } + for section in ANSWER_SENSITIVE_SECTIONS { + let path: Vec<&str> = section.split('.').collect(); + redact_answer_value(&mut value, &path, &|value| match value.as_table_mut() { + Some(table) => table.iter_mut().for_each(|(_, value)| *value = redacted()), + None => *value = redacted(), + }); + } } Ok(toml::to_string_pretty(&value)?) } +/// Calls `redact` on the value at `path`, also within arrays along it, as for a section that was +/// given as an array of tables. +fn redact_answer_value(value: &mut toml::Value, path: &[&str], redact: &impl Fn(&mut toml::Value)) { + if let toml::Value::Array(items) = value { + for item in items { + redact_answer_value(item, path, redact); + } + return; + } + match path.split_first() { + None => redact(value), + Some((part, rest)) => { + if let Some(value) = value.get_mut(*part) { + redact_answer_value(value, rest, redact); + } + } + } +} + fn prepare_iso(args: &CommandPrepareISOArgs) -> Result<()> { check_prepare_requirements(args)?; let uuid = get_iso_uuid(&args.input)?; @@ -982,7 +1007,14 @@ fn prepare_iso(args: &CommandPrepareISOArgs) -> Result<()> { if let Some(file) = &args.answer_file { println!("Checking provided answer file..."); - parse_answer(file)?; + let answer = parse_answer(file)?; + // the ISO travels independently of the host it installs + if answer.disks.encryption.is_some() { + bail!( + "Cannot embed an answer file with a disk passphrase, as every copy of the ISO \ + would contain it. Use '--fetch-from http' or '--fetch-from partition' instead." + ); + } } let iso_target = final_iso_location(args)?; @@ -1694,9 +1726,44 @@ fn parse_cd_info(raw_cd_info: &str) -> Result { #[cfg(test)] mod tests { - use super::{CdInfo, PXE_BOOT_OPTIONS, boot_option_params, parse_cd_info}; + use super::{CdInfo, PXE_BOOT_OPTIONS, boot_option_params, format_answer_toml, parse_cd_info}; use anyhow::Result; + #[test] + fn redacts_disk_encryption_passphrase() -> Result<()> { + let answer = r#" +[global] +root-password = "rootsecret" + +[disk-setup] +filesystem = "ext4" + +[disk-setup.encryption] +passphrase = "disksecret" +"#; + let redacted = format_answer_toml(answer, true)?; + for secret in ["rootsecret", "disksecret"] { + assert!(!redacted.contains(secret), "{secret} leaked:\n{redacted}"); + } + assert!(redacted.contains("filesystem = \"ext4\""), "{redacted}"); + assert!(format_answer_toml(answer, false)?.contains("disksecret")); + + // malformed sections, as an ISO prepared by other means may contain + for answer in [ + "[disk-setup]\nencryption = \"disksecret\"\n", + "[[disk-setup.encryption]]\npassphrase = \"disksecret\"\n", + "[disk-setup.encryption]\npasphrase = \"disksecret\"\n", + "[[disk-setup]]\n[disk-setup.encryption]\npassphrase = \"disksecret\"\n", + "[[global]]\nroot-password = \"rootsecret\"\n", + ] { + let redacted = format_answer_toml(answer, true)?; + for secret in ["rootsecret", "disksecret"] { + assert!(!redacted.contains(secret), "{secret} leaked:\n{redacted}"); + } + } + Ok(()) + } + #[test] fn parse_cdinfo() -> Result<()> { let s = r#" -- 2.47.3