Skip to content

Build fixes, update documentation. - #6

Merged
shschaefer merged 3 commits into
mainfrom
dev/shschaefer/build_fix
Feb 16, 2026
Merged

shschaefer merged 3 commits into
mainfrom
dev/shschaefer/build_fix

Conversation

@shschaefer

Copy link
Copy Markdown
Contributor

Cleanup the build scripts. Update the documentation, creating a doc folder and first files.

Comment thread docs/examples.md Resolved
Comment thread sdk/src/platform.ts

// Check branch
if (branch !== 'ge_current_directwinai') {
if (!branch.startsWith('ge_current_directwinai')) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the bfscfg change has not yet RIed from dev1 to directwinai

@shschaefer
shschaefer merged commit 73730c3 into main Feb 16, 2026
1 check passed
@shschaefer
shschaefer deleted the dev/shschaefer/build_fix branch March 5, 2026 22:31
Copilot AI mentioned this pull request Jun 15, 2026
7 tasks
Lily Barkley (lilybarkley-msft) added a commit that referenced this pull request Jun 26, 2026
Lily Barkley (lilybarkley-msft) added a commit that referenced this pull request Jul 7, 2026
Addresses MGudgin / Copilot review feedback on PR #584:

  #2  --audit lifecycle chatter (spawn banner, non-zero-exit / spawn-fail
      lines, capability-injection warning) now writes only to the log
      buffer by default; add --audit-verbose to also surface them on
      stderr for pipeline-debugging.
  #3  Replace the encode_utf16+PCWSTR mutex-name literal with the
      windows::core::w!() macro in both wxc-exec (Global\\Mxc_Plm_Audit)
      and plm.exe.
  #4  Scope chrono to default-features = false, features = std+clock so
      it stops dragging js-sys / wasm-bindgen / iana-time-zone into the
      dep tree.
  #5  Clarify the "PLM runs as administrator" comment — the elevation
      lives in "launched --audit from an elevated context" (needed for
      WPR kernel session), not a PLM-internal auto-elevate.
  #6  Drop stale build.rs comment referencing the pre-embedded WPR
      profile staging.
  #8  run_plm_command doc no longer claims plm failures never abort;
      documents that --audit's "plm start" caller does abort while
      "plm stop" falls through to wpr -cancel cleanup.
  #9  --audit's "is capability already present?" check is now case-
      sensitive (matching the downstream AppContainer runner) so an
      operator's mis-cased spelling doesn't silently disable the
      injection.
  #10 Move mark_plm_trace_active() out of plm's main.rs into a callback
      that log::run fires only AFTER wpr -start engages. Prevents a
      Ctrl+C during stdin-prompt or spawn-fail from issuing wpr -cancel
      against an unrelated host WPR session.
  #11 WprExeStopper::stop no longer builds wpr_command() twice — reuse
      the single builder instead of constructing a throwaway just to
      read get_program().
  #13 Remove the extra "// " in dacl_ctrl_handler's comment header.

Co-authored-by: Copilot <[email protected]>
Lily Barkley (lilybarkley-msft) added a commit that referenced this pull request Jul 8, 2026
* PLM split PR1: audit-mode plumbing and trace lifecycle

Wide-spread plumbing + Windows-only plm crate skeleton:

- wxc-exec --audit flag, console-control handler, named-mutex singleton
- AppContainer release-build gate rejecting permissiveLearningMode
- �udit field in wire model and config parser
- plm crate: clap dispatch for start/stop/log, WPR start/stop, embedded
  WPR profile materializer, singleton coordination, wpr.exe path
  resolution
- CI/build infra (Azure Pipelines + GitHub Actions) to build plm.exe
  and stage it next to wxc-exec.exe via build.bat

Event parsing, capability extraction, filesystem/UI merging, and the
adjusted-config writer arrive in subsequent PRs.

Builds + tests pass: cargo fmt --check, cargo clippy -p plm,
cargo test -p plm (25 tests).

Co-authored-by: Copilot <[email protected]>

* Remove round-N review markers from CI workflow comments

* PLM CI: restrict integration tests to filesystem fixtures (headless)

* PLM PR1 fix #1: build plm cross-platform via no-op stub main

Replace the workspace's bespoke default-members = members - plm list with the implicit default (all members), and remove the crate-level #![cfg(target_os = "windows")] on plm's main.rs. The Windows-only body is gated per-item; a tiny non-Windows fn main() prints and exits 1 so the binary still links on Linux/macOS.

Drops the special-cased -p plm/--lib steps in the GitHub Actions and Azure DevOps templates that existed solely because plm was excluded from default-members; the regular workspace build now covers it, and the Linux gate keeps a -p plm build/test step so the cross-platform contract is still CI-enforced.

Also adds core/mxc-sdk to the implicit default (Copilot review #12).

Co-authored-by: Copilot <[email protected]>

* PLM PR1 review fixes: quiet --audit, w! macro, chrono scope, WPR race

Addresses MGudgin / Copilot review feedback on PR #584:

  #2  --audit lifecycle chatter (spawn banner, non-zero-exit / spawn-fail
      lines, capability-injection warning) now writes only to the log
      buffer by default; add --audit-verbose to also surface them on
      stderr for pipeline-debugging.
  #3  Replace the encode_utf16+PCWSTR mutex-name literal with the
      windows::core::w!() macro in both wxc-exec (Global\\Mxc_Plm_Audit)
      and plm.exe.
  #4  Scope chrono to default-features = false, features = std+clock so
      it stops dragging js-sys / wasm-bindgen / iana-time-zone into the
      dep tree.
  #5  Clarify the "PLM runs as administrator" comment — the elevation
      lives in "launched --audit from an elevated context" (needed for
      WPR kernel session), not a PLM-internal auto-elevate.
  #6  Drop stale build.rs comment referencing the pre-embedded WPR
      profile staging.
  #8  run_plm_command doc no longer claims plm failures never abort;
      documents that --audit's "plm start" caller does abort while
      "plm stop" falls through to wpr -cancel cleanup.
  #9  --audit's "is capability already present?" check is now case-
      sensitive (matching the downstream AppContainer runner) so an
      operator's mis-cased spelling doesn't silently disable the
      injection.
  #10 Move mark_plm_trace_active() out of plm's main.rs into a callback
      that log::run fires only AFTER wpr -start engages. Prevents a
      Ctrl+C during stdin-prompt or spawn-fail from issuing wpr -cancel
      against an unrelated host WPR session.
  #11 WprExeStopper::stop no longer builds wpr_command() twice — reuse
      the single builder instead of constructing a throwaway just to
      read get_program().
  #13 Remove the extra "// " in dacl_ctrl_handler's comment header.

Co-authored-by: Copilot <[email protected]>

* PLM PR1 review batch 2 fixes: comment cleanup, MIT headers, workspace deps, extract wxc audit module

- Drop future-PR/past-state phrasing from plm module doc-comments
- Prepend MIT copyright headers to coordination.rs, profile_gen.rs, wpr_path.rs
- Simplify plm log trace filename (drop PID and parse-preview note)
- Move serde_json/chrono/roxmltree to workspace [workspace.dependencies]
- Use wxc_common::string_util::from_wide in plm::wpr_path
- Add plm::coordination::singleton with shared try_acquire/release helpers;
  both plm::main and wxc::audit now delegate to it
- Extract PLM audit lifecycle (~230 lines) from wxc/src/main.rs into
  wxc/src/audit.rs

Co-authored-by: Copilot <[email protected]>

* Gate plm_ctrl_handler on target_os = "windows"

* Regenerate dev schema to match wire model

* Soften README claim about plm stop parsing (not yet wired on this PR)

* Move --with-bfs to filesystem PR

Per review: --with-bfs / tier2_bfs plumbing belongs with the filesystem extraction PR, not the audit skeleton.

* Drop debug_assertions branch on permissiveLearningMode gate

Per review: now that --audit is the intended enablement mechanism, the debug-build carve-out is redundant.

* Shorten audit-mode README section; link to plm readme

Per review: keep the root README short and defer PLM detail to src/core/plm/readme.md.

* Byte-verify staged plm.wprp against embedded profile before rename

Per review: detect filter drivers, quota clamps, and AV rewrites that would otherwise let a corrupted plm.wprp be adopted on every subsequent run via the early-return existence check.

* Verify wpr.exe Authenticode signature before every plm invocation

wpr.exe runs elevated (SeSystemProfile for NT Kernel Logger); an attacker-planted binary would execute with full admin rights. Cache the verify result so back-to-back plm log + plm stop only pays the cert-chain walk once.

* Remove inline PLM integration test step from Build.Windows.Job

The step references run_plm_test.ps1 which does not exist on this branch (arrives in the testing PR). A dedicated PLM integration test job belongs on the branch that ships the script.

* Drop serde_json preserve_order feature

Removes the runtime feature that reordered every serde_json Map — which was the sole cause of the dev schema on this branch differing from main. The feature was consumed only by a dead type alias in plm/src/config.rs. Regenerated dev schema now matches main byte-for-byte.

* Remove Tessera codename from docs

Substitute neutral placeholder paths in the plm readme (C:\Tessera\mxc -> C:\src\mxc).

* plm: address PR584 review — capture wpr/plm stdio, harden singleton, doc-comment ctrl-handler globals

- start.rs / stop.rs: switch wpr.exe spawns from .status() to .output()
  so successful runs stay silent; replay captured stdout+stderr on
  non-zero exit via shared start::replay_wpr_output. Fixes the
  wxc-exec --audit stdio pollution called out in comments
  r3514558858 / r3514562221 / r3514564478.
- wxc/src/audit.rs: capture plm.exe stdio via .output() so the
  audit-mode background trace never leaks plm chatter into the
  wrapped workload's console. On failure (and in --verbose) the
  captured streams are replayed via a shared replay_child_output
  helper. Fixes r3502009755 / r3502010101 / r3502010465 / r3514551150.
- coordination.rs: switch singleton acquire from
  CreateMutexW(bInitialOwner=true) + ERROR_ALREADY_EXISTS to
  CreateMutexW + WaitForSingleObject(0) so a previous owner that
  crashed (WAIT_ABANDONED) no longer blocks the singleton forever
  and forces a reboot. Addresses r3503721112.
- main.rs: expand PLM_TRACE_ACTIVE doc-comment to explain why it's
  a process-wide static (Windows ctrl-handler callback context has
  no captured self — must reach state via globals). Expand
  plm_ctrl_handler doc to explain why polling is used instead of a
  wait-object (wpr's kernel-session engagement isn't OS-signalled;
  bounded 40-poll worst case stays well under the ~5s ctrl-handler
  kill budget). Addresses r3503762141 / r3503729778.
- stop.rs: drop redundant _pid<PID> suffix from log-dir stamp;
  sub-second (%H%M%S%.3f) is already collision-safe. Addresses
  r3503525035.

Co-authored-by: Copilot <[email protected]>

* plm: move PLM_TRACE_ACTIVE ownership onto AcquiredSingleton

The atomic itself has to stay a process-wide static because the
Windows console-control handler (plm_ctrl_handler) is an OS-owned
extern "system" callback with no captured self/environment — it
can only reach state via process globals. But all non-signal-context
mutation now goes through &AcquiredSingleton methods:

- mark_trace_active(&self)  — was free fn mark_plm_trace_active
- clear_trace_active(&self) — was free fn clear_plm_trace_active
- cancel_active_trace(&self) — was free fn cancel_active_plm_trace

The compile-time invariant is that trace-active can only be flipped
while we hold the host-wide Global\\Mxc_Plm_Audit singleton mutex —
you can't call these methods without first producing an
AcquiredSingleton. The single remaining free-fn escape hatch,
cancel_active_plm_trace_from_signal(), is documented as callable
only from the ctrl handler (where no &self exists).

Also: AcquiredSingleton::drop now cancels any leftover trace before
releasing the mutex, so an error mid-flow can't leak the kernel
session past exit.

The Cmd::Log flow uses the singleton bypass path (when wxc-exec
--audit already holds the mutex outer-process) — that branch falls
back to touching PLM_TRACE_ACTIVE directly because no local
AcquiredSingleton exists in the bypass case.

Addresses PR584 review comment r3503762141 more thoroughly than the
prior doc-comment-only fix.

Co-authored-by: Copilot <[email protected]>

* plm: replace WinVerifyTrust with existence check for wpr.exe

wpr.exe is catalog-signed, not embedded-signed, so WinVerifyTrust with WINTRUST_ACTION_GENERIC_VERIFY_V2 returns TRUST_E_NOSIGNATURE (0x800B0100) on stock Windows installs. Correctly verifying a catalog-signed binary requires a CryptCATAdmin fallback dance.

Since we resolve the path via GetSystemDirectoryW (not env-spoofable) and %SystemDirectory% write access requires TrustedInstaller, path resolution already is the trust boundary. Reduce verify_wpr_signed() to a sanity file-existence check that surfaces a clear message when WPT isn't installed.

Co-authored-by: Copilot <[email protected]>

* plm: suppress `wpr -stop` progress bar in `plm log` happy path

`wpr -stop` streams a `100% [>>>>>>>]` progress bar to stdout as it merges the ETL, which pollutes any wrapping tool's console. `stop::WprExeStopper` already captures via `.output()` and replays via `replay_wpr_output` only on failure; apply the same pattern to `log::stop_wpr_trace`.

Co-authored-by: Copilot <[email protected]>

* plm: spawn wpr.exe with CREATE_NO_WINDOW to suppress its progress bar

wpr.exe renders its `100% [>>>>>>]` merge progress via `WriteConsoleW`, which writes to the console handle directly and bypasses any stdio pipe redirection (`.stdout(Stdio::piped())` / `.output()`). So even though `log.rs` / `stop.rs` / `start.rs` all already capture wpr's stdout+stderr via `.output()`, the progress bar was still leaking onto the wrapping tool's terminal.

Add CREATE_NO_WINDOW (0x08000000) as a creation flag on the Command returned by wpr_command(), so every wpr.exe child is spawned without an attached console and its WriteConsoleW calls silently no-op. Normal stdout/stderr traffic still flows through the pipes and is replayed on failure via replay_wpr_output.

Co-authored-by: Copilot <[email protected]>

* plm(pr1): remove forward-looking future-PR language in module docs

Addresses PR#584 reviewer feedback (bbonaby comments r3503498362, r3503511023, r3503528016, r3503563795, r3503578675, r3503583878, r3507611305). Rewrites the pr1 subcommand summary, `Cmd::Stop` doc, `resolve_bin_path` doc, the `Trace captured at` print, the trailing `verbose logging` message, and the pass-through-options comment so they describe what the code does now rather than deferring to `later PRs`.

The extract-caps subcommand doc entry is removed because Cmd::ExtractCaps isn't wired in this PR (it lands in the split-out PR#587).

Co-authored-by: Copilot <[email protected]>

* wxc-exec: auto-elevate --audit via UAC self-relaunch

Detects a non-elevated token at startup (before COM init) and, when
--audit was requested, re-launches the same argv with ShellExecuteExW
+ `runas` so the user sees the standard UAC consent dialog. The
child's exit code is propagated so the outer invoker sees the normal
return contract. UAC decline (ERROR_CANCELLED = 1223) surfaces a
clear `--audit requires elevation` message.

Addresses PR#584 review thread 3501401682.

Co-authored-by: Copilot <[email protected]>

* plm: move crate from src/core/plm to src/host/plm

Per PR#584 review (MGudgin): PLM's wpr invocations require
Administrator, but the wxc-exec invariant is that it never runs
elevated. Moving the plm crate into src/host/ (alongside wxc-host-prep)
sets up a follow-up commit that adds a small wxc-host-wpr helper
with a requireAdministrator manifest, keeping the elevated surface
scoped to the wpr command line.

No behavior change in this commit \u2014 path move + Cargo path updates
only.

Co-authored-by: Copilot <[email protected]>

* Revert "wxc-exec: auto-elevate --audit via UAC self-relaunch"

This reverts commit 2feb58e1b2b5bc5aed23975b2ab6b09924ecf4a2.

* plm: elevate via requireAdministrator manifest instead of wxc-exec self-relaunch

Restores the invariant that wxc-exec never runs elevated by moving the
elevation requirement onto plm.exe itself, following the wxc-host-prep
pattern.

* Embed a requireAdministrator application manifest on plm.exe
  (release builds only, via embed-manifest crate in build.rs).
* wxc-exec --audit spawns plm.exe via ShellExecuteExW with the "runas"
  verb (new plm_launch module). The elevated child cannot inherit our
  unelevated stdio pipes, so we pass per-invocation capture file paths
  through MXC_PLM_STDOUT_FILE / MXC_PLM_STDERR_FILE env vars; plm.exe
  redirects its stdio to those files on startup via SetStdHandle and
  we replay the captured bytes after the child exits.
* Disable the empty main.rs test binary for the plm crate so
  cargo test -p plm --release does not attempt to launch the
  manifested bin from an unelevated dev shell.

Co-authored-by: Copilot <[email protected]>

* plm: pass elevated-child handshake via CLI flags

ShellExecuteExW + runas does not propagate env vars or stdio handles
across the elevation boundary, so the parent-holds-singleton signal
and the stdio capture paths now ride on hidden CLI flags on plm's Cli
(--wxc-singleton-held-by-parent, --wxc-capture-dir) instead of env
vars. redirect_stdio_from_argv scans argv manually before Cli::parse so
clap parse errors still surface in the capture files.

Co-authored-by: Copilot <[email protected]>

* plm: harden elevated-child capture-file path against symlink attack

The capture-file handshake previously used a deterministic temp dir
(%TEMP%\mxc-plm-<pid>) that any same-user medium-IL attacker could
pre-squat, and the elevated child opened stdout.log/stderr.log with
plain OpenOptions::create(true) which silently follows reparse points.
A racing attacker could plant those filenames as symlinks pointing at
an admin-only target and have the elevated (admin-token) plm.exe
append attacker-influenceable diagnostic bytes to it — an EoP.

Two defenses layered:

1. plm_launch.rs: use tempfile::Builder with a 16-byte random suffix
   so the dir path isn't guessable, and treat pre-existing dir as
   fatal (no silent reuse).

2. plm/main.rs redirect_one: switch OpenOptions::create(true) to
   create_new(true) so CreateFileW returns ERROR_FILE_EXISTS if
   anything (regular file, symlink, junction) already occupies the
   path — the elevated child either creates the file itself fresh
   or gives up on capture; it will never follow an attacker-planted
   reparse point.

Co-authored-by: Copilot <[email protected]>

* plm: fix stale doc comment in run_plm_elevated

Comment described the elevated child as using 'create(true).append(true) +
reparse-point rejection', but the security-fix sibling commit actually
switched to create_new(true) precisely because create(true) has no
reparse-point rejection and silently follows symlinks. A maintainer
trusting the old comment could revert to create(true) and reintroduce
the EoP. Also fix two references to tempdir_in (the code calls tempdir).

Co-authored-by: Copilot <[email protected]>

* plm: document 'wxc-exec never runs elevated' invariant at delegation sites

Add module-doc paragraphs at plm_launch.rs and audit.rs making the
design invariant explicit at the two files where wxc-exec coordinates
PLM elevation: wxc-exec itself is unelevated, and the WPR/ETW work
that requires admin is delegated to plm.exe (requireAdministrator
manifest) via ShellExecuteExW + runas. Mirrors the existing rationale
in src/host/plm/build.rs. Also update the stale 'via env' phrase in
plm_launch.rs docs to reflect the CLI-flag handshake introduced in
3d3bee8.

Co-authored-by: Copilot <[email protected]>

* plm: bound elevated child wait, tidy comments, drop unused windows features

* plm_launch.rs: swap WaitForSingleObject INFINITE for a 30 s bound
  (new PLM_ELEVATED_WAIT_MS const) and add a WAIT_TIMEOUT branch that
  TerminateProcess'es the orphan child before CloseHandle so it can't
  finish wpr -start behind our back and leak the kernel logger
  session. Documented that PLM is intended for a single end-to-end
  flow / unit test at a time, so 30 s is sufficient for the supported
  usage.
* audit.rs: fix stale comments that implied wxc-exec ran elevated;
  cancel_active_audit_trace and AUDIT_SINGLETON_HANDLE docs now
  correctly attribute elevation to plm.exe and name the
  --wxc-singleton-held-by-parent bypass.
* Cargo.toml: drop Win32_Security_WinTrust and Win32_Security_Cryptography
  from the workspace windows crate features; no code uses them (only
  stale comments in plm's wpr_path.rs / main.rs which explicitly say
  we do NOT call WinVerifyTrust).

Co-authored-by: Copilot <[email protected]>

* sdk tests: allow plm.exe as an optional bundled binary

The umbrella build stages plm.exe into sdk/bin/<arch> alongside
wxc-exec.exe when the plm crate is part of the workspace build.
The SDK 'no unexpected binaries' package test fails because
plm.exe wasn't in any allowed list.

Add 'plm.exe' to OPTIONAL_BINARIES (mirroring the wslcsdk.dll
pattern) so builds with and without plm.exe both pass the
integration test, without forcing every build to produce it.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
Dan Legg (danlegg) pushed a commit that referenced this pull request Aug 7, 2026
Address the code-review findings on the coresident explicit-load change
(38dbd88). Runtime binding still activates the MSI IsoSessionApp.dll by
absolute path with zero registry mutation; this commit hardens the
surrounding load, error, and diagnostic behavior.

regfree.rs (#1,#5,#6,#7,#8,#9,#10):
- Load the App DLL with LoadLibraryExW using
  LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32 so
  the runtime directory is the sole search root for its dependencies
  (search-order hijack hardening). Reject non-absolute
  MXC_ISOSESSION_RUNTIME_DIR overrides.
- Replace the 2-state load cache with a 3-state RuntimeLoad enum
  (Absent / Loaded / Unloadable). A missing default folder still falls
  back to inbox activation, but an honored-but-broken explicit override
  or a present-but-unloadable DLL now surfaces the error instead of
  silently falling back.
- Report real Win32 errors (GetProcAddress) and null-check the returned
  factory pointer before from_raw.
- Gate success-path eprintln! on MXC_DIAG_CONSOLE.
- Correct the CoInitializeEx SAFETY comment.
- Add unit tests for runtime-dir resolution and app-dll path building.

manager.rs (#2): wrap the over-length activate line for rustfmt.

oneshot.md (#4,#11): document the two activation paths, the
runtime-folder resolution table (MXC_ISOSESSION_RUNTIME_DIR /
DEFAULT_RUNTIME_DIR), apartment init, and prerequisites; fix
RoInitialize -> CoInitializeEx wording.

tests/scripts (#3): accept EITHER inbox (System32 DLL + registry) OR the
coresident MSI runtime dir in the prerequisite probe, so the suites no
longer skip on an MSI-only host.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: f5cc2011-5308-43d6-a8ea-2b8ed9b6ceb3
RamonArjona4 added a commit that referenced this pull request Aug 11, 2026
Implements all in-scope fixes from PR #791 review:

- Fix #1: Emit M-ETW-5 (SandboxTornDown) independent of diagnostic sinks
- Fix #2: Emit M-ETW-3 (PolicyHash) for state-aware lifecycle phases
- Fix #3: Escape DisplayEvent messages to prevent console injection
- Fix #4: Emit M-ETW-7 (ConfigRejected) for all validation failures
- Fix #5: Initialize telemetry provider before command-override checks
- Fix #6: Use case-insensitive secret detection in policy identity hash

All fixes maintain strict scope boundary: logging, ETW emission, and
directly related hardening only. Pre-existing network, fallback, DACL,
and cleanup behavior is unchanged.

Verification:
- 645 wxc_common tests pass
- Cargo fmt applied
- No new compiler warnings

Co-authored-by: Copilot <[email protected]>
Copilot-Session: ff351c1b-421d-433d-b038-b61db4f1da12
@RamonArjona4 RamonArjona4 mentioned this pull request Aug 11, 2026
2 of 8 tasks
@MGudgin Gudge (MGudgin) mentioned this pull request Aug 12, 2026
5 of 8 tasks
Dan Legg (danlegg) pushed a commit that referenced this pull request Sep 1, 2026
Address the code-review findings on the coresident explicit-load change
(38dbd88). Runtime binding still activates the MSI IsoSessionApp.dll by
absolute path with zero registry mutation; this commit hardens the
surrounding load, error, and diagnostic behavior.

regfree.rs (#1,#5,#6,#7,#8,#9,#10):
- Load the App DLL with LoadLibraryExW using
  LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32 so
  the runtime directory is the sole search root for its dependencies
  (search-order hijack hardening). Reject non-absolute
  MXC_ISOSESSION_RUNTIME_DIR overrides.
- Replace the 2-state load cache with a 3-state RuntimeLoad enum
  (Absent / Loaded / Unloadable). A missing default folder still falls
  back to inbox activation, but an honored-but-broken explicit override
  or a present-but-unloadable DLL now surfaces the error instead of
  silently falling back.
- Report real Win32 errors (GetProcAddress) and null-check the returned
  factory pointer before from_raw.
- Gate success-path eprintln! on MXC_DIAG_CONSOLE.
- Correct the CoInitializeEx SAFETY comment.
- Add unit tests for runtime-dir resolution and app-dll path building.

manager.rs (#2): wrap the over-length activate line for rustfmt.

oneshot.md (#4,#11): document the two activation paths, the
runtime-folder resolution table (MXC_ISOSESSION_RUNTIME_DIR /
DEFAULT_RUNTIME_DIR), apartment init, and prerequisites; fix
RoInitialize -> CoInitializeEx wording.

tests/scripts (#3): accept EITHER inbox (System32 DLL + registry) OR the
coresident MSI runtime dir in the prerequisite probe, so the suites no
longer skip on an MSI-only host.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: f5cc2011-5308-43d6-a8ea-2b8ed9b6ceb3
RamonArjona4 added a commit that referenced this pull request Sep 4, 2026
* feat: add OpenShell-compatible diagnostics

* Enhance ETW requirement test payload coverage validation

Test coverage High finding fix: The requirement event test
\
equirement_events_use_bounded_event_names\ now validates that:

1. All ProcessExited events include exit_code field with correct value
2. All ProcessTimedOut events include timeout_ms field with correct value
3. All ProcessKillFailed events include kill_method field with correct value
4. Event payloads match the data variant (reject mismatched identity+data pairs)
5. EnforcementDegraded events include all tier/reason/enforcement-level fields
6. PolicyHash events include policy_hash and config_schema_version fields
7. SandboxNetworkPolicyApplied events include enforcement mode and proxy port
8. SandboxTornDown events include status and released_resources
9. ConfigRejected events include all rejection metadata

Enhanced the test sink's \
ecord_process\ function to capture the full
payload (ProcessEventData::ExitCode/TimeoutMs/KillFailure) so tests can
assert on actual field values, not just event names and identity.

All 632 wxc_common + 17 mxc_telemetry tests pass.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 84161020-6009-4a46-a320-79d062f2ffa8

* Fix performance Medium issue: avoid allocation when both ETW sinks inactive

Performance Medium finding fix: In emit_enforcement_degraded(), reorganize
the early-exit checks so that when neither telemetry nor diagnostic sinks
are active, we return immediately and never allocate the effective_level
string or reason_codes string.

The previous code always computed both strings after checking sinks are
active, even though one sink path (telemetry-only) would compute both but
ignore the reason_codes allocation in the diagnostic sink branch.

After fix:
- If both sinks inactive: return immediately
- If both sinks active: compute both (shared path)
- If only telemetry active: compute both, use reason_codes, skip diagnostic
- If only diagnostic active: compute both, skip telemetry, use reason_codes

Also changed check from \logger.has_diagnostic_sink()\ to \diagnostic_active\
variable (already computed above).

All 632 wxc_common + 17 mxc_telemetry + dispatcher tests pass.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 84161020-6009-4a46-a320-79d062f2ffa8

* Fix High and Medium severity findings from adversarial review

High-severity fixes:
- Refactor ProcessEventKind + ProcessEventData into single ProcessEvent enum
  to make mismatched kind/data pairs unrepresentable at compile time (7717c04)
- Fix field names in test_sink from snake_case to PascalCase (ExitCode,
  TimeoutMs, mxc.error_type) to match actual ETW provider schema
- Update all call sites to use new ProcessEvent API (3 runners × 3 variants)
- Remove deprecated ProcessEventKind/Data from public exports (mod.rs)

Medium-severity fixes:
- Expand logging_sinks_active test from 2 to 4 boolean combinations
- Fix misleading comment in dispatcher.rs on sink-inactive early exit path
- Update test assertions to validate correct field values

All 632 wxc_common tests pass (excluding pre-existing fallback test failure).
Formatting and warnings validated.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: ff351c1b-421d-433d-b038-b61db4f1da12

* fix: address 6 GitHub review comments for Windows ETW logging

Implements all in-scope fixes from PR #791 review:

- Fix #1: Emit M-ETW-5 (SandboxTornDown) independent of diagnostic sinks
- Fix #2: Emit M-ETW-3 (PolicyHash) for state-aware lifecycle phases
- Fix #3: Escape DisplayEvent messages to prevent console injection
- Fix #4: Emit M-ETW-7 (ConfigRejected) for all validation failures
- Fix #5: Initialize telemetry provider before command-override checks
- Fix #6: Use case-insensitive secret detection in policy identity hash

All fixes maintain strict scope boundary: logging, ETW emission, and
directly related hardening only. Pre-existing network, fallback, DACL,
and cleanup behavior is unchanged.

Verification:
- 645 wxc_common tests pass
- Cargo fmt applied
- No new compiler warnings

Co-authored-by: Copilot <[email protected]>
Copilot-Session: ff351c1b-421d-433d-b038-b61db4f1da12

* fix: restore BaseContainer denied-paths DACL requirement in forced_decision

The previous refactoring accidentally split the match arm:
  IsolationTier::BaseContainer | IsolationTier::AppContainerBfs => denied

Into:
  IsolationTier::BaseContainer => false,
  IsolationTier::AppContainerBfs => denied,

This broke the contract that BaseContainer with denied paths requires DACL
augmentation (for DACL-fallback enforcement of deny policies at Tier 1).
Restore the original combined arm so both tiers check if denied paths are
present.

Fixes the Windows CI test failure:
  fallback_detector::tests::denied_paths_disabled_blocks_t1

All 218 appcontainer_common tests now pass.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: ff351c1b-421d-433d-b038-b61db4f1da12

* chore: remove leaked PR log artifacts

Remove temporary CI analysis and workflow log files from PR #791, and clarify that diagnostic pipe tokens are caller-generated and shared by both processes.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: ff351c1b-421d-433d-b038-b61db4f1da12

* fix: address MGudgin's 20 review comments on PR791 ETW/logging remediation

Fixes 20 review findings from the second MGudgin review round, all within
the PR's logging/ETW scope:

High severity:
- ProcessKillFailed ETW now carries the real OS error code (mxc.error_code)
  alongside the bounded kill-method string.
- ConfigRejected ETW now threads the state-aware phase through to
  mxc.phase; the wrapper accepted it but never forwarded it.
- Telemetry test module now shares TEST_LOCK with events::test_sink instead
  of using a separate lock that didn't serialize against it.
- Added runner-level e2e tests (real process + real job object + real
  file-backed Logger) proving the wait/kill/teardown -> audit-log wiring
  end to end, including a regression test for proactive-cancellation
  telemetry suppression.

Medium severity:
- Diagnostic pipe CreateFile now sets SECURITY_SQOS_PRESENT |
  SECURITY_IDENTIFICATION to prevent client impersonation above the
  intended level.
- State-aware policy-hash identity now goes through redact_identity so a
  UPN-shaped iso:/caller-supplied identity is never hashed/logged raw.
- Raw-config redaction in wxc-exec is now gated behind
  logger.has_diagnostic_sink() instead of always doing the work and
  discarding the result.
- Redaction path tracking in diagnostic.rs no longer clones the whole path
  vector per JSON key.
- Canonical JSON hashing in policy_identity.rs now writes into a single
  growing Vec<u8> buffer instead of allocating a String per key/scalar.
- Thread-local diagnostic sink installation now returns an RAII guard
  (ThreadDiagnosticSinkGuard) that clears the sink on drop, including on a
  panic unwind, instead of relying on a paired install/clear call.
- Removed the stray duplicate schemas/dev/mxc-config.schema.0.dev.json
  (the canonical mxc-config.schema.0.8.0-dev.json already exists on main).
- Removed the zero-call-site deprecated ProcessEventKind/ProcessEventData
  compat types.
- network_manager.rs's initialize_policy now reuses describe_policy's
  NetworkPolicyPlan instead of duplicating the same decision.
- Removed CODE_REVIEW_TRACELOGGING_COMPLIANCE.md, a leaked review artifact.

Low severity:
- Pipe token validation now checks Shannon entropy instead of a
  distinct-byte-count check that a repeated short pattern could satisfy.
- Case-insensitive secret-field key matching no longer allocates a
  lower-cased copy of every key.
- Added a named READ_CONTROL constant replacing a raw hex literal in the
  diagnostic pipe access mask.
- Replied (no code change) to the sha2 0.10/0.11 duplicate-version
  observation: this PR adds one more consumer of an already-duplicated
  version rather than introducing a new duplicate pair; unification is
  tracked as separate follow-up work.

Validated: cargo fmt --all --check, cargo clippy (wxc_common,
appcontainer_common, isolation_session_common, mxc_telemetry, wxc) with
-D warnings, full workspace build, and targeted tests across all five
touched crates (1076 tests passing, 0 failed).

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 8517b504-0321-4b97-9b8b-aaddbb06e6a3

* Fix Windows clippy failures after merge

Co-authored-by: Copilot <[email protected]>

Copilot-Session: aa378d85-8a60-4f11-8ed3-485123cba810

---------

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 84161020-6009-4a46-a320-79d062f2ffa8
Copilot-Session: ff351c1b-421d-433d-b038-b61db4f1da12
Copilot-Session: 8517b504-0321-4b97-9b8b-aaddbb06e6a3
Copilot-Session: aa378d85-8a60-4f11-8ed3-485123cba810
Dan Legg (danlegg) pushed a commit that referenced this pull request Oct 1, 2026
Address the code-review findings on the coresident explicit-load change
(38dbd88). Runtime binding still activates the MSI IsoSessionApp.dll by
absolute path with zero registry mutation; this commit hardens the
surrounding load, error, and diagnostic behavior.

regfree.rs (#1,#5,#6,#7,#8,#9,#10):
- Load the App DLL with LoadLibraryExW using
  LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32 so
  the runtime directory is the sole search root for its dependencies
  (search-order hijack hardening). Reject non-absolute
  MXC_ISOSESSION_RUNTIME_DIR overrides.
- Replace the 2-state load cache with a 3-state RuntimeLoad enum
  (Absent / Loaded / Unloadable). A missing default folder still falls
  back to inbox activation, but an honored-but-broken explicit override
  or a present-but-unloadable DLL now surfaces the error instead of
  silently falling back.
- Report real Win32 errors (GetProcAddress) and null-check the returned
  factory pointer before from_raw.
- Gate success-path eprintln! on MXC_DIAG_CONSOLE.
- Correct the CoInitializeEx SAFETY comment.
- Add unit tests for runtime-dir resolution and app-dll path building.

manager.rs (#2): wrap the over-length activate line for rustfmt.

oneshot.md (#4,#11): document the two activation paths, the
runtime-folder resolution table (MXC_ISOSESSION_RUNTIME_DIR /
DEFAULT_RUNTIME_DIR), apartment init, and prerequisites; fix
RoInitialize -> CoInitializeEx wording.

tests/scripts (#3): accept EITHER inbox (System32 DLL + registry) OR the
coresident MSI runtime dir in the prerequisite probe, so the suites no
longer skip on an MSI-only host.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: f5cc2011-5308-43d6-a8ea-2b8ed9b6ceb3
Dan Legg (danlegg) pushed a commit that referenced this pull request Oct 1, 2026
Address the code-review findings on the coresident explicit-load change
(38dbd88). Runtime binding still activates the MSI IsoSessionApp.dll by
absolute path with zero registry mutation; this commit hardens the
surrounding load, error, and diagnostic behavior.

regfree.rs (#1,#5,#6,#7,#8,#9,#10):
- Load the App DLL with LoadLibraryExW using
  LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32 so
  the runtime directory is the sole search root for its dependencies
  (search-order hijack hardening). Reject non-absolute
  MXC_ISOSESSION_RUNTIME_DIR overrides.
- Replace the 2-state load cache with a 3-state RuntimeLoad enum
  (Absent / Loaded / Unloadable). A missing default folder still falls
  back to inbox activation, but an honored-but-broken explicit override
  or a present-but-unloadable DLL now surfaces the error instead of
  silently falling back.
- Report real Win32 errors (GetProcAddress) and null-check the returned
  factory pointer before from_raw.
- Gate success-path eprintln! on MXC_DIAG_CONSOLE.
- Correct the CoInitializeEx SAFETY comment.
- Add unit tests for runtime-dir resolution and app-dll path building.

manager.rs (#2): wrap the over-length activate line for rustfmt.

oneshot.md (#4,#11): document the two activation paths, the
runtime-folder resolution table (MXC_ISOSESSION_RUNTIME_DIR /
DEFAULT_RUNTIME_DIR), apartment init, and prerequisites; fix
RoInitialize -> CoInitializeEx wording.

tests/scripts (#3): accept EITHER inbox (System32 DLL + registry) OR the
coresident MSI runtime dir in the prerequisite probe, so the suites no
longer skip on an MSI-only host.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: f5cc2011-5308-43d6-a8ea-2b8ed9b6ceb3
Dan Legg (danlegg) pushed a commit that referenced this pull request Oct 6, 2026
Address the code-review findings on the coresident explicit-load change
(38dbd88). Runtime binding still activates the MSI IsoSessionApp.dll by
absolute path with zero registry mutation; this commit hardens the
surrounding load, error, and diagnostic behavior.

regfree.rs (#1,#5,#6,#7,#8,#9,#10):
- Load the App DLL with LoadLibraryExW using
  LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32 so
  the runtime directory is the sole search root for its dependencies
  (search-order hijack hardening). Reject non-absolute
  MXC_ISOSESSION_RUNTIME_DIR overrides.
- Replace the 2-state load cache with a 3-state RuntimeLoad enum
  (Absent / Loaded / Unloadable). A missing default folder still falls
  back to inbox activation, but an honored-but-broken explicit override
  or a present-but-unloadable DLL now surfaces the error instead of
  silently falling back.
- Report real Win32 errors (GetProcAddress) and null-check the returned
  factory pointer before from_raw.
- Gate success-path eprintln! on MXC_DIAG_CONSOLE.
- Correct the CoInitializeEx SAFETY comment.
- Add unit tests for runtime-dir resolution and app-dll path building.

manager.rs (#2): wrap the over-length activate line for rustfmt.

oneshot.md (#4,#11): document the two activation paths, the
runtime-folder resolution table (MXC_ISOSESSION_RUNTIME_DIR /
DEFAULT_RUNTIME_DIR), apartment init, and prerequisites; fix
RoInitialize -> CoInitializeEx wording.

tests/scripts (#3): accept EITHER inbox (System32 DLL + registry) OR the
coresident MSI runtime dir in the prerequisite probe, so the suites no
longer skip on an MSI-only host.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: f5cc2011-5308-43d6-a8ea-2b8ed9b6ceb3
Dan Legg (danlegg) pushed a commit that referenced this pull request Oct 7, 2026
Address the code-review findings on the coresident explicit-load change
(38dbd88). Runtime binding still activates the MSI IsoSessionApp.dll by
absolute path with zero registry mutation; this commit hardens the
surrounding load, error, and diagnostic behavior.

regfree.rs (#1,#5,#6,#7,#8,#9,#10):
- Load the App DLL with LoadLibraryExW using
  LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32 so
  the runtime directory is the sole search root for its dependencies
  (search-order hijack hardening). Reject non-absolute
  MXC_ISOSESSION_RUNTIME_DIR overrides.
- Replace the 2-state load cache with a 3-state RuntimeLoad enum
  (Absent / Loaded / Unloadable). A missing default folder still falls
  back to inbox activation, but an honored-but-broken explicit override
  or a present-but-unloadable DLL now surfaces the error instead of
  silently falling back.
- Report real Win32 errors (GetProcAddress) and null-check the returned
  factory pointer before from_raw.
- Gate success-path eprintln! on MXC_DIAG_CONSOLE.
- Correct the CoInitializeEx SAFETY comment.
- Add unit tests for runtime-dir resolution and app-dll path building.

manager.rs (#2): wrap the over-length activate line for rustfmt.

oneshot.md (#4,#11): document the two activation paths, the
runtime-folder resolution table (MXC_ISOSESSION_RUNTIME_DIR /
DEFAULT_RUNTIME_DIR), apartment init, and prerequisites; fix
RoInitialize -> CoInitializeEx wording.

tests/scripts (#3): accept EITHER inbox (System32 DLL + registry) OR the
coresident MSI runtime dir in the prerequisite probe, so the suites no
longer skip on an MSI-only host.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: f5cc2011-5308-43d6-a8ea-2b8ed9b6ceb3
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.

2 participants