Skip to content

[Bubblewrap] 2/2: Map root workloads to reserved subordinate IDs - #1814

Open
Soham Das (SohamDas2021) wants to merge 5 commits into
mainfrom
sohamdas2021-bubblewrap-uid-mapping
Open

Soham Das (SohamDas2021) wants to merge 5 commits into
mainfrom
sohamdas2021-bubblewrap-uid-mapping

Conversation

@SohamDas2021

@SohamDas2021 Soham Das (SohamDas2021) commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

📖 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/subuid and /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 TMPDIR when a missing deniedPaths entry needs an overlay. Files the workload creates belong to the mapped IDs. docs/development/architecture/versioning.md records 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 with scripts/ci/bwrap-root-ids.py and 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, from src/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.
  • On 24.04.5, as an unprivileged user with passwordless sudo, after bwrap-root-ids.py setup --disposable-ci-host: bash scripts/ci/run_backend_validation_tests.sh bubblewrap <bin> — passed. Strict run_bwrap_all_tests.sh passed 24 suites, then every root suite and the five identity::tests::root_* tests passed.
  • On 26.04.1, as root, after the same setup: bash tests/scripts/run_bwrap_<suite>_test.sh for identity_rejection, capabilities, dns, resolver_isolation, root_lifetime, and inbound_deny, and the five identity::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

  • Signed the Contributor License Agreement
  • Linked to an issue
  • For features or changes requiring a spec: linked the issue with maintainer-applied feature-accepted
  • For implementation: linked the required approved and merged design/API spec, or explained why no spec is required
  • Feature issue remains open unless this PR completes all agreed implementation, validation, and documentation
  • Updated documentation (if applicable)
  • Updated Copilot instructions (if build, architecture, or conventions changed)
  • If this PR changes Cargo.lock, the dependency-feed-check check passes (see pull request builds)

📋 Issue Type

  • Bug fix
  • Feature
  • Task
Microsoft Reviewers: Open in CodeFlow

@SohamDas2021
Soham Das (SohamDas2021) requested a review from a team as a code owner November 18, 2026 23:38
Copilot AI balanced review requested due to automatic review settings November 18, 2026 23:38
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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;
Copilot AI balanced review requested due to automatic review settings November 19, 2026 01:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 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

No deployments
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