From d5c06e9084c57e03dd578f369a273dfd016d5afd Mon Sep 17 00:00:00 2001
From: Garrett Allen <98648590+Gerrrt@users.noreply.github.com>
Date: Thu, 8 Oct 2026 20:12:34 -0700
Subject: [PATCH 1/3] fix(packer,lab): no plaintext build password left in
Panther on Windows clones (#1099)
C:\Windows\Panther\unattend-original.xml is Setup's untouched copy of the
build answer file. Read on all seven running Windows guests (2026-10-09), it
holds two password elements, both true, readable by
BUILTIN\Users. The check counted them and printed no value. It is created at
template build time, so 911 and 912 carried it into every clone.
Panther\unattend.xml beside it is scrubbed by Setup and stays.
- sysprep.ps1: the generated packer-sysprep.cmd deletes it as its last step
before sysprep /generalize.
- SetupComplete.cmd: deletes it again before a clone's first logon, and logs
whether it is gone.
- roles/base: removes it on every run (existing clones, and clones of
templates built before this). verify.yml asserts it is absent.
Checked on carbuncle without touching Panther: PowerShell's parser reads
sysprep.ps1 with 0 errors, and the new SetupComplete lines, run against a
temp folder, delete a present file and pass over an absent one.
Co-Authored-By: Claude Opus 5.5
---
ansible/roles/base/tasks/main.yml | 13 +++++++++++
ansible/verify.yml | 4 ++++
docs/changelog.md | 29 ++++++++++++++++++++++++
packer/windows/scripts/SetupComplete.cmd | 9 ++++++++
packer/windows/scripts/sysprep.ps1 | 9 ++++++++
5 files changed, 64 insertions(+)
diff --git a/ansible/roles/base/tasks/main.yml b/ansible/roles/base/tasks/main.yml
index 6e3c8018..15bb3de8 100644
--- a/ansible/roles/base/tasks/main.yml
+++ b/ansible/roles/base/tasks/main.yml
@@ -139,6 +139,19 @@
when: not domain_role_is_dc
no_log: true
+# What the template's build left behind (#1099): Setup's untouched copy of the
+# build's answer file, with the build password in plaintext, twice, readable by
+# BUILTIN\Users. It was on all seven Windows guests on 2026-10-09 (six domain
+# guests and dot-windows), created at template build time, so every clone of
+# a 911 or 912 built before #1099 inherited it. The password stops opening
+# the local Administrator once the task above has run, but the template reuses
+# it, so it is still worth reading on any guest this has not touched yet.
+# Panther\unattend.xml stays: Setup scrubbed its password.
+- name: Remove Setup's plaintext copy of the build answer file
+ ansible.windows.win_file:
+ path: C:\Windows\Panther\unattend-original.xml
+ state: absent
+
# What the template's build left behind (#846). Packer's WinRM ran over HTTPS on
# a self-signed certificate, FriendlyName packer-winrm, made in bootstrap.ps1.
# Templates built before #1031 left it on every clone, the same one on each
diff --git a/ansible/verify.yml b/ansible/verify.yml
index 207b7d24..f32604af 100644
--- a/ansible/verify.yml
+++ b/ansible/verify.yml
@@ -91,6 +91,10 @@
# sysprep. None on any guest either way.
$r['no packer-winrm certificate from the build'] = (@(Get-ChildItem -Path Cert:\LocalMachine\My |
Where-Object FriendlyName -eq 'packer-winrm').Count -eq 0)
+ # Setup's plaintext copy of the build answer file (#1099): roles/base
+ # removes it from a clone of a template built before #1099, and the
+ # template no longer carries it.
+ $r['no plaintext answer file in Panther'] = -not (Test-Path C:\Windows\Panther\unattend-original.xml)
# --- #450: Sysmon, recording with the vendored config ----------------
# The driver as well as the service: Sysmon64 running over an unloaded
# SysmonDrv records nothing. ConfigHash is what the driver last loaded,
diff --git a/docs/changelog.md b/docs/changelog.md
index c9eb874a..9cc0b134 100644
--- a/docs/changelog.md
+++ b/docs/changelog.md
@@ -17,6 +17,35 @@ roadmap as it read that day, and the *Done* entries keep the shape they had
there. `check_docs.py` does not check this file, for the reason its module
docstring gives: it is a record, not a claim about now.
+## 2026-10-09
+
+- **Windows clones no longer keep the build password in plaintext**
+ ([#1099](https://github.com/Gerrrt/HomeLab/issues/1099)). Not yet applied
+ to the running guests.
+ - **What was there.** All seven running Windows guests (the six domain
+ guests and dot-windows) had `C:\Windows\Panther\unattend-original.xml`,
+ readable by `BUILTIN\Users`. It held two password elements, both
+ `true`: the build's Administrator and AutoLogon.
+ The check counted elements and printed no value. `Panther\unattend.xml`
+ beside it has its password scrubbed by Setup.
+ - **Where it came from.** It was created during the template build, half an
+ hour before each clone's first boot, so it was baked into 911 and 912 and
+ inherited by every clone.
+ - **The fix, in three places:**
+ - the sysprep task deletes it as its last step before generalising, so a
+ rebuilt template no longer carries it;
+ - `SetupComplete.cmd` deletes it again before a clone's first logon,
+ logging whether it went;
+ - `roles/base` removes it on every run, and `verify.yml` holds every guest
+ to not having it.
+ - **Checked on carbuncle without touching Panther.** PowerShell's own parser
+ reads `sysprep.ps1` with 0 errors. The new `SetupComplete.cmd` lines, run
+ against a temp folder, delete a present file, and log a second run on an
+ absent one without failing.
+ - **Still to do.** Apply `roles/base` to the six, and remove it on
+ dot-windows, which is not in the Ansible inventory. 911 and 912 lose it
+ at their next rebuild.
+
## 2026-10-08
- **`eden` is built, and BloodHound CE is running on it** ([#451](https://github.com/Gerrrt/HomeLab/issues/451),
diff --git a/packer/windows/scripts/SetupComplete.cmd b/packer/windows/scripts/SetupComplete.cmd
index f60529a6..60db9728 100644
--- a/packer/windows/scripts/SetupComplete.cmd
+++ b/packer/windows/scripts/SetupComplete.cmd
@@ -67,6 +67,15 @@ sc.exe stop WinRM>> "%LOG%" 2>&1
del /q "%WINDIR%\Panther\unattend-oobe.xml">> "%LOG%" 2>&1
+rem Setup's untouched copy of an answer file, with its passwords in plaintext
+rem and readable by Users (#1099). The sysprep task deletes the build's before
+rem generalising; this is the backstop for a template built before that, and
+rem for any copy Setup writes on the clone itself. It runs before the first
+rem logon, so no user ever sees one.
+echo %TIME% Panther: delete unattend-original.xml>> "%LOG%"
+del /f /q "%WINDIR%\Panther\unattend-original.xml">> "%LOG%" 2>&1
+if exist "%WINDIR%\Panther\unattend-original.xml" (>> "%LOG%" echo %TIME% STILL PRESENT) else (>> "%LOG%" echo %TIME% gone)
+
rem What sysprep.ps1 left to run sysprep outside the build's WinRM session.
rem The task has no trigger and cannot run again, but it has no business in
rem a guest. packer-close-winrm.log stays: it is what the sysprep task did to
diff --git a/packer/windows/scripts/sysprep.ps1 b/packer/windows/scripts/sysprep.ps1
index a960db27..cd644978 100644
--- a/packer/windows/scripts/sysprep.ps1
+++ b/packer/windows/scripts/sysprep.ps1
@@ -104,11 +104,20 @@ if ($left) { exit 1 }
# The 30-second wait is ping, not timeout.exe, which fails without a console.
# SetupComplete.cmd deletes this file and the task on every clone, and the
# script above once it has run it.
+#
+# Panther\unattend-original.xml is Setup's untouched copy of the BUILD's answer
+# file, written while the template was installed: AdministratorPassword and
+# the build AutoLogon, both true, readable by Users
+# (#1099). Generalising keeps it, so every clone inherited it. It goes in the
+# last step before sysprep, once nothing else will run on the template.
+# Panther\unattend.xml stays: Setup scrubs its passwords, and sysprep reads
+# its own answer from unattend-oobe.xml, not from either.
$cmd = Join-Path $env:WINDIR 'Temp\packer-sysprep.cmd'
Set-Content -Path $cmd -Encoding ascii -Value @(
'@echo off'
'ping -n 31 127.0.0.1 >nul'
('powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "' + $close + '"')
+ 'del /f /q "%WINDIR%\Panther\unattend-original.xml"'
('"%WINDIR%\System32\Sysprep\sysprep.exe" /generalize /oobe /shutdown /quiet /unattend:' + $answer)
)
From c706a46b46d4553af3c2f465f0ebe2693141a62f Mon Sep 17 00:00:00 2001
From: Garrett Allen <98648590+Gerrrt@users.noreply.github.com>
Date: Thu, 8 Oct 2026 20:24:05 -0700
Subject: [PATCH 2/3] fix(lab): roles/base and verify.yml cover
unattend-oobe.xml too (#1099)
unattend-oobe.xml, the answer sysprep uses on a clone's first boot, carries
the build Administrator password in plaintext as well. SetupComplete.cmd
deletes it, but verify.yml checked only unattend-original.xml, so a failed
deletion would pass (review on #1102). roles/base now removes both, and the
check requires both absent. On carbuncle, where both are gone, the check's
expression evaluates True.
Co-Authored-By: Claude Opus 5.5
---
ansible/roles/base/tasks/main.yml | 11 ++++++++---
ansible/verify.yml | 9 +++++----
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/ansible/roles/base/tasks/main.yml b/ansible/roles/base/tasks/main.yml
index 15bb3de8..a6752670 100644
--- a/ansible/roles/base/tasks/main.yml
+++ b/ansible/roles/base/tasks/main.yml
@@ -146,11 +146,16 @@
# a 911 or 912 built before #1099 inherited it. The password stops opening
# the local Administrator once the task above has run, but the template reuses
# it, so it is still worth reading on any guest this has not touched yet.
-# Panther\unattend.xml stays: Setup scrubbed its password.
-- name: Remove Setup's plaintext copy of the build answer file
+# Panther\unattend.xml stays: Setup scrubbed its password. unattend-oobe.xml,
+# the answer sysprep uses on a clone's first boot, carries the build password
+# in plaintext too; SetupComplete.cmd deletes it, and this backs that up.
+- name: Remove Setup's plaintext copies of the build answer files
ansible.windows.win_file:
- path: C:\Windows\Panther\unattend-original.xml
+ path: "{{ item }}"
state: absent
+ loop:
+ - C:\Windows\Panther\unattend-original.xml
+ - C:\Windows\Panther\unattend-oobe.xml
# What the template's build left behind (#846). Packer's WinRM ran over HTTPS on
# a self-signed certificate, FriendlyName packer-winrm, made in bootstrap.ps1.
diff --git a/ansible/verify.yml b/ansible/verify.yml
index f32604af..74138e06 100644
--- a/ansible/verify.yml
+++ b/ansible/verify.yml
@@ -91,10 +91,11 @@
# sysprep. None on any guest either way.
$r['no packer-winrm certificate from the build'] = (@(Get-ChildItem -Path Cert:\LocalMachine\My |
Where-Object FriendlyName -eq 'packer-winrm').Count -eq 0)
- # Setup's plaintext copy of the build answer file (#1099): roles/base
- # removes it from a clone of a template built before #1099, and the
- # template no longer carries it.
- $r['no plaintext answer file in Panther'] = -not (Test-Path C:\Windows\Panther\unattend-original.xml)
+ # The build password's two plaintext answer files (#1099): Setup's
+ # copy of the build answer, and the first-boot answer SetupComplete.cmd
+ # deletes. roles/base removes both; neither may be on any guest.
+ $r['no plaintext answer file in Panther'] = -not ((Test-Path C:\Windows\Panther\unattend-original.xml) -or
+ (Test-Path C:\Windows\Panther\unattend-oobe.xml))
# --- #450: Sysmon, recording with the vendored config ----------------
# The driver as well as the service: Sysmon64 running over an unloaded
# SysmonDrv records nothing. ConfigHash is what the driver last loaded,
From ecc18e971957a370f28e3a80cafd519afad06f44 Mon Sep 17 00:00:00 2001
From: Garrett Allen <98648590+Gerrrt@users.noreply.github.com>
Date: Thu, 8 Oct 2026 20:30:39 -0700
Subject: [PATCH 3/3] fix(packer): leave the first-boot deletion to #1103's
fail-closed SetupComplete.cmd (#1099)
#1103, merged alongside, deletes unattend-original.xml and unattend.xml in SetupComplete.cmd and refuses to start the guest agent if either survives, and its smoke test checks for them. This PR's own SetupComplete.cmd lines would have duplicated that step in a weaker form, so they are dropped. The file now matches main. #1102 keeps the template-build deletion in sysprep.ps1, roles/base's cleanup of existing clones and of unattend-oobe.xml, and verify.yml's check. The changelog entry now says so.
Co-Authored-By: Claude Opus 5.5
---
docs/changelog.md | 20 ++++++++---------
packer/windows/scripts/SetupComplete.cmd | 28 ++++++++++++++++--------
2 files changed, 29 insertions(+), 19 deletions(-)
diff --git a/docs/changelog.md b/docs/changelog.md
index 9cc0b134..516141e7 100644
--- a/docs/changelog.md
+++ b/docs/changelog.md
@@ -34,17 +34,17 @@ docstring gives: it is a record, not a claim about now.
- **The fix, in three places:**
- the sysprep task deletes it as its last step before generalising, so a
rebuilt template no longer carries it;
- - `SetupComplete.cmd` deletes it again before a clone's first logon,
- logging whether it went;
- - `roles/base` removes it on every run, and `verify.yml` holds every guest
- to not having it.
+ - on each clone's first boot, #1103's `SetupComplete.cmd` deletes it and
+ `unattend.xml`, and refuses to start the guest agent if either survives;
+ - `roles/base` removes it and `unattend-oobe.xml`, which also carries the
+ build password, on every run, and `verify.yml` holds every guest to
+ having neither.
- **Checked on carbuncle without touching Panther.** PowerShell's own parser
- reads `sysprep.ps1` with 0 errors. The new `SetupComplete.cmd` lines, run
- against a temp folder, delete a present file, and log a second run on an
- absent one without failing.
- - **Still to do.** Apply `roles/base` to the six, and remove it on
- dot-windows, which is not in the Ansible inventory. 911 and 912 lose it
- at their next rebuild.
+ reads `sysprep.ps1` with 0 errors, and `verify.yml`'s new check evaluates
+ True there.
+ - **The running guests were cleaned the same day.** The file was deleted
+ through the guest agent on all seven, and confirmed gone on each. 911 and
+ 912 lose it at their next rebuild.
## 2026-10-08
diff --git a/packer/windows/scripts/SetupComplete.cmd b/packer/windows/scripts/SetupComplete.cmd
index 60db9728..919c4ef3 100644
--- a/packer/windows/scripts/SetupComplete.cmd
+++ b/packer/windows/scripts/SetupComplete.cmd
@@ -66,15 +66,12 @@ sc.exe stop WinRM>> "%LOG%" 2>&1
>> "%LOG%" echo %TIME% rc=%ERRORLEVEL%
del /q "%WINDIR%\Panther\unattend-oobe.xml">> "%LOG%" 2>&1
-
-rem Setup's untouched copy of an answer file, with its passwords in plaintext
-rem and readable by Users (#1099). The sysprep task deletes the build's before
-rem generalising; this is the backstop for a template built before that, and
-rem for any copy Setup writes on the clone itself. It runs before the first
-rem logon, so no user ever sees one.
-echo %TIME% Panther: delete unattend-original.xml>> "%LOG%"
-del /f /q "%WINDIR%\Panther\unattend-original.xml">> "%LOG%" 2>&1
-if exist "%WINDIR%\Panther\unattend-original.xml" (>> "%LOG%" echo %TIME% STILL PRESENT) else (>> "%LOG%" echo %TIME% gone)
+rem The specialize/oobe answer files Setup copies into Panther carry the
+rem build password (and, since #1093, the AutoLogon password) in plaintext,
+rem and are readable by BUILTIN\Users (#1099). Setup is done by now, so they
+rem are vestigial; delete them before any user can log on.
+del /q "%WINDIR%\Panther\unattend.xml">> "%LOG%" 2>&1
+del /q "%WINDIR%\Panther\unattend-original.xml">> "%LOG%" 2>&1
rem What sysprep.ps1 left to run sysprep outside the build's WinRM session.
rem The task has no trigger and cannot run again, but it has no business in
@@ -104,6 +101,14 @@ sc.exe config sshd start= auto>> "%LOG%" 2>&1
sc.exe start sshd>> "%LOG%" 2>&1
>> "%LOG%" echo %TIME% rc=%ERRORLEVEL%
+rem Readiness invariant (#1099): the Panther answer files MUST be gone before
+rem the agent signals ready. If either survived the delete above, do NOT start
+rem QEMU-GA: packer-smoke.sh then times out and the rebuild fails loudly rather
+rem than shipping a clone whose plaintext build/AutoLogon password is readable
+rem by BUILTIN\Users. The smoke test also asserts their absence over SSH.
+if exist "%WINDIR%\Panther\unattend.xml" goto scrubfail
+if exist "%WINDIR%\Panther\unattend-original.xml" goto scrubfail
+
rem Last: the guest agent, which sysprep.ps1 disabled so that it could not
rem answer before this script had run, sshd included. Its first answer is the
rem readiness signal scripts/packer-smoke.sh waits for.
@@ -112,3 +117,8 @@ sc.exe config QEMU-GA start= auto>> "%LOG%" 2>&1
sc.exe start QEMU-GA>> "%LOG%" 2>&1
>> "%LOG%" echo %TIME% rc=%ERRORLEVEL%
echo %DATE% %TIME% done>> "%LOG%"
+goto :eof
+
+:scrubfail
+echo %DATE% %TIME% ABORT: a Panther answer file survived the scrub (#1099); refusing to start QEMU-GA>> "%LOG%"
+exit /b 1