Repository navigation
[Bubblewrap] 2/2: Map root workloads to reserved subordinate IDs - #1814
Open
Soham Das (SohamDas2021) wants to merge 5 commits into
Open
Soham Das (SohamDas2021) wants to merge 5 commits into
Soham Das (SohamDas2021) wants to merge 5 commits into
Conversation
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The change introduces unaccepted breaking behavior for existing V1 root callers, and a unit test panics on older supported Linux kernels while leaving child processes running.
2 open issues
What changed in this PR
Completes the Bubblewrap hardening started in #1734 by mapping root-launched workloads to reserved subordinate UID/GID ranges. Non-root identity behavior remains unchanged.
Changes:
- Adds mapped-identity validation, filesystem access checks, separate root network supervision, and workload lifetime cleanup.
- Preserves piped stdio when the host has standard descriptors closed.
- Adds root regression coverage, temporary CI allocation provisioning and restoration, and prerequisite/migration documentation.
| File | Description |
|---|---|
tests/scripts/run_bwrap_root_lifetime_test.sh |
Tests cleanup after exit, timeout, and termination signals. |
tests/scripts/run_bwrap_resolver_isolation_test.sh |
Adapts namespace and ownership fixtures for root workloads. |
tests/scripts/run_bwrap_identity_rejection_test.sh |
Tests allocation validation and account-lookup failures. |
tests/scripts/run_bwrap_dns_test.sh |
Supports root and non-root DNS fixtures. |
tests/scripts/run_bwrap_capabilities_test.sh |
Checks mapped identities, permissions, and supervisor separation. |
tests/scripts/run_bwrap_all_tests.sh |
Registers the new root-only suites. |
tests/scripts/README.md |
Documents root test coverage and prerequisites. |
src/mxc-sdk/tests/fixtures/module_lifetime.rs |
Allows unused filesystem-probe helpers in the fixture. |
src/mxc-sdk/tests/fixtures/bubblewrap/root_allocations.json |
Supplies shared allocation-validation cases. |
src/mxc-sdk/src/core/mxc_common/filesystem_probe.rs |
Adds bounded batch filesystem probes. |
src/mxc-sdk/src/core/mxc_common/filesystem_access.rs |
Shortens access-check comments; behavior is unchanged. |
src/mxc-sdk/src/backends/bubblewrap/common/resolver_file.rs |
Reads resolver snapshots with workload credentials. |
src/mxc-sdk/src/backends/bubblewrap/common/proxy_network.rs |
Separates supervisor identity and passes generated files by descriptor. |
src/mxc-sdk/src/backends/bubblewrap/common/mod.rs |
Registers the Linux identity module. |
src/mxc-sdk/src/backends/bubblewrap/common/identity.rs |
Implements allocation checks, mapped helpers, watchdogs, and tests. |
src/mxc-sdk/src/backends/bubblewrap/common/bwrap_runner.rs |
Integrates mapped launches, cleanup, and stdio handling. |
scripts/ci/test_bwrap_root_ids.py |
Tests allocation selection and configuration restoration. |
scripts/ci/run_backend_validation_tests.sh |
Requires root identity and lifecycle regressions. |
scripts/ci/bwrap-root-ids.py |
Provisions and restores disposable CI subordinate allocations. |
docs/schema.md |
Documents mapped-identity grant checks. |
docs/development/build-and-test/ci-validation-infrastructure.md |
Describes root validation and CI provisioning. |
docs/development/architecture/versioning.md |
Records the V1 security-servicing exception. |
docs/backends/bwrap/bubblewrap-backend.md |
Explains root prerequisites, ownership, and cleanup behavior. |
.github/workflows/Validation.Tests.Matrix.Job.yml |
Adds allocation setup and restoration to scheduled validation. |
.github/workflows/Build.Linux.Job.yml |
Adds identity tests, root regressions, and allocation cleanup. |
Review effort: Balanced
Comment on lines
+372
to
+373
| let root_identity = | ||
| RootIdentity::for_caller().map_err(|error| ScriptResponse::error(&error))?; |
|
|
||
| #[test] | ||
| fn a_watchdog_kills_its_sandbox_when_the_launcher_exits_or_its_socket_closes() { | ||
| use std::os::unix::process::ExitStatusExt; |
Co-authored-by: Copilot App <[email protected]>
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The root-execution changes break published V1 behavior without recorded maintainer acceptance, and a non-ignored test panics on supported Linux 3.8–5.2 kernels while leaving child processes running.
2 open issues
Review effort: Balanced
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


📖 Description
When MXC runs as root, Bubblewrap workloads now run as UID and GID 1000 in a user namespace mapped to root's reserved ranges in
/etc/subuidand/etc/subgid, with no supplementary groups or capabilities. No sandbox ID maps to host UID or GID 0. Previously, root's workloads ran as host root and kept root-owner access to the host files exposed to them.MXC checks grants, and reads the host's hosts and resolver files, as the mapped IDs, so a grant those IDs cannot use is rejected before launch. The root network supervisor stays in the host user namespace. Bubblewrap's parent-death signal cannot reach another host UID, so a helper running as the mapped IDs stops the sandbox when Bubblewrap or MXC exits. Missing, invalid, or conflicting allocations, or a failed account lookup, reject startup; MXC never edits allocations.
Non-root launches are unchanged. Separately, SDK launches that use pipes now keep the workload's stdio when the host has descriptor 0, 1, or 2 closed.
Part 2 of 2. Root callers must reserve ranges, run Linux 5.3 or later, and give the mapped IDs access to each granted path, and to
TMPDIRwhen a missingdeniedPathsentry needs an overlay. Files the workload creates belong to the mapped IDs.docs/development/architecture/versioning.mdrecords this V1 change as a security-servicing exception, which needs maintainer acceptance. Request JSON and SDK APIs are unchanged, so no spec is required. CI reserves disposable ranges withscripts/ci/bwrap-root-ids.pyand runs the root suites.🔗 References
Follows #1734 (part 1 of 2, merged), which drops all workload capabilities. No public issue linked.
🔍 Validation
WSL2: unprivileged tests on Ubuntu 24.04.4 with Bubblewrap 0.9.0; root suites in disposable Ubuntu 24.04.5 (Bubblewrap 0.9.0) and 26.04.1 (Bubblewrap 0.11.1) distributions. Rust commands ran from
src/.cargo fmt --all -- --check— passed.cargo clippy -p mxc-sdk --all-targets --locked -- -D warnings, on Windows — passed.cargo clippy --target x86_64-unknown-linux-gnu --locked --all-targets --all-features --release -- -D warnings, fromsrc/tools/lxc— passed.cargo test --locked --release -p mxc-sdk --lib -- backend_modules::bubblewrap::common:: filesystem_— 540 passed.MXC_BWRAP_TESTS_REQUIRE_EXECUTION=1 cargo test --locked --release -p mxc-sdk --test streaming_bubblewrap— 19 passed.MXC_BWRAP_TESTS_REQUIRE_EXECUTION=1 cargo test --locked --release -p mxc-sdk --test wxc_e2e_tests_e2e_bubblewrap_characterization— 15 passed.python3 scripts/ci/test_bwrap_root_ids.py— 10 passed.sudo, afterbwrap-root-ids.py setup --disposable-ci-host:bash scripts/ci/run_backend_validation_tests.sh bubblewrap <bin>— passed. Strictrun_bwrap_all_tests.shpassed 24 suites, then every root suite and the fiveidentity::tests::root_*tests passed.bash tests/scripts/run_bwrap_<suite>_test.shforidentity_rejection,capabilities,dns,resolver_isolation,root_lifetime, andinbound_deny, and the fiveidentity::tests::root_*tests with--ignored --exact— each passed.Each root regression test fails without its change: the stop helper, the mapped group's access to the private overlay storage (under umask
077), the mapped-identity host-file reads, keeping the supervisor in the host user namespace, and the stdio pipe fix.Not run: remote CI, the Windows all-features workspace lint, macOS, arm64, RHEL 10, Debian 13, and kernels without
pidfd_open.✅ Checklist
feature-acceptedCargo.lock, thedependency-feed-checkcheck passes (see pull request builds)📋 Issue Type
Microsoft Reviewers: Open in CodeFlow