Skip to content

feat(bwrap): add filesystem preflight diagnostics - #1160

Closed
Gudge (MGudgin) wants to merge 1 commit into
mainfrom
user/gudge/mxc-507-bwrap-preflight
Closed

Gudge (MGudgin) wants to merge 1 commit into
mainfrom
user/gudge/mxc-507-bwrap-preflight

Conversation

@MGudgin

@MGudgin Gudge (MGudgin) commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

This PR adds actionable Bubblewrap diagnostics for paths hidden by the deny-by-
default filesystem baseline. Launch-time cwd preflight rejects only paths that
are provably uncovered or denied and defers ambiguous namespace cases to
Bubblewrap with retained warnings.

Fixes #507

Details

  • Distinguish uncovered, denied, and inconclusive cwd diagnostics while keeping
    host-dependent checks out of the stable validate surface.
  • Model synthetic /dev, /proc, and /var/run -> /run topology, including
    policy mounts that shadow the compatibility link.
  • Preserve caller deniedPaths spellings through symlink, hard-link, and
    filesystem-object alias normalization without probing unchanged spellings.
  • Preserve lxc-exec failure output in shell E2Es and accurately identify
    resolver-config inspection failures.
  • Add unit, parser-corpus, documentation, and real Bubblewrap E2E coverage.

Tests

  • cargo fmt --all -- --check
  • cargo check -p bwrap_common --target x86_64-unknown-linux-gnu
  • cargo clippy -p bwrap_common --target x86_64-unknown-linux-gnu -- -D warnings
  • cargo test -p bwrap_common in WSL (379 passed)
  • Exact wxc_common differential repository corpus test
  • node scripts/versioning/validate-configs.js (373 configs, 11 exempt)
  • Rebuilt lxc-exec, basic Bubblewrap E2E, and cwd-preflight E2E

Copilot AI balanced review requested due to automatic review settings September 14, 2026 21:58
@MGudgin
Gudge (MGudgin) requested a review from a team as a code owner September 14, 2026 21:58
@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.

Copilot review overview

🟡 Changes recommended

Cwd validation mishandles symlinks and synthetic parents created by denied mounts.

Get a fresh assessment by requesting another Copilot review.

Review tier: Balanced
Findings: 1 Medium severity

Open findings (1)
What changed in this PR

Adds Bubblewrap filesystem preflight diagnostics to replace opaque launch-time failures.

Changes:

  • Validates process.cwd visibility before launch.
  • Warns about hidden resolver symlink targets.
  • Adds unit tests and backend documentation.
File Description
bwrap_runner.rs Implements diagnostics and tests.
bwrap_command.rs Exposes baseline mount paths for validation.
bubblewrap-backend.md Documents preflight behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/backends/bubblewrap/common/src/bwrap_runner.rs Outdated
Comment thread src/backends/bubblewrap/common/src/bwrap_runner.rs Outdated
Comment thread src/backends/bubblewrap/common/src/bwrap_runner.rs Outdated
Comment thread src/backends/bubblewrap/common/src/bwrap_runner.rs Outdated
Comment thread src/backends/bubblewrap/common/src/bwrap_runner.rs Outdated
Comment thread src/backends/bubblewrap/common/src/bwrap_runner.rs Outdated
Comment thread src/backends/bubblewrap/common/src/bwrap_runner.rs Outdated
Comment thread src/backends/bubblewrap/common/src/bwrap_runner.rs Outdated
Comment thread src/backends/bubblewrap/common/src/bwrap_runner.rs Outdated
Comment thread src/backends/bubblewrap/common/src/bwrap_runner.rs
Comment thread docs/bwrap-support/bubblewrap-backend.md Outdated
Copilot AI review requested due to automatic review settings September 15, 2026 15:28
@MGudgin
Gudge (MGudgin) force-pushed the user/gudge/mxc-507-bwrap-preflight branch from 9aceabd to a0c379a Compare September 15, 2026 15:28

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.

Copilot review overview

🟡 Changes recommended

Host-path canonicalization can disagree with Bubblewrap’s assembled namespace, causing false rejections and incorrect warning suppression.

Get a fresh assessment by requesting another Copilot review.

Review tier: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (1)

Comment thread src/backends/bubblewrap/common/src/bwrap_runner.rs Outdated
Copilot AI review requested due to automatic review settings September 15, 2026 15:37
@MGudgin
Gudge (MGudgin) force-pushed the user/gudge/mxc-507-bwrap-preflight branch from a0c379a to c669d4b Compare September 15, 2026 15:37

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.

Copilot review overview

🔵 Needs a closer look

Parent-component and symlinked mount-destination handling can produce incorrect preflight verdicts.

Review tier: Balanced
Findings: 1 Medium severity

Open (1)

Copilot AI review requested due to automatic review settings September 15, 2026 15:54
@MGudgin
Gudge (MGudgin) force-pushed the user/gudge/mxc-507-bwrap-preflight branch from c669d4b to d0adb32 Compare September 15, 2026 15:54
@MGudgin
Gudge (MGudgin) requested a review from a team September 15, 2026 15:54

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.

Copilot review overview

🟡 Changes recommended

Synthetic parents created by denied mounts are incorrectly rejected, and denied-cwd remediation is misleading.

Get a fresh assessment by requesting another Copilot review.

Review tier: Balanced
Findings: 1 Low severity

Open (1)
Resolved since last review (1)

Comment thread src/backends/bubblewrap/common/src/bwrap_runner.rs Outdated
Copilot AI review requested due to automatic review settings September 15, 2026 16:14
@MGudgin
Gudge (MGudgin) force-pushed the user/gudge/mxc-507-bwrap-preflight branch from d0adb32 to af1e2f8 Compare September 15, 2026 16:14

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.

Copilot review overview

🟡 Changes recommended

Denied-path diagnostics can identify internal rewritten paths and recommend remediation that cannot resolve the denial.

Get a fresh assessment by requesting another Copilot review.

Review tier: Balanced
Findings: 2 Medium severity

Open (2)
Resolved since last review (1)

Comment thread src/backends/bubblewrap/common/src/bwrap_runner.rs Outdated
Comment thread src/backends/bubblewrap/common/src/bwrap_runner.rs Outdated
@SohamDas2021
Soham Das (SohamDas2021) requested review from Soham Das (SohamDas2021) and a balanced review from Copilot September 15, 2026 16:25

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.

Copilot review overview

🔵 Needs a closer look

Some denied-path diagnostics identify internal paths or recommend remediation that cannot resolve the policy conflict.

Review tier: Balanced
Findings: 2 Medium severity

Open (2)

Copilot AI review requested due to automatic review settings September 15, 2026 17:57

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.

Copilot review overview

🟡 Changes recommended

The preflight omits the synthetic /var/run mapping and can reject a CWD that is visible in the assembled namespace.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)

Comment thread src/backends/bubblewrap/common/src/bwrap_runner.rs
Copilot AI review requested due to automatic review settings September 16, 2026 21:26
@MGudgin
Gudge (MGudgin) force-pushed the user/gudge/mxc-507-bwrap-preflight branch from d505c91 to 19f71d8 Compare September 16, 2026 21:26
@MGudgin
Gudge (MGudgin) force-pushed the user/gudge/mxc-507-bwrap-preflight branch from 19f71d8 to 5fecc4c Compare September 16, 2026 21:28

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.

Comment thread tests/scripts/run_bwrap_basic_test.sh Outdated
Comment thread tests/scripts/run_bwrap_cwd_preflight_test.sh Outdated
Comment thread src/backends/bubblewrap/common/src/bwrap_runner.rs Outdated
Copilot AI review requested due to automatic review settings September 16, 2026 21:30

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.

Copilot review overview

🟡 Changes recommended

Policy mounts shadowing /var/run and normalized filesystem aliases can currently produce incorrect diagnostics.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 4 Medium severity · 1 Low severity

Open (5)

Comment thread src/backends/bubblewrap/common/src/bwrap_runner.rs Outdated
Comment thread src/backends/bubblewrap/common/src/bwrap_runner.rs Outdated
Copilot AI review requested due to automatic review settings September 16, 2026 21:38
@MGudgin
Gudge (MGudgin) force-pushed the user/gudge/mxc-507-bwrap-preflight branch from 5fecc4c to 4b16412 Compare September 16, 2026 21:38

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.

Copilot AI review requested due to automatic review settings September 16, 2026 21:44
@MGudgin
Gudge (MGudgin) force-pushed the user/gudge/mxc-507-bwrap-preflight branch from 4b16412 to d64dbfe Compare September 16, 2026 21:44

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.

Copilot review overview

🟡 Changes recommended

Denied-path provenance performs quadratic filesystem metadata probes for ordinary policies.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (2)

Comment thread src/backends/bubblewrap/common/src/bwrap_runner.rs
Copilot AI review requested due to automatic review settings September 16, 2026 21:57
@MGudgin
Gudge (MGudgin) force-pushed the user/gudge/mxc-507-bwrap-preflight branch from d64dbfe to ebe9fe4 Compare September 16, 2026 21:57

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.

Copilot review overview

🟢 Approval recommended

The implementation is consistent with the assembled namespace model and includes thorough regression coverage.

Review effort: Balanced
Findings: None

Resolved since last review (1)

This PR adds actionable Bubblewrap diagnostics for paths hidden by the deny-by-
default filesystem baseline. Launch-time cwd preflight rejects only paths that
are provably uncovered or denied and defers ambiguous namespace cases to
Bubblewrap with retained warnings.

Details

* Distinguish uncovered, denied, and inconclusive cwd diagnostics while keeping
  host-dependent checks out of the stable validate surface.
* Model synthetic `/dev`, `/proc`, and `/var/run -> /run` topology, including
  policy mounts that shadow the compatibility link.
* Preserve caller `deniedPaths` spellings through symlink, hard-link, and
  filesystem-object alias normalization without probing unchanged spellings.
* Preserve `lxc-exec` failure output in shell E2Es and accurately identify
  resolver-config inspection failures.
* Add unit, configuration, documentation, and real Bubblewrap E2E coverage.

Tests

* `cargo fmt --all -- --check`
* `cargo check -p bwrap_common --target x86_64-unknown-linux-gnu`
* `cargo clippy -p bwrap_common --target x86_64-unknown-linux-gnu -- -D warnings`
* `cargo test -p bwrap_common -- --test-threads=1` in WSL (394 passed)
* `cargo test -p wxc_common -- config_deserialize` in WSL (25 passed)
* `node scripts/versioning/validate-configs.js` (405 configs, 15 exempt)
* Rebuilt `lxc-exec`, basic Bubblewrap E2E, and cwd-preflight E2E

Fixes #507

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7bde2bdd-d3ba-468d-8ecb-4174e134507e
Generated-with: gpt-5.6-sol
Copilot AI review requested due to automatic review settings September 24, 2026 19:20
@MGudgin
Gudge (MGudgin) force-pushed the user/gudge/mxc-507-bwrap-preflight branch from ebe9fe4 to c16d428 Compare September 24, 2026 19:20

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.

Copilot review overview

🟡 Changes recommended

Resolver diagnostics miss policies hiding /etc/resolv.conf itself, and the new relative-cwd documentation contradicts schema 0.9 behavior.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity · 3 Low severity

Open (4)

Comment on lines +469 to +470
match working_directory_visibility(request, &target) {
PathVisibility::Visible => {}
`filesystem.readwritePaths`. Symlinked paths and paths containing `..` are
advisory: the runner records that it cannot decide conclusively and leaves
Bubblewrap as the authority, avoiding false rejection of a valid namespace
path. Relative values remain passed through to `bwrap` unchanged.
Comment thread docs/schema.md
Comment on lines +297 to +298
reject a valid namespace path. Relative values retain the general verbatim
behavior described above.
Comment on lines +201 to +203
// Preserve the backend's existing contract: relative cwd values are
// passed verbatim to `bwrap --chdir`. Without a stable sandbox base
// directory, rejecting them here would add behavior beyond #507.
@MGudgin

Copy link
Copy Markdown
Member Author

Closing this PR because the implementation is not converging.

The original goal in #507 remains valid, but this approach has expanded into a second model of Bubblewrap namespace and path-resolution semantics. Repeated review rounds continue to uncover additional correctness gaps across mount precedence, symlinks, policy aliases, resolver visibility, and version-specific cwd behavior. Continuing to patch this branch would increase risk without establishing a stable design boundary.

#507 remains open. A replacement should start with a smaller design: separate the resolver diagnostic from cwd handling, and make any cwd preflight advisory-only or derive it from a shared structured mount plan consumed by both argument generation and diagnostics.

The branch is retained for reference.

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.

feat(bwrap): Improve error reporting for deny by default file system semantics

4 participants