Skip to content

Warn when Bubblewrap cwd is clearly unmounted - #1442

Open
Gudge (MGudgin) wants to merge 1 commit into
mainfrom
user/gudge/mxc_507_cwd_advisory
Open

Gudge (MGudgin) wants to merge 1 commit into
mainfrom
user/gudge/mxc_507_cwd_advisory

Conversation

@MGudgin

@MGudgin Gudge (MGudgin) commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

This PR adds an advisory warning when an explicit, canonical process.cwd
is clearly outside Bubblewrap's mounts. It names the filesystem policy
remedy while leaving ambiguous paths and execution results to Bubblewrap.

Part of #507; the separate resolver-target diagnostic is #1441. This remains advisory as recommended when #1160 was closed. Neither PR alone closes #507.

Details

  • Compare cwd with baseline, virtual, and policy mount destinations
    without rejecting the request.
  • Cover root mounts and every emitted mount destination in regression tests.
  • Verify the CLI warning on stderr alongside the original bwrap failure,
    and document SDK/CLI warning delivery.

Tests

  • From src/, cargo fmt --all -- --check: passed.
  • cargo check -p mxc-sdk --all-targets --quiet: passed.
  • cargo clippy -p mxc-sdk --all-targets --quiet -- -D warnings: passed.
  • cargo test -p mxc-sdk --lib bwrap_command --quiet: 53 passed on Windows.
  • cargo check -p mxc-sdk --target x86_64-unknown-linux-gnu --all-targets --quiet: passed.
  • cargo clippy -p mxc-sdk --target x86_64-unknown-linux-gnu --all-targets --quiet -- -D warnings: passed.
  • From the repository root, C:\Program Files\Git\bin\bash.exe -n tests\scripts\run_bwrap_cwd_advisory_test.sh: passed.
  • Ubuntu 26.04 ARM64 WSL (src/), CARGO_TARGET_DIR="$HOME/src/microsoft/mxc/mxc.root/src/target" cargo test -p mxc-sdk --lib bubblewrap::common --quiet -- --test-threads=1: 306 passed.
  • CARGO_TARGET_DIR="$HOME/src/microsoft/mxc/mxc.root/src/target" cargo build -p lxc --quiet: passed.
  • LXC_EXEC="$HOME/src/microsoft/mxc/mxc.root/src/target/debug/lxc-exec" bash ../tests/scripts/run_bwrap_cwd_advisory_test.sh: passed; the uncovered cwd emitted the warning on stderr and retained Bubblewrap's error, while the covered cwd succeeded without the advisory.
Microsoft Reviewers: Open in CodeFlow

Copilot AI balanced review requested due to automatic review settings October 7, 2026 17:06
@MGudgin
Gudge (MGudgin) requested a review from a team as a code owner October 7, 2026 17:06
@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

Raw string containment can incorrectly warn for equivalent mount paths containing repeated or trailing separators.

1 open finding
What changed in this PR

Adds conservative Bubblewrap warnings when an explicit working directory is clearly outside mounted paths.

Changes:

  • Detects uncovered canonical working directories and retains warnings.
  • Adds unit and CLI integration coverage.
  • Documents warning behavior and remedies.
File Description
bwrap_runner.rs Emits and tests retained cwd warnings.
bwrap_command.rs Determines whether cwd overlaps known mounts.
run_bwrap_cwd_advisory_test.sh Tests CLI warning and execution behavior.
run_bwrap_all_tests.sh Registers the new integration test.
bubblewrap-backend.md Documents the advisory.

🧠 Review effort: Balanced


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

Comment on lines +280 to +284
fn path_is_within(path: &str, parent: &str) -> bool {
parent == "/" && path.starts_with('/')
|| path == parent
|| (path.starts_with(parent) && path.as_bytes().get(parent.len()) == Some(&b'/'))
}
This PR adds a conservative launch-time warning for an explicit, canonical
process.cwd that is clearly outside Bubblewrap's mounts. It names the
filesystem policy remedy while leaving ambiguous paths and execution
results to Bubblewrap.

Details

* Compare cwd with the baseline, virtual, and policy mount destinations
  without rejecting the request.
* Cover root mounts and every emitted mount destination in regression tests.
* Verify the CLI warning on stderr alongside the original bwrap failure
  and document warning delivery for SDK and CLI callers.

Tests

* cargo fmt --all -- --check: passed.
* cargo check -p mxc-sdk --all-targets --quiet: passed.
* cargo clippy -p mxc-sdk --all-targets --quiet -- -D warnings: passed.
* cargo test -p mxc-sdk --lib bwrap_command --quiet: 53 passed.
* Linux-target mxc-sdk all-target check and Clippy: passed.
* Git Bash shell syntax check: passed; live Linux bwrap test not run locally.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6f448a40-019f-4bfd-82e0-ec6b7d23c4d8
Generated-with: gpt-6-sol
@MGudgin
Gudge (MGudgin) force-pushed the user/gudge/mxc_507_cwd_advisory branch from 85daae0 to a284d8a Compare October 7, 2026 17:19
@MGudgin Gudge (MGudgin) changed the title feat(bwrap): warn on clearly uncovered working directories Warn when Bubblewrap cwd is clearly unmounted Oct 7, 2026

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.

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

2 participants