You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mount the pixi home ($PIXI_HOME, default ~/.pixi) read-only in every bw* sandbox, so a session can no longer replace the tools that the host runs from ~/.pixi/bin.
build_pixi_mounts bound $PIXI_HOME with --bind. A session could overwrite ~/.pixi/bin/* (zellij, nvim, ruff, prek and any other pixi global tool), and the host would run the changed file the next time the user started it outside the sandbox. It is now --ro-bind. All six launchers call the function, so one change covers bwclaude, bwcodex, bwcopilot, bwopenchamber, bwopencode and bwopencode2.
Nothing needs to write there. With PIXI_HOME read-only (permissions only, not a bind mount), pixi exec, pixi add and pixi run worked in a scratch project. Only pixi global install and pixi self-update fail ("Permission denied" here, read-only file system in the sandbox). Both are host commands.
The mount is repeated after every other read-write mount (pin_pixi_home_read_only, called first thing in build_sandbox_context, so the context file lists the final mounts and the binary masks stay last): at its own path, at its real path if that differs, and wherever a read-write bind has the pixi home, a directory in it, or a directory above it as its source. A PIXI_HOME inside the read-write npm, ccache or prek caches, a ~/.pixi that is a symlink into one, or a ~/.npm that is a symlink to ~/.pixi or to a directory that holds it, stays read-only. --rw-path on the pixi home (~ is expanded, a symlinked home included) is the one way to make it writable.
A different PIXI_HOME is mounted read-only as well. The issue also suggested mounting the default ~/.pixi read-only in that case. I did not: the home is a tmpfs, so the default ~/.pixi is not in the sandbox at all and adding it would only expose more.
Comments and docs/bw-wrappers.md that said ~/.pixi is writable from the sandbox are corrected, and a short section describes the change. bwopenchamber's Node probe is unchanged. It still never runs a node on the host, because an activated project environment is still writable.
Open point for reviewers: this closes the pixi home only. The working directory is read-write by design, and the host later runs things from it (.git/hooks, core.hooksPath and core.fsmonitor in .git/config, pixi tasks, .envrc). The new doc section says so. I think that needs its own issue (for example read-only binds of .git/hooks and .git/config), so I left it out here.
Testing
tests/test-bwopenchamber.sh: 126 passed. It has new dry-run checks that the default and a custom PIXI_HOME get --ro-bind and no --bind, that the default ~/.pixi is not mounted when PIXI_HOME is elsewhere, that a PIXI_HOME inside ~/.npm is read-only after the npm mount, that --rw-path on the pixi home (also written with ~) wins, that a symlinked ~/.pixi is covered by its real path, that the binary masks still come after the pin (PIXI_HOME=/usr), that a ~/.npm symlinked to the pixi home is covered, that a ~/.npm symlinked to a directory above the pixi home is covered, that the sandbox context file lists a nested pixi home as read-only (also with --no-sandbox-context), and that --rw-path on a symlinked home is writable at the configured path. With the library change reverted, the mount checks fail. The test helper clears PIXI_HOME and NPM_CONFIG_CACHE, so exported ones do not change the result.
tests/test-bwopencode2-serve.sh (72) and tests/test-bla-git-config.sh (49) pass.
pixi run -e dev lint-files on the five changed files passed, and the same hooks passed again at commit.
pixi exec, pixi add, pixi run and pixi global install tried with a read-only PIXI_HOME (chmod 555) in an agent sandbox, not through a launcher: the first three worked, the last failed as described above.
Not tested: a real bw* launch with the read-only bind on a managed host, or bwopenchamber against a real pixi global Node.
Checklist
Edit the sections above with relevant information
Update in-repo documentation, if applicable
Run pixi run -e dev lint locally (or wait for CI) — see .github/workflows/lint.yml
Test the changes on a representative managed host (or runansible deployment)
The host runs the tools in ~/.pixi/bin outside the sandbox, so a program
replaced there from inside a session escaped it. Project work and pixi exec
write elsewhere; only pixi global and pixi self-update need the host.
ClosesNSLS2#46
Assisted-by: opencode:claude-sonnet-5-5
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
A later writable npm mount overrides Pixi’s read-only protection for nested custom paths, preserving a host-binary replacement vulnerability, while the default-home test also depends on the invoking shell’s environment.
This PR addresses #46 by making the shared Pixi-home mount read-only across all six sandbox launchers, protecting host-run tools from modification inside sessions.
Changes:
Switch the Pixi-home bind to read-only.
Add dry-run checks for default and custom PIXI_HOME paths.
Update security documentation and comments without changing browser or Node probing behavior.
File
Description
tests/test-bwopenchamber.sh
Add Pixi-home mount assertions.
lib/bwrap_sandbox_lib.sh
Make the shared Pixi-home mount read-only.
docs/bw-wrappers.md
Explain protection, limitations, and host-only operations.
A PIXI_HOME inside a read-write cache such as ~/.npm was covered again by
that cache's mount. Mount it read-only once more after all other mounts,
unless --rw-path names it. The test helper now clears PIXI_HOME.
Assisted-by: opencode:claude-sonnet-5-5
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Critical Pixi mount issues can re-expose masked binaries and leave host tools writable through symlink aliases, while path normalization and cache-dependent regression checks also need fixes.
Call the pin from build_binary_masks so the masks stay last, expand ~ in
--rw-path the way the extra-path mounts do, and also mount the real path of
a symlinked pixi home. The test helper clears NPM_CONFIG_CACHE.
Assisted-by: opencode:claude-sonnet-5-5
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
A writable ~/.npm symlink alias still bypasses ~/.pixi protection, allowing host-tool replacement without --rw-path, while the documented write opt-out also fails for symlinked pixi homes.
No open issues 🎉
2 previously missed issues
In code that hasn't changed since last review
Protect writable bind aliases of the Pixi directory
lib/bwrap_sandbox_lib.sh:5980
The reverse symlink layout still bypasses this protection: with ~/.npm -> ~/.pixi, build_npm_mounts emits a writable bind at ~/.npm, backed by the same host directory. These pins cover only ~/.pixi, so a session can still replace host tools through ~/.npm/bin without --rw-path. Resolve writable bind sources and protect their corresponding destination aliases too, or reject such overlaps; add a regression check for this inverse symlink layout.
Honor --rw-path for symlinked Pixi home
lib/bwrap_sandbox_lib.sh:5977
When ~/.pixi is a symlink to ~/.npm/pixi, --rw-path ~/.pixi mounts only the canonical ~/.npm/pixi destination. This early return leaves the initial read-only mount at ~/.pixi intact, so commands using the configured pixi home still cannot write despite the documented opt-out. Make the override writable at the configured path too, while preserving nested --ro-path overrides, and add a regression check combining the symlink and opt-out cases.
Mount the pixi home read-only again wherever a read-write bind has it as
its source (a ~/.npm that is a symlink to ~/.pixi), and mount it read-write
at the configured path when --rw-path names a symlinked pixi home.
Assisted-by: opencode:claude-sonnet-5-5
A read-write bind whose real source is an ancestor of the pixi home showed
the home at destination/<relative path>. Mount it read-only there too.
Assisted-by: opencode:claude-sonnet-5-5
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Pixi permissions are pinned after the sandbox context is rendered, causing the agent’s access table to omit the read-only exception when PIXI_HOME is nested under the writable npm mount.
The context file lists the mounts as they are when it is built, so the pin
has to come first. It now runs at the start of build_sandbox_context, which
every launcher calls after its other mounts and before the binary masks, and
also with --no-sandbox-context.
Assisted-by: opencode:claude-sonnet-5-5
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because interacting path-resolution and mount-order edge cases can produce incorrect dry-run mappings or cause actual sandbox launches to fail.
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
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.
Summary
Mount the pixi home (
$PIXI_HOME, default~/.pixi) read-only in everybw*sandbox, so a session can no longer replace the tools that the host runs from~/.pixi/bin.Closes #46.
Description
build_pixi_mountsbound$PIXI_HOMEwith--bind. A session could overwrite~/.pixi/bin/*(zellij,nvim,ruff,prekand any otherpixi globaltool), and the host would run the changed file the next time the user started it outside the sandbox. It is now--ro-bind. All six launchers call the function, so one change coversbwclaude,bwcodex,bwcopilot,bwopenchamber,bwopencodeandbwopencode2.PIXI_HOMEread-only (permissions only, not a bind mount),pixi exec,pixi addandpixi runworked in a scratch project. Onlypixi global installandpixi self-updatefail ("Permission denied" here, read-only file system in the sandbox). Both are host commands.pin_pixi_home_read_only, called first thing inbuild_sandbox_context, so the context file lists the final mounts and the binary masks stay last): at its own path, at its real path if that differs, and wherever a read-write bind has the pixi home, a directory in it, or a directory above it as its source. APIXI_HOMEinside the read-write npm, ccache or prek caches, a~/.pixithat is a symlink into one, or a~/.npmthat is a symlink to~/.pixior to a directory that holds it, stays read-only.--rw-pathon the pixi home (~is expanded, a symlinked home included) is the one way to make it writable.PIXI_HOMEis mounted read-only as well. The issue also suggested mounting the default~/.pixiread-only in that case. I did not: the home is a tmpfs, so the default~/.pixiis not in the sandbox at all and adding it would only expose more.docs/bw-wrappers.mdthat said~/.pixiis writable from the sandbox are corrected, and a short section describes the change.bwopenchamber's Node probe is unchanged. It still never runs anodeon the host, because an activated project environment is still writable.Open point for reviewers: this closes the pixi home only. The working directory is read-write by design, and the host later runs things from it (
.git/hooks,core.hooksPathandcore.fsmonitorin.git/config, pixi tasks,.envrc). The new doc section says so. I think that needs its own issue (for example read-only binds of.git/hooksand.git/config), so I left it out here.Testing
tests/test-bwopenchamber.sh: 126 passed. It has new dry-run checks that the default and a customPIXI_HOMEget--ro-bindand no--bind, that the default~/.pixiis not mounted whenPIXI_HOMEis elsewhere, that aPIXI_HOMEinside~/.npmis read-only after the npm mount, that--rw-pathon the pixi home (also written with~) wins, that a symlinked~/.pixiis covered by its real path, that the binary masks still come after the pin (PIXI_HOME=/usr), that a~/.npmsymlinked to the pixi home is covered, that a~/.npmsymlinked to a directory above the pixi home is covered, that the sandbox context file lists a nested pixi home as read-only (also with--no-sandbox-context), and that--rw-pathon a symlinked home is writable at the configured path. With the library change reverted, the mount checks fail. The test helper clearsPIXI_HOMEandNPM_CONFIG_CACHE, so exported ones do not change the result.tests/test-bwopencode2-serve.sh(72) andtests/test-bla-git-config.sh(49) pass.pixi run -e dev lint-fileson the five changed files passed, and the same hooks passed again at commit.pixi exec,pixi add,pixi runandpixi global installtried with a read-onlyPIXI_HOME(chmod 555) in an agent sandbox, not through a launcher: the first three worked, the last failed as described above.bw*launch with the read-only bind on a managed host, orbwopenchamberagainst a realpixi globalNode.Checklist
pixi run -e dev lintlocally (or wait for CI) — see.github/workflows/lint.ymlrunansibledeployment)Assisted-by: opencode:claude-sonnet-5-5