Skip to content

v50 patch 3

Choose a tag to compare

@ArthurJDurand ArthurJDurand released this 15 Oct 11:19
· 2 commits to main since this release

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 return ok, the
    branch now sets $Script:ResumeTaskShouldPersist = $true before
    returning $EXIT_FATAL, so the finally block leaves the
    temporary resume task registered. A reboot result does not
    confirm WinRE is enabled - only ok does - so the persist
    condition is -ne 'ok', not -ne 'ok' -and -ne 'reboot'.

  • Non-OS stray-recovery sweep verifies each deletion.
    Remove-StrayRecoveryPartitions re-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-GitHubBaseWinRE rejects 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 logs Get-GitHubBaseWinRE: no winre.7z.NNN archive parts found at <url> and returns $false rather 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
    labelled Recovery or WINRE now requires the volume's
    partition to be on the OS disk.

  • Add-ManagerBackupRoot preserves 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 inline Test-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-WorkDirCandidates wraps its Get-Volume call 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 same if that
    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, because reagentc /enable returning ok establishes only that reagentc reports
    Enabled, not that the target WIM's bytes are intact.

  • Test-PathTrustedForSystem honours its fail-closed contract
    for unresolvable ACE SIDs.
    The header comment promised
    fail-closed on an unresolvable SID; the ACE loop's catch { 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 to Cleanup-Backups.ps1's duplicated trust helper and
    to the compressed inline trust check in WinRE-Manager.cmd's
    Restore TARGET_COMMAND.

Changed

  • Trust guard: shared Test-PathTrustedForSystem helper
    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 is Delete | DeleteSubdirectoriesAndFiles | TakeOwnership | ChangePermissions; on a file it adds WriteData | AppendData,
    because on a directory those two rights mean only
    create-new-file and create-new-subdirectory, not
    modify-existing. WriteData and AppendData are deliberately
    excluded on directories - including them would false-positive on
    the stock C:\ProgramData ACL that grants BUILTIN\Users
    (I)(CI)(WD,AD,WEA,WA). Fail-closed on unreadable ACL, unknown
    owner, or unresolvable SID.

  • Get-ManagerConfig and Set-ManagerConfig verify the config
    file itself, not just its directory.
    A non-admin who pre-
    created manager.json inside 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-ResumeTask stages the running script to a
    SYSTEM-owned location.
    The final design stages the running
    script to C:\Recovery\OEM\Resume\WinRE.ps1 under an explicit
    DACL (SYSTEM and Administrators FullControl, inheritance
    disabled), byte-verifies the copy against the source, re-verifies
    the staged file and its directory with Test-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.

  • .NOTES trust-gate and resume-task bullets updated.
    .NOTES Version line updated to 50.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-Process paths ending in a
    backslash.
    The wrapper now doubles the trailing backslashes of
    $dest, $path, and $src before 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 -BackupPath restricts the default-directory cleanup.
  • Empty-directory pruning runs on the early-exit path.
  • ACE-catch fail-closed correction mirroring the production
    Test-PathTrustedForSystem fix.
  • 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
    reporting No matching backups selected. (Sort-Object returns
    a scalar PSCustomObject for a single-element pipeline; the old
    $backups.Count range check rejected every numeric token in that
    case. The branch now forces array semantics with
    @($backups).Count and collects indices in a typed List[int].)

Changed (harness)

  • Test-WinRE.ps1 moved from v37 to v38. Run logging added;
    -NonInteractive now runs the parser self-test.

Changed (map builders)

  • Build-DellWinPEMap.ps1 and Build-HPWinPEMap.ps1 refuse to
    publish an empty map.
  • Build-LenovoWinPEMap.ps1 resolves curl-impersonate from
    releases/latest with 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.ps1 reparse-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.