Uh oh!
There was an error while loading. Please reload this page.
[Bubblewrap] Add optional type discriminator to deniedPaths entries - #640
[Bubblewrap] Add optional type discriminator to deniedPaths entries#640Soham Das (SohamDas2021) wants to merge 3 commits into
type discriminator to deniedPaths entries#640Conversation
There was a problem hiding this comment.
Pull request overview
Adds an optional "type": "file" | "directory" discriminator for filesystem.deniedPaths entries (string form still supported) so Linux Bubblewrap masking can be deterministic even when the denied path doesn’t exist on the host. This flows from Rust wire/schema → SDK types → Bubblewrap runner behavior, and includes new Bubblewrap tests and docs updates.
Changes:
- Extend the wire model + dev schema so
deniedPathsacceptsstring | { path, type? }, and update TS wire emitter to handleanyOfunion definitions. - Plumb declared kinds through parsing (
denied_path_kinds) and use them in Bubblewrap denied-path classification + symlink resolution + post-run stub cleanup. - Add Bubblewrap regression test config + script and document the new behavior in schema and Bubblewrap backend docs.
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/scripts/run_bwrap_denied_kind_test.sh | New end-to-end Bubblewrap test for missing denied file vs missing denied dir with declared kinds |
| tests/scripts/run_bwrap_all_tests.sh | Includes the new denied-kind test in the Bubblewrap test suite |
| tests/configs/bubblewrap_denied_kind.json | Test config exercising typed deniedPaths entries |
| src/core/wxc_common/src/wire.rs | Wire model: introduce PathKind, DeniedPathObject, DeniedPathEntry; widen denied_paths type |
| src/core/wxc_common/src/ts_emit.rs | TS emitter: handle anyOf definitions as unions; unwrap $ref wrapped in allOf |
| src/core/wxc_common/src/models.rs | Domain model: add PathKind and denied_path_kinds map to ContainerPolicy |
| src/core/wxc_common/src/config_parser.rs | Parse typed denied entries into denied_paths + denied_path_kinds, with unit tests |
| src/backends/bubblewrap/common/src/bwrap_runner.rs | Use declared kinds for masking classification; re-key kinds on symlink resolution; stub cleanup logic |
| sdk/src/types.ts | Public SDK types: DeniedPathEntry/DeniedPathObject; widen deniedPaths fields accordingly |
| sdk/src/index.ts | Export the new denied-path types |
| sdk/src/generated/wire.ts | Generated wire TS updated for new denied-path union + PathKind |
| schemas/dev/mxc-config.schema.0.8.0-dev.json | Dev schema updated for denied-path union/object + PathKind |
| docs/schema.md | Document widened deniedPaths syntax and Bubblewrap honoring behavior |
| docs/sandbox-policy/v1/policy.md | Update policy type + table docs for typed denied paths |
| docs/bwrap-support/bubblewrap-backend.md | Document deterministic masking via type, conflict behavior, and host-stub cleanup |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Soham Das (SohamDas2021)
commented
Jul 14, 2026
Copilot resolve the merge conflicts in this pull request |
Resolved. The base branch (
|
Soham Das (SohamDas2021)
commented
Jul 14, 2026
Copilot resolve the merge conflicts in this pull request |
Resolved in commit |
Gudge (MGudgin)
left a comment
There was a problem hiding this comment.
I think we should do the work to add 'type' to the policy language at the same time as we do the work to add 'leaf' vs 'tree'. And I think we should do it independently of work on any given back-end.
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>
Take the reconciled bwrap_runner.rs from the #640 cloud-agent review line: rename the rewrite flag to any_path_rewritten, warn on declared- kind key collisions when re-keying a symlinked denied path onto a target that already has a declared type (target takes precedence), and keep the non-UTF-8 host-path fail-closed guard. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
204f072 to
d46c1dbCompare* [LXC] Harden denied-path masking + add most-specific-path resolver (AB#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 * [LXC] Observe host path for denied-mask kind + tolerate trailing-slash 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> * [LXC] Scope PR to most-specific-path resolver; drop file/dir schema work Address review feedback on #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 #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> * [LXC] Address review: host-reality denied mask, drop redundant collapse Addresses the change requests on PR #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> * [LXC] Add sample configs for denied-path masking + most-specific-path PR #630 changes LXC filesystem policy behavior but shipped no tests/configs sample; the parallel Bubblewrap work (#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 * [LXC] Wire denied-masking configs into LXC and WSLC test runners 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 #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 --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
📖 Description
Builds on #623 (denied-path masking). A denied path must be masked differently depending on whether it is a file (
--ro-bind /dev/null) or a directory (--tmpfs). When a denied path does not exist on the host, the runner has no way to know which kind of stub to create, so this change lets a caller declare the kind explicitly.deniedPathsentries may now be either a plain string (unchanged) or an object with an optionaltypediscriminator:🔗 References
🔍 Validation
✅ Checklist
Cargo.lock, thedependency-feed-checkcheck passes (see docs/pull-requests.md)📋 Issue Type
GitHub Actions runs the PR validation build automatically. The ADO pipeline
(
MXC-PR-Build) is the Azure version of the PR pipeline, kept in parity with the GitHubActions build; it runs on merge to
main, and Microsoft reviewers with write access can trigger iton a PR with
/azp run. See docs/pull-requests.md.If the
dependency-feed-checkcheck fails on a new dependency, the crate must be added tothe feed before the PR can pass. See docs/pull-requests.md
for the steps.
Microsoft Reviewers: Open in CodeFlow