Uh oh!
There was an error while loading. Please reload this page.
[LXC] Address file system policy gaps - #630
Conversation
…B#62861419) - Replace is_file() masking heuristic with explicit `type` schema field + symlink_metadata() fallback (no symlink follow; fail-closed on missing+untyped). - Add reusable most-specific-path-wins resolver in wxc_common (deny>ro>rw); wire LXC mounts to emit in specificity order. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3b78bec0-e139-4cfd-9c10-092ef986d4f4
There was a problem hiding this comment.
Pull request overview
This PR hardens filesystem policy handling by extending the wire format for filesystem.deniedPaths and introducing a reusable “most-specific-path-wins” resolver to produce deterministic mount emission order for Linux backends.
Changes:
- Extend
deniedPathsto accept either a legacy string or an object{ path, type: "file" | "dir" }, and plumb the parsed mask kind intoContainerPolicy. - Add
wxc_common::path_specificityto resolve overlapping filesystem intents by specificity (deep overrides shallow; exact ties pick most restrictive). - Update LXC mount emission to use the new resolver and apply explicit denied-path mask kinds.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/core/wxc_common/src/wire.rs | Changes wire model so deniedPaths supports string or typed object entries. |
| src/core/wxc_common/src/ts_emit.rs | Updates TS emitter to correctly emit anyOf unions and allOf wrappers as TypeScript type aliases. |
| src/core/wxc_common/src/path_specificity.rs | Introduces the new most-specific-path-wins resolver and tests. |
| src/core/wxc_common/src/models.rs | Adds MaskKind and denied_path_kinds to ContainerPolicy for backend masking decisions. |
| src/core/wxc_common/src/lib.rs | Exposes the new path_specificity module. |
| src/core/wxc_common/src/filesystem_resolve.rs | Keeps compatibility by re-exporting the resolver from the new module. |
| src/core/wxc_common/src/config_parser.rs | Converts wire denied-path entries into denied_paths + denied_path_kinds in the domain policy. |
| src/backends/lxc/common/src/filesystem_mounts.rs | Switches mount emission ordering to the resolver and adds explicit denied-path masking logic. |
| sdk/src/generated/wire.ts | Regenerates TS wire types for the new DeniedPath union/object forms. |
| schemas/dev/mxc-config.schema.0.8.0-dev.json | Regenerates the dev schema to reflect the new denied-path shapes. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…h keys Address PR review feedback on denied-path masking: - `observed_mask_path_kind` now takes `&Path` and inspects the *host* path instead of the container rootfs path (`.../rootfs/<container_path>`). The rootfs path does not exist before mounts are applied, so the previous code returned `NotFound` for real host denied paths and spuriously demanded an explicit `type`, breaking existing LXC object-policy validation. Also drops the `to_string_lossy()` allocation by passing `&Path` directly. - Add `lookup_mask_kind` with trailing-separator normalization so an explicit `type` is not dropped when the resolved mount path and the configured `denied_path_kinds` key differ only by a trailing slash. - Add unit tests for host-path observation (dir/file/missing) and normalized kind lookup. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
Soham Das (SohamDas2021)
commented
Jul 13, 2026
Since this might be touching common code, make sure all lxc and bwrap tests/configs pass |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Address review feedback on microsoft#630: - Remove the denied-path file/dir `type` discriminator (wire DeniedPath union, MaskKind, denied_path_kinds, regenerated schema + TS wire types, ts_emit anyOf/allOf handling, and the LXC mask-kind logic). Per reviewer guidance the file-vs-dir schema distinction is deferred (to be designed alongside leaf/tree), and the wire change duplicates bwrap microsoft#640. - Keep the most-specific-path-wins resolver but extend `filesystem_resolve` in place instead of renaming it to `path_specificity` with a compat shim, avoiding churn / conflict surface with the bwrap branches. Delete path_specificity.rs and the shim. - Fix the `dedup_by` dead code: the retained element is the earlier `b`, so mutating `a` was a no-op. Rely on the most-restrictive-first sort (with a comment) and add a test asserting the kept path string on an exact-key conflict across lists that differ only by a trailing slash. - Revert LXC denied-path masking to its original behavior while still emitting mounts in resolver (shallow->deep) order. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Soham Das (SohamDas2021)
commented
Jul 14, 2026
The PR description is stale and still says that you update the schema. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e5d2aa5b-7f04-4e4d-83d3-a02efe7020ab
Addresses the change requests on PR microsoft#630: - filesystem_mounts.rs: classify denied paths from the HOST path (via symlink_metadata, never following symlinks) instead of the not-yet-existing rootfs path, so a denied host file is masked with /dev/null (create=file) and a directory/symlink/missing path with an empty tmpfs (create=dir). - filesystem_resolve.rs: drop the exact-path most-restrictive collapse from resolve_path_plan; it duplicated the upstream normalize_filesystem_paths (config parser) and normalize_object_conflicts (every runner). The resolver now only orders shallow-to-deep, and emission order still yields most-restrictive-wins for any same-path duplicate that survives upstream. - filesystem_resolve.rs: move the test-only effective_intent oracle into the tests module and gate PathKey::is_prefix_of to test builds. Updated affected unit tests. cargo fmt/clippy clean; wxc_common 398 tests pass; lxc_common + bwrap_common clippy clean on x86_64-unknown-linux-gnu. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Darren Hoehna (dhoehna)
commented
Jul 15, 2026
Addressed the change requests in bae58f5:
Also refreshed the stale PR description (no schema/wire changes remain). Validation (this is a Windows dev box, so the LXC/bwrap E2E shell suites — which need a Linux host with
Rebased onto the latest branch tip (post main-merge 037907d) before pushing. |
Darren Hoehna (dhoehna)
commented
Jul 17, 2026
🧪 Local test re-verification — 2026-07-17Re-ran the test suites locally at branch tip Windows host (
Linux (WSL2 Ubuntu-24.04,
Note: the |
PR microsoft#630 changes LXC filesystem policy behavior but shipped no tests/configs sample; the parallel Bubblewrap work (microsoft#623) added one per scenario. Add the LXC equivalents so the behavior is demonstrated in action and covered by the config-validation gate: - lxc_denied_masking.json: a denied regular file is masked with a /dev/null bind (create=file); a denied directory with an empty ro tmpfs (create=dir). - lxc_denied_symlink_dir.json / lxc_denied_symlink_file.json: a denied symlink is classified via symlink_metadata (never followed) and masked with an empty ro tmpfs, so neither the target dir nor file leaks. - lxc_most_specific_denied_parent.json: a readwrite child under a denied parent stays readable/writable while the parent sibling is masked (most-specific-path-wins resolver). All four validate against schemas/dev/mxc-config.schema.0.8.0-dev.json (node scripts/versioning/validate-configs.js: 190 configs OK). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b6b3323b-7297-4b07-9e6e-ab4b220124e6
Darren Hoehna (dhoehna)
commented
Jul 20, 2026
Soham Das (@SohamDas2021) -- added the missing LXC sample configs demonstrating this PR's filesystem-policy behavior (commit c9373ef), mirroring the Bubblewrap denied-masking config set from #623:
Scope note: after dropping the file/dir schema |
| @@ -0,0 +1,19 @@ | |||
| { | |||
There was a problem hiding this comment.
Please make sure the new jsons are added to tests\scripts\run_wslc_all_tests.ps1
There was a problem hiding this comment.
Done. I've wired the new filesystem-policy configs into both test runners.
WSLC runner (tests/scripts/run_wslc_all_tests.ps1): added two native WSLC variants -- wslc_denied_masking.json and wslc_most_specific_denied_parent.json -- each with a wrapper (run_wslc_denied_masking_test.ps1, run_wslc_most_specific_test.ps1) that owns its Windows fixture. They use the WSLC "denied path = not mounted" model (policy_mapping.rsbuild_volume_mounts).
Why not the lxc_* configs directly in the WSLC harness: on Windows, wxc-exec cannot run containment:"lxc" configs -- run.rs:181 returns unsupported_containment("LXC backend not available on Windows"), so they would hard-fail rather than test anything.
LXC runner (tests/scripts/run_lxc_all_tests.sh): registered the four lxc_* configs via run_lxc_denied_masking_test.sh and run_lxc_most_specific_test.sh (they run under lxc-exec on Linux, same as the bwrap wrappers).
I intentionally skipped WSLC symlink variants: Windows file-symlinks require admin/Developer Mode, and the "denied alias not mounted" semantics they'd exercise are already covered by wslc_filesystem_object.json. Happy to add them if you'd prefer full parity.
All 192 configs pass node scripts/versioning/validate-configs.js. Pushed as 5a28fe5.
Register the four lxc_* filesystem-policy configs from c9373ef with the Linux LXC runner, and add equivalent wslc_* variants to the Windows WSLC runner, per Soham's review note on PR microsoft#630. LXC (Linux, lxc-exec): - run_lxc_denied_masking_test.sh drives lxc_denied_masking, lxc_denied_symlink_dir, lxc_denied_symlink_file. - run_lxc_most_specific_test.sh drives lxc_most_specific_denied_parent. - Both registered in run_lxc_all_tests.sh. WSLC (Windows, wxc-exec): the lxc_* configs cannot run on the WSLC harness (run.rs:181 returns unsupported_containment for Lxc on Windows), so add native wslc_* variants using the WSLC "denied path = not mounted" model (policy_mapping.rs): - wslc_denied_masking.json + run_wslc_denied_masking_test.ps1 - wslc_most_specific_denied_parent.json + run_wslc_most_specific_test.ps1 - Both registered in run_wslc_all_tests.ps1. WSLC symlink variants intentionally omitted: Windows file-symlinks need admin/Developer Mode, and the "denied alias not mounted" semantics are already covered by wslc_filesystem_object.json. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b6b3323b-7297-4b07-9e6e-ab4b220124e6
Uh oh!
There was an error while loading. Please reload this page.
Resolve conflict in src/backends/lxc/common/src/filesystem_mounts.rs as a union of both changes: - microsoft#633 mount-accumulation fix: clear_config_item("lxc.mount.entry") before re-deriving the policy's mounts (so a restart replaces, not unions, mounts). - upstream microsoft#630 denied-dir masking: rebound_container_paths / has_rebound_descendant, iterating &mounts. Both new unit tests (configure_filesystem_mounts_replaces_not_accumulates and has_rebound_descendant_detects_nested_rebind_only) are kept. Validated with `cargo check -p lxc_common --tests` (native linux/liblxc, WSL). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b6b3323b-7297-4b07-9e6e-ab4b220124e6
Linked work item: AB#62861419 — [LXC] Address file system policy gaps
Summary
Hardens LXC denied-path masking and adds a reusable most-specific-path-wins policy resolver in
wxc_common. No schema or wire-format changes — see the Schema note below.<lxc_path>/<name>/rootfs/<container_path>) does not exist until mounts are applied, so inspecting it always misclassified the mask as a directory. A regular host file is now masked with a read-only/dev/nullbind (create=file); a directory, symlink, or missing host path with an empty read-only tmpfs (create=dir). Classification usessymlink_metadataso a symlinked deny is never followed to an unintended target.filesystem_resolvemodule inwxc_commonin place (no module rename / compat shim). Paths are emitted shallow-to-deep so the deepest (most specific) intent wins at every path regardless of which policy list it came from (e.g.readwritePaths: [""/data/secrets""]survivesdeniedPaths: [""/data""]). Exact same-path conflicts are not re-collapsed in the resolver — that is already handled upstream by the config parser'snormalize_filesystem_paths(string-level) and each runner'snormalize_object_conflicts(object-identity); for any duplicate that still reaches the resolver, emission order (denied emitted last) preserves most-restrictive-wins.Schema
No schema or wire-format changes. The earlier
type: ""file"" | ""dir""discriminator — and theMaskKind/denied_path_kindsmodel fields — have been dropped. Per the discussion on this PR, the file/dir (and leaf/tree) distinction will be handled as separate schema work, and the shared schema/wire surface is owned by #640 (user/sodas/bwrap-denied-path-type), which LXC will consume once it lands. This PR is scoped to the resolver + host-reality masking and touches no files underschemas/orsdk/src/generated/.Validation
cargo fmt --all -- --check— cleancargo clippy -p wxc_common --all-targets -- -D warnings(Windows) andcargo clippy --target x86_64-unknown-linux-gnu -p lxc_common -p bwrap_common --all-targets -- -D warnings— cleancargo test -p wxc_common— 397 passedcargo checkforlxc_common+bwrap_commononx86_64-unknown-linux-gnu— passIndependent of the sibling LXC branches (no shared model fields).
Microsoft Reviewers: Open in CodeFlow