Skip to content

Preserve exact isolated process environment literals - #954

Merged
coneilen merged 1 commit into
mainfrom
coneilen-process-environment-boundary
Oct 30, 2026
Merged

coneilen merged 1 commit into
mainfrom
coneilen-process-environment-boundary

Conversation

@coneilen

@coneilen coneilen commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Add a narrowly scoped helper for isolated PowerShell entry points to reassert the exact reviewed PATHEXT and PSModulePath Process literals after startup, without relaxing the full 30-key environment guard. This standalone change does not wire or invoke inventory entry points.

Changes

  • Validate the complete 30-property literal map and approved existing absolute entry path before either of exactly two Process-only writes. Preserve strict membership, Ordinal literal equality, zero extras, and refusal of subsequent mutation.
  • Add the focused fresh-process contract and exactly one ValidationRunner registration; document the boundary and the distinction between documented PSModulePath construction and the observed PATHEXT inequality.
  • Replay only the reviewed helper, contract, registration, and matrix delta onto clean main 1aa30100d4f38e4617e22ca1c0332c3a68afa093. No inherited UIA/Delete/Wire source hunks, inventory copies, readiness rebinding, or metadata-policy changes.

The helper is byte-identical to reviewed SHA-256 26CC557B22B302488AC68151FBEC10A200F4A1FD2F7798F1EB03FB7E8DB80270. One tightly coupled test-fixture correction was necessary: start synthetic PATH with PSHOME before System32, avoiding unrelated PowerShell startup PATH reordering. The original GREEN failure and key-only PATH diagnostic are retained. Reversing only that ordering restores the exact reviewed test SHA-256 C819290E7D179B9E444770E46BAB6C600EC91FC709F562C40CC0A888FBCE61F1; the helper and strict guard were not changed.

Test plan

RED: & 'C:\Program Files\PowerShell\7\pwsh.exe' -NoProfile -File Tools\windows\Tests\IsolatedProcessEnvironment.Contracts.Tests.ps1 -Phase RED -> 1 case; actual exit 1; fresh-pwsh startupDrift=true and exact ISOLATED_ENV_LITERAL refusal without reassertion
GREEN: & 'C:\Program Files\PowerShell\7\pwsh.exe' -NoProfile -File Tools\windows\Tests\IsolatedProcessEnvironment.Contracts.Tests.ps1 -Phase GREEN -> 1 case passed; actual exit 0; startup drift observed and complete strict guard passed
REGRESSION: & 'C:\Program Files\PowerShell\7\pwsh.exe' -NoProfile -File Tools\windows\Tests\IsolatedProcessEnvironment.Contracts.Tests.ps1 -Phase REGRESSION -> 14 cases passed; actual exit 0; all required refusal categories and unchanged parent literals asserted

Chronology: reviewed implementation sources existed before these behavioral runs. RED is an actual fresh-process reproduction of the missing-initializer boundary, not a claim that implementation followed test-first development.

Exact local command Result
& 'C:\Program Files\PowerShell\7\pwsh.exe' -NoProfile -File Tools\windows\Tests\UiCaptureDriver.Tests.ps1 -PrepareFixturesOnly -ScratchRoot C:\gceb78f7\prebuilt-v1 Exit 0; 2 fixtures, 14 artifact lengths/hashes, 6 source bindings and 2 compiler provenance records independently verified.
& 'C:\Program Files\PowerShell\7\pwsh.exe' -NoProfile -File Tools\windows\Tests\UiCaptureDriver.Tests.ps1 -ScratchRoot C:\gceb78f7\capture-v1 -PrebuiltFixtureManifest C:\gceb78f7\prebuilt-v1\fixtures.json -PrebuiltFixtureManifestSha256 FC1B9F7AB69A619F748E2D6E83D1F4D52154F5CB1081D0CB5B790E37ADAC0419 Exit 0; 182 executed, 182 passed, 0 failed, 0 skipped.
& 'C:\Program Files\PowerShell\7\pwsh.exe' -NoProfile -File Tools\windows\Tests\ValidationRunner.Tests.ps1 Exit 0; full runner PASS. Includes HWND/CIM/native contracts, not native-free. Structured sub-suites: UiScenario 166, UiCaptureDriver 182, ActionWorkerImport 18, ActionWindowIdentity 62, ActionTopologyImport 16, WireTargeting 56, all executed=passed and failed=0; helper regression 14 also executed. UiScenario has no skip field; the other five report 0 skips. No aggregate whole-runner test count is claimed.
& 'C:\Program Files\PowerShell\7\pwsh.exe' -NoProfile -File Tools\windows\validate.ps1 -Task hardening Exit 0; 5 deterministic dimensions across 3 runs, 15/15 passed; repeated-runs 3/3. Optional owned-environment matrix explicitly not run.
& 'C:\Program Files\PowerShell\7\pwsh.exe' -NoProfile -File Tools\tdd\Tests\TddEvidence.Tests.ps1 Exit 0; all 4 evidence scenarios passed.
PowerShell Parser.ParseFile on helper, focused contract and ValidationRunner 3 files parsed, 0 errors.
Explicit CR-byte checks on all 4 changed files; git diff --check 4 LF-only files; diff check passed. Staged blobs are checked before commit.

Focused cases cover baseline/green, missing and empty approved literals, missing other expected literal, extra key, other-key drift, post-reassertion mutation, wrong entry path, and refused User/Machine/Host target parameters. Passing GREEN uses the strict full-map guard, preserving the other 28 literal values and permitting no extra keys. An additional fresh regression run confirmed the whole parent Process map (138 keys) remained unchanged; dot-sourcing also left that map unchanged. Static helper inspection found exactly two setters and four environment API sites, all explicit Process scope. User/Machine values were neither read nor snapshotted; persistent-scope non-mutation is source/scope evidence, not a runtime registry comparison.

Recovery granted the exclusive serialized native/resource lease for the full suites and the separately authorized fixture-preparation stage; they ran sequentially. The first unbound full-suite attempt is retained as a setup failure, exit 1, executed 1/passed 0/failed 1/skipped 0, PrebuiltFixtureRequired; it is not native-behavior evidence. Fixture source/tool/file bindings were independently checked before the subsequent run; the parent's additional independent verification arrived after launch and before continuation. Compiler raw EOF remains unproven in provenance snapshots; this is not represented as complete compile-stream capture.

Raw streams, synthetic maps, first failures and replay checks remain in the owned worktree .build\environment-boundary-evidence / .build\isolated-process-environment and short owned C:\gceb78f7 roots. The passing full suites retain injected selector/denied-path diagnostics rather than suppressing them. Suite held-handle/job/EOF cleanup assertions passed; a separate advisory process scan observed 345 processes with 0 owned-root survivors, not authority to terminate processes. No full default-profile snapshot is claimed.

Exact-head CI history: run 41113548037, attempt 1, Windows 2025 job 124261920850 failed with UiCaptureDriver 180/182 (2 failures, 0 skips); helper regression 14 passed. The primary case was matched S tab actual worker seed write preserves scene path and not-created cleanup: the live held PID 8544's first CIM observation was Incomplete at 19:23:06.4773810Z, triggering guarded rollback; a later observation contained creation/image metadata and guarded Stop followed. The existing fixture's finally block masked the original launch refusal with its cleanup assertion because no run had returned. Its default false EOF/root flags prove neither a leak nor completed cleanup. The report-gate failure was dependent on that failed case. The primary exception text did not survive masking; unchanged capture module/test/worker sources were not edited.

After preserving attempt 1 log/artifact 13005916886 and independently reviewing its trace, exactly one targeted rerun of the failed job was authorized at the same head 4e1e70de789880a0e74b403c0ad52254300dec2e, with no source changes. Run 41113548037, attempt 2, actual Windows 2025 job 124271394331 passed: helper regression 14, UiCaptureDriver 182/182 with 0 failed/0 skipped, full ValidationRunner PASS, and deterministic hardening repeated-runs 3/3. The carried Windows 2022 success retains its original execution timestamps; it is not claimed as a second Windows 2022 execution. First-failure and successful-rerun logs, the nonempty 32-event primary trace, and the original diagnostic artifact remain retained under C:\gceb78f7. This supports a transient unchanged-platform CIM acquisition failure, not a source correction or weakened guard. Required checks are rechecked after this evidence-only body edit before merge; path-skipped checks are not runtime evidence.

Local limits: no macOS make test/make check, product UI walkthrough, visual parity, physical input, screen-reader campaign, inventory/closed-audit invocation, product build, or packaging scheduler/PATH operations. Required hosted CI separately ran its configured Windows validation jobs. Inventory remains held after merge until a fresh pinned compile/inventory plan is independently reviewed.

Checklist

  • I have read the Contributing Guidelines
  • I have signed off my commits (git commit -s) per the DCO
  • Tests pass locally (make test)
  • Code follows the existing style (make check)
  • I added the test/contract before the implementation and observed the intended RED failure

Signed-off-by: Colin Neilens <coneilen@microsoft.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@coneilen
coneilen merged commit aa30762 into main Oct 30, 2026
31 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant