-
Notifications
You must be signed in to change notification settings - Fork 49
Permissive Learning Mode 1/6 audit skeleton #584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lilybarkley-msft
wants to merge
24
commits into
main
Choose a base branch
from
user/lilybarkley/plm-pr1-audit-skeleton
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
8c0f5b7
PLM split PR1: audit-mode plumbing and trace lifecycle
lilybarkley-msft 6e255c2
Remove round-N review markers from CI workflow comments
lilybarkley-msft 3e0478c
PLM CI: restrict integration tests to filesystem fixtures (headless)
lilybarkley-msft a7f10e2
PLM PR1 fix #1: build plm cross-platform via no-op stub main
lilybarkley-msft 7d7f4a8
PLM PR1 review fixes: quiet --audit, w! macro, chrono scope, WPR race
lilybarkley-msft 94de54b
PLM PR1 review batch 2 fixes: comment cleanup, MIT headers, workspaceβ¦
lilybarkley-msft 18fe0fd
Gate plm_ctrl_handler on target_os = "windows"
lilybarkley-msft 72606c7
Regenerate dev schema to match wire model
lilybarkley-msft f09b340
Soften README claim about plm stop parsing (not yet wired on this PR)
lilybarkley-msft badb6b2
Move --with-bfs to filesystem PR
lilybarkley-msft 5222d79
Drop debug_assertions branch on permissiveLearningMode gate
lilybarkley-msft 7b1dcbe
Shorten audit-mode README section; link to plm readme
lilybarkley-msft 0e25d9b
Byte-verify staged plm.wprp against embedded profile before rename
lilybarkley-msft 2da4ff1
Verify wpr.exe Authenticode signature before every plm invocation
lilybarkley-msft 64d1838
Remove inline PLM integration test step from Build.Windows.Job
lilybarkley-msft a980d44
Drop serde_json preserve_order feature
lilybarkley-msft 16fd29c
Remove Tessera codename from docs
lilybarkley-msft 5424928
plm: address PR584 review β capture wpr/plm stdio, harden singleton, β¦
lilybarkley-msft 6e46795
plm: move PLM_TRACE_ACTIVE ownership onto AcquiredSingleton
lilybarkley-msft d277890
plm: replace WinVerifyTrust with existence check for wpr.exe
lilybarkley-msft af003bb
plm: suppress `wpr -stop` progress bar in `plm log` happy path
lilybarkley-msft cdf6d21
plm: spawn wpr.exe with CREATE_NO_WINDOW to suppress its progress bar
lilybarkley-msft 0fd93c4
plm(pr1): remove forward-looking future-PR language in module docs
lilybarkley-msft 2feb58e
wxc-exec: auto-elevate --audit via UAC self-relaunch
lilybarkley-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| [package] | ||
| name = "plm" | ||
| version = "0.1.0" | ||
| edition.workspace = true | ||
|
|
||
| [lib] | ||
| name = "plm" | ||
| path = "src/lib.rs" | ||
|
|
||
| [[bin]] | ||
| name = "plm" | ||
| path = "src/main.rs" | ||
|
|
||
| [dependencies] | ||
| clap.workspace = true | ||
| anyhow.workspace = true | ||
| # Portable deps (config / access_event / event_parser) must compile on | ||
| # every target so their unit tests run in cross-platform CI. The | ||
| # `windows` crate stays target-gated below. | ||
| serde_json.workspace = true | ||
| chrono.workspace = true | ||
| roxmltree.workspace = true | ||
|
|
||
| [target.'cfg(target_os = "windows")'.dependencies] | ||
| windows = { workspace = true, features = [ | ||
| "Win32_System_EventLog", | ||
| "Win32_System_SystemInformation", | ||
| "Win32_System_Threading", | ||
| ] } | ||
| wxc_common = { workspace = true } | ||
|
|
||
| [build-dependencies] | ||
| mxc_build_common.workspace = true | ||
|
|
||
| [dev-dependencies] | ||
| tempfile.workspace = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| //! Build script for plm β embeds Windows VersionInfo. | ||
|
|
||
| fn main() { | ||
| mxc_build_common::embed_version_info("MXC permissive learning mode", "plm.exe"); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| # PLM β Permissive Learning Mode | ||
|
|
||
| `plm.exe` is the Windows-only trace driver for permissive learning mode. Long-form, it captures the access-denied events emitted by Windows' permissive sandbox layer, decodes them into structured findings, and merges those findings back into an MXC container config so the next enforcing run succeeds. | ||
|
|
||
| This PR introduces the **trace-lifecycle skeleton only**: WPR start/stop, the host-wide singleton mutex, the embedded `plm.wprp` materializer, and the `wxc-exec --audit` plumbing. Event parsing, capability extraction, filesystem/UI merging, and the adjusted-config writer arrive in subsequent PRs. | ||
|
|
||
| PLM is invoked automatically by [`wxc-exec --audit`](../../../README.md#audit-mode-permissive-learning-mode); the standalone CLI documented here is for capturing traces, interactive iteration, and (later) debugging the parser itself. | ||
|
|
||
| ## How it works (skeleton) | ||
|
|
||
| 1. **Capture** β `plm start` calls `wpr -start <plm.wprp>!AccessFailureProfile -filemode`, enabling the `Microsoft-Windows-Privacy-Auditing-PermissiveLearningMode` and `Microsoft-Windows-Kernel-General` ETW providers in a secure realtime collector. | ||
| 2. **Run** β the operator runs the workload. The OS-side permissive sandbox logs `EventID=14` / `EventID=27` for every access that *would* have been denied. | ||
| 3. **Stop** β `plm stop` calls `wpr -stop <trace.etl>` and records the captured trace location. | ||
| 4. **Parse / Merge** β *(arrives in later PRs)* the `.etl` is walked with `EvtQuery` / `EvtRender` and findings are merged into a copy of the input config as `Adjusted_<name>.json`. | ||
|
|
||
| ## Layout (this PR) | ||
|
|
||
| | File | Role | | ||
| |-----------------------|-------------------------------------------------------------------------------------| | ||
| | `src/main.rs` | `clap` dispatch for `plm start` / `plm stop` / `plm log` (`extract-caps` lands later) | | ||
| | `src/start.rs` | `wpr -cancel` (best-effort) + `wpr -start β¦!AccessFailureProfile -filemode` | | ||
| | `src/stop.rs` | `wpr -stop` (or skip with `--trace-file`); parse + merge arrive in later PRs | | ||
| | `src/log.rs` | Interactive mode: Enter to start, Enter to stop; preview arrives in later PRs | | ||
| | `src/coordination.rs` | Cross-process singleton named-mutex + bypass-env-var coordination for `plm log` | | ||
| | `src/wpr_path.rs` | Resolves `wpr.exe` to its absolute `%SystemRoot%\System32` path (PATH-spoof-safe) | | ||
| | `src/profile_gen.rs` | Inline WPR profile (`EMBEDDED_WPRP`) + run-time writer that drops `plm.wprp` next to `plm.exe` when missing | | ||
|
|
||
| ## CLI | ||
|
|
||
| ### `plm start` | ||
|
|
||
| Cancels any in-progress WPR session and starts a new permissive-learning-mode trace. | ||
|
|
||
| ```powershell | ||
| plm.exe start [--wprp <path>] | ||
| ``` | ||
|
|
||
| | Flag | Default | Purpose | | ||
| |------------|------------------------|---------------------------------------------------------------| | ||
| | `--wprp` | `<exe dir>\plm.wprp` | Override the WPR profile path. By default `plm` materializes its embedded profile next to the exe on first use; an existing `plm.wprp` is never overwritten, so operator hand-edits are preserved. | | ||
|
|
||
| ### `plm stop` | ||
|
|
||
| Stops the active trace (or accepts a previously captured one). | ||
|
|
||
| ```powershell | ||
| plm.exe stop [--config-path <path>] [--log-dir <path>] [--bin-path <path>] | ||
| [--adjusted-config-path <path>] [--trace-file <path>] | ||
| [--verbose-logging] | ||
| ``` | ||
|
|
||
| `--config-path` / `--adjusted-config-path` are accepted today so `wxc-exec --audit` can pass them through; the merge that consumes them arrives in subsequent PRs. | ||
|
|
||
| ### `plm log` | ||
|
|
||
| Interactive iteration mode: press Enter to start a trace, run the workload, press Enter again to stop. The "diff against a blank config" preview arrives in later PRs. | ||
|
|
||
| ```powershell | ||
| plm.exe log [--wprp <path>] [--verbose-logging] | ||
| ``` | ||
|
|
||
| ## Building | ||
|
|
||
| PLM is part of the MXC workspace but excluded from `default-members` because it's Windows-only. Build it explicitly: | ||
|
|
||
| ```powershell | ||
| cd C:\src\mxc\src | ||
| cargo build -p plm --target x86_64-pc-windows-msvc | ||
| # or for release: | ||
| cargo build -p plm --target x86_64-pc-windows-msvc --release | ||
| ``` | ||
|
|
||
| The WPR profile is embedded into `plm.exe` itself (see `src/profile_gen.rs`); on first use of `plm start` / `plm log`, `profile_gen::ensure_wprp_next_to_exe` writes it to disk next to the binary if no `plm.wprp` is already present. `build.bat` from the repo root builds `plm.exe` and stages it next to `wxc-exec.exe` for the `--audit` integration. | ||
|
|
||
| ## Limitations | ||
|
|
||
| - **Windows-only.** Uses `wpr.exe` and Job-Object UI-limit semantics that have no portable equivalent. | ||
| - **No parse-and-merge yet.** `plm stop` writes the captured `.etl` to the log directory but does not yet produce an `Adjusted_*.json`. Later PRs add file-path extraction, capability extraction, UI-policy extraction, and the adjusted-config writer. | ||
|
|
||
| ## See also | ||
|
|
||
| - [`docs/base-process-container/guide.md`](../../../docs/base-process-container/guide.md) β process-container backend overview | ||
| - [README β Debugging β Audit Mode](../../../README.md#audit-mode-permissive-learning-mode) β `wxc-exec --audit` integration |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.