From: Thomas Lamprecht <t.lamprecht@proxmox.com>
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 [thread overview]
Message-ID: <20261117234330.801935-7-t.lamprecht@proxmox.com> (raw)
In-Reply-To: <20261117234330.801935-1-t.lamprecht@proxmox.com>
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 <t.lamprecht@proxmox.com>
---
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:
<INPUT> Path to the ISO to inspect.
OPTIONS:
- --show-sensitive Print sensitive fields (root password, subscription key,
- HTTP auth token) verbatim instead of as <redacted>.
+ --show-sensitive Print sensitive fields (root password, disk passphrase,
+ subscription key, HTTP auth token) verbatim instead of
+ as <redacted>.
-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<String> {
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<CdInfo> {
#[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
next prev parent reply other threads:[~2026-11-17 23:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 23:42 [PATCH proxmox/installer/docs 0/8] installer: add full-disk encryption of the system disks Thomas Lamprecht
2026-11-17 23:42 ` [PATCH proxmox 1/1] installer-types: add full-disk encryption to the disk setup Thomas Lamprecht
2026-11-17 23:42 ` [PATCH installer 1/5] install: encrypt the system disks with LUKS2 or native ZFS encryption Thomas Lamprecht
2026-11-17 23:42 ` [PATCH installer 2/5] auto: support full-disk encryption in answer files Thomas Lamprecht
2026-11-17 23:42 ` [PATCH installer 3/5] chroot enter: unlock the LUKS containers of an encrypted installation Thomas Lamprecht
2026-11-17 23:42 ` [PATCH installer 4/5] ui: offer full-disk encryption in the graphical and terminal installer Thomas Lamprecht
2026-11-17 23:42 ` Thomas Lamprecht [this message]
2026-11-17 23:42 ` [PATCH docs 1/2] installation: describe full-disk encryption Thomas Lamprecht
2026-11-17 23:42 ` [PATCH docs 2/2] local-zfs: update the limitations of native encryption Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261117234330.801935-7-t.lamprecht@proxmox.com \
--to=t.lamprecht@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox