Repository navigation
v50 patch 3
Trust-guard hardening and wrapper correctness fixes.
Two independent peer reviews of the v50 patch 2 source and the
v50 wrapper identified twelve actionable findings; this release
closes all twelve, plus two follow-up revisions to the trust-
guard mask after the standard C:\ProgramData ACL was found to
false-positive on the original unified form, and a final-round
set of correctness fixes landed after the initial documentation
pass.
ScriptVersion remains 50; ScriptPatchLevel moves from "2" to
"3". No DesiredStateId change; no fleet-wide rebuild.
Fixed
-
Restore action preserves the resume task on deployment
failure.Invoke-RestoreAction's WIM-deployment-failure
branch attempts to re-enable WinRE when the previous state was
Enabled. If that re-enable attempt does not returnok, the
branch now sets$Script:ResumeTaskShouldPersist = $truebefore
returning$EXIT_FATAL, so thefinallyblock leaves the
temporary resume task registered. Arebootresult does not
confirm WinRE is enabled - onlyokdoes - so the persist
condition is-ne 'ok', not-ne 'ok' -and -ne 'reboot'. -
Non-OS stray-recovery sweep verifies each deletion.
Remove-StrayRecoveryPartitionsre-queries the target disk with
a terminating query and confirms the partition is not among the
results before recording success. A query failure is treated as
not-confirmed-deleted (fail closed). -
Get-GitHubBaseWinRErejects an empty archive-parts list with
a named reason. If the GitHub folder is reachable but its
contents no longer match the expected filename pattern, the
function logsGet-GitHubBaseWinRE: no winre.7z.NNN archive parts found at <url>and returns$falserather than indexing
$parts[0]on an empty array. -
Recovery-volume drive-letter normalization is scoped to the
OS disk. The block that removes drive letters from volumes
labelledRecoveryorWINREnow requires the volume's
partition to be on the OS disk. -
Add-ManagerBackupRootpreserves volume roots.
[System.IO.Path]::GetFullPath('E:\').TrimEnd('\')returned
E:, which is drive-relative in PowerShell and does not match
the mapped-drive resolution regex. The function now preserves a
path whose full form is exactly a volume root; the mapped-drive
UNC conversion skips its trailing separator when the relative
path is empty. -
Recovery-volume drive-letter normalization is fail-closed on a
provider error. The block's inlineTest-Path "$X:\Windows"
check is now a try/catch that logs the failure and skips removal
for that volume; an indeterminate result is treated as "do not
remove". -
Workspace volume enumeration is fail-closed with a named
reason.Get-WorkDirCandidateswraps itsGet-Volumecall in
a try/catch that logs a named reason and returns an empty
candidate list, so the caller defers cleanly with the standard
no-eligible-workspace message rather than aborting FATAL. -
Resume-script staging is removed only when the resume task is
unregistered. The staging directory and the temporary resume
task share a lifetime; the call is now inside the sameifthat
gates the task unregister. -
Restore failure now invalidates stale state only when the
target cannot be proven unchanged.Invoke-RestoreAction's
WIM-deployment-failure branch captures the target WIM's SHA256
before the deploy attempt and again after the failure. The state
file, checkpoint, and deferral marker are preserved only when
both hashes are present and equal; otherwise they are invalidated
so the next run does not trust stale state. The persist flag is
set unconditionally in the invalidate branch, becausereagentc /enablereturningokestablishes only that reagentc reports
Enabled, not that the target WIM's bytes are intact. -
Test-PathTrustedForSystemhonours its fail-closed contract
for unresolvable ACE SIDs. The header comment promised
fail-closed on an unresolvable SID; the ACE loop'scatch { continue }shape silently skipped such ACEs instead. The loop
now logs the failure and returns$false. Fail-more-often,
never fail-less: the change can only produce additional
refusals, never additional acceptances. The same correction was
mirrored toCleanup-Backups.ps1's duplicated trust helper and
to the compressed inline trust check inWinRE-Manager.cmd's
RestoreTARGET_COMMAND.
Changed
-
Trust guard: shared
Test-PathTrustedForSystemhelper
replaces the ownership-only check. The helper validates the
ACL owner (SYSTEM or Administrators) and rejects any Allow ACE
granting a modify-capable right to a principal outside SYSTEM,
Administrators, or TrustedInstaller. The modify-capable mask
differs by object class: on a directory it isDelete | DeleteSubdirectoriesAndFiles | TakeOwnership | ChangePermissions; on a file it addsWriteData | AppendData,
because on a directory those two rights mean only
create-new-file and create-new-subdirectory, not
modify-existing.WriteDataandAppendDataare deliberately
excluded on directories - including them would false-positive on
the stockC:\ProgramDataACL that grantsBUILTIN\Users
(I)(CI)(WD,AD,WEA,WA). Fail-closed on unreadable ACL, unknown
owner, or unresolvable SID. -
Get-ManagerConfigandSet-ManagerConfigverify the config
file itself, not just its directory. A non-admin who pre-
createdmanager.jsoninside a SYSTEM-owned directory would
have passed the directory-only check but supplied hostile
content. On the write path the file check runs only when the
file already exists. -
Register-ResumeTaskstages the running script to a
SYSTEM-owned location. The final design stages the running
script toC:\Recovery\OEM\Resume\WinRE.ps1under an explicit
DACL (SYSTEM and Administrators FullControl, inheritance
disabled), byte-verifies the copy against the source, re-verifies
the staged file and its directory withTest-PathTrustedForSystem,
and registers the task against the staged copy. On clean terminal
exit the staging directory is removed at the same point the task
is unregistered. -
.NOTEStrust-gate and resume-task bullets updated.
.NOTESVersionline updated to50.3 (v50 patch 3).
Changed (wrapper)
- Restore picker's config read is gated on the shared trust
check. - Restore enumerates the manager config catalogue in addition to
the default root. - Wrapper accepts WIM-only backups.
- Argument quoting for
Start-Processpaths ending in a
backslash. The wrapper now doubles the trailing backslashes of
$dest,$path, and$srcbefore embedding them in the
argument string.
Changed (Cleanup-Backups.ps1)
- Trust model ported to the shared
Test-PathTrustedForSystem
shape. - Reparse-point backup directories rejected during discovery and
revalidated immediately before deletion. - WIM-only backups are listed and can be deleted.
- Exit code reflects deletion failures.
- Explicit
-BackupPathrestricts the default-directory cleanup. - Empty-directory pruning runs on the early-exit path.
- ACE-catch fail-closed correction mirroring the production
Test-PathTrustedForSystemfix. - Numeric-selection fix for the single-backup case: with exactly
one backup present under a root, selecting it by its displayed
number now proceeds to confirmation and deletion rather than
reportingNo matching backups selected.(Sort-Objectreturns
a scalarPSCustomObjectfor a single-element pipeline; the old
$backups.Countrange check rejected every numeric token in that
case. The branch now forces array semantics with
@($backups).Countand collects indices in a typedList[int].)
Changed (harness)
Test-WinRE.ps1moved from v37 to v38. Run logging added;
-NonInteractivenow runs the parser self-test.
Changed (map builders)
Build-DellWinPEMap.ps1andBuild-HPWinPEMap.ps1refuse to
publish an empty map.Build-LenovoWinPEMap.ps1resolves curl-impersonate from
releases/latestwith a download-host allowlist.
Migration Note
ScriptVersion remains 50, so the SCRIPT component of
DesiredStateId is unchanged and no fleet-wide rebuild is forced.
ScriptPatchLevel moves from "2" to "3", visible in the
startup banner (WinRE Manager Started (v50 patch 3)) and in the
harness menu (v38). A machine that ran v50 patch 2 continues on the
fast path.
The manager config trust gate takes effect only on a machine whose
config directory, its immediate parent, or the config file itself
would fail the extended check; a machine whose config directory
has the stock ACL passes the extended check exactly as it passed
the v50 owner-only check, confirmed by the v50 patch 3 field
verification.
Rollback: change $ScriptPatchLevel back to "2" and revert the
v50 patch 3 changes. No DesiredStateId change; no second rebuild.
Field verification
The v50 patch 3 backup action was exercised on 2026-10-14 on a
second test machine. The run captured the currently-registered
WinRE WIM to a timestamped backup directory, wrote the sidecar
backup.json, wrote C:\ProgramData\OEM\WinRE-Manager\manager.json
with BackupRoots count=2, and exited 0. The extended
Test-PathTrustedForSystem mask accepted the stock
C:\ProgramData\OEM ACL, confirmed by the absence of any
Test-PathTrustedForSystem: WARN line and by the successful
config write.
The resume-script staging design was exercised on 2026-10-14 on
the project's ASUS desktop test machine. The run staged
D:\GitHub\WinRE-Manager\scripts\WinRE.ps1 to
C:\Recovery\OEM\Resume\WinRE.ps1 with the SHA256 of the staged
copy matching the source, registered the temporary resume task
against the staged copy, and removed both the task and the staging
directory on clean exit. A backup-and-delete round-trip via the
wrapper completed cleanly on the same machine, and the wrapper's
Restore picker loaded with the trust-checked config read.
Three of the four final follow-up corrections were verified on
2026-10-15 by inspection of the staged script and by the harness's
source-level binding checks: the Restore-failure hash-comparison
invalidation, the Test-PathTrustedForSystem ACE-catch fix, and
the two mirror syncs. The Cleanup-Backups.ps1 numeric-selection
fix was verified end-to-end on the same date.
The following items remain pending field verification:
- Resume-script staging failure branches (staging-directory
creation, script copy, hash verification, self-staging case). - Resume-task persist path on the Restore deployment-failure
branch. - Stray-sweep post-deletion verification on a machine with an
actual stray recovery partition. - Wrapper numbered-restore with multiple registered roots and
WIM-only restore acceptance. - Wrapper argument quoting on paths ending in a backslash.
Cleanup-Backups.ps1reparse-point rejection on a real
reparse-point candidate.- The fail-closed ACE-catch branches against an actual
unresolvable-SID ACE. - The Restore-failure hash-comparison logic against a genuine
WIM-replacement failure.
Full changelog
See CHANGELOG.md.