Skip to content

[Bubblewrap] Mask denied files with a /dev/null bind instead of tmpfs#623

Open
SohamDas2021 wants to merge 2 commits into
mainfrom
user/sodas/bwrap-denied-path-masking
Open

[Bubblewrap] Mask denied files with a /dev/null bind instead of tmpfs#623
SohamDas2021 wants to merge 2 commits into
mainfrom
user/sodas/bwrap-denied-path-masking

Conversation

@SohamDas2021

@SohamDas2021 SohamDas2021 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

📖 Description

The Bubblewrap backend masked every denied path with --tmpfs. Mounting a tmpfs over a regular file turns it into an empty directory (bwrap creates the mount point as a dir), changing the object's type and breaking tools that expect a regular file.

This PR classifies each denied path at runtime and masks it with the correct primitive:

  • Directories keep --tmpfs (empty, no leak).
  • Files (and other non-directory objects) are masked with a read-only bind of /dev/null, preserving a non-directory type with empty content.

This brings Bubblewrap in line with the LXC backend, which already distinguishes files from directories when masking.

🔗 References

🔍 Validation

✅ Checklist

📋 Issue Type

  • Bug fix
  • Feature
  • Task

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 GitHub
Actions build; it runs on merge to main, and Microsoft reviewers with write access can trigger it
on a PR with /azp run. See docs/pull-requests.md.

If the dependency-feed-check check fails on a new dependency, the crate must be added to
the feed before the PR can pass. See docs/pull-requests.md
for the steps.

Microsoft Reviewers: Open in CodeFlow

Copilot AI review requested due to automatic review settings July 8, 2026 17:56

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.

Pull request overview

This PR improves Bubblewrap’s denied-path masking behavior so that denying a regular file no longer converts it into an empty directory (a side-effect of --tmpfs creating the mount point as a directory). It aligns Bubblewrap with the LXC backend by masking denied directories and denied non-directories differently to better preserve object type semantics.

Changes:

  • Classify denied paths at runtime and mask denied non-directories via --ro-bind /dev/null (directories remain --tmpfs).
  • Add unit tests for classified denied-path masking in the Bubblewrap argument builder.
  • Add an end-to-end shell test + config to validate denied file vs denied directory masking behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/scripts/run_bwrap_denied_masking_test.sh New end-to-end test script validating denied file vs denied directory masking semantics.
tests/scripts/run_bwrap_all_tests.sh Adds the new denied-masking test to the Bubblewrap test suite runner.
tests/configs/bubblewrap_denied_masking.json New Bubblewrap config fixture used by the denied-masking test.
src/backends/bubblewrap/common/src/bwrap_runner.rs Classifies denied paths at runtime and passes classification into arg building.
src/backends/bubblewrap/common/src/bwrap_command.rs Adds build_args_classified and unit tests to mask denied files with /dev/null instead of --tmpfs.

Comment thread src/backends/bubblewrap/common/src/bwrap_runner.rs Outdated
@SohamDas2021 SohamDas2021 force-pushed the user/sodas/bwrap-denied-path-masking branch from a7e0e05 to 0582bac Compare July 8, 2026 18:09
@SohamDas2021 SohamDas2021 marked this pull request as ready for review July 8, 2026 18:24
@SohamDas2021 SohamDas2021 requested a review from a team as a code owner July 8, 2026 18:24
Comment thread tests/scripts/run_bwrap_denied_masking_test.sh
Comment thread src/backends/bubblewrap/common/src/bwrap_command.rs
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.

3 participants