fix(image): run bwrap from a copy in /usr/local/bin #65
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/bwrap-nested-userns"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
On a Linux host whose AppArmor ships Ubuntu's
bwrap-userns-restrictprofile, Claude Code's sandbox cannot start in the
claudeclientcontainer, even with
sandbox.enableWeakerNestedSandbox, which theNested sandboxes section recommends: every sandboxed Bash command fails
with
apply-seccomp: write /proc/self/setgroups ... Permission denied.The host profile attaches by path to
/usr/bin/bwrapinside thecontainer too, runs the jail as
bwrap//&unpriv_bwrapwith an emptycapability bounding set, and so the user namespace Claude Code nests
there cannot map its IDs. A copy of the same binary at another path keeps
the container's own confinement and nests one. Fixes #64.
Unmasking the container's
/proc, as the issue proposed, only lets afresh
/procmount and leaves this failure in place, so it is not partof this change.
What changed
The images now run
bwrapfrom/usr/local/bin/bwrap, a copy the basestage makes of Ubuntu's binary, which stays in place;
PATHfinds thecopy first, and Claude Code resolves
bwrapthroughPATH. With thedocumented setting, Claude Code's sandbox runs commands on such hosts.
The image smoke gate's bubblewrap probe now nests a user namespace in its
jail, and Nested sandboxes says where
bwrapruns from, that a customimage upgrading
bubblewrapcopies it again, and thatsandbox.bwrapPath, when set, names/usr/local/bin/bwrap.How to verify
On a host with rootless Podman and
bwrap-userns-restrictloaded:make test-e2eon this branch printssmoke-images: all three image targets passed. With this branch'stests/e2e/smoke_images.shon master's Dockerfile, it stops atassert_bubblewrapafterunshare: write failed /proc/self/uid_map: Operation not permitted.Build an image from the branch and launch it on an empty workspace
with the sandbox on:
Asked to run
command -v bwrap && ls /, Claude Code runs it as onesandboxed command and prints
/usr/local/bin/bwrap.make lint && .agents/hooks/shellcheck.sh repo && make testpasses onthe tip (349 tests);
test_base_copies_bwrap_to_usr_local_binand thesmoke unit test's nested-probe assertion fail on master. Both scenarios
passed on Ubuntu with Podman 5.7.0 and kernel 7.0.0-42-generic. Not
tried: hosts without that profile, and macOS.
Considerations
The copy is made when the base builds, so it lags a
bubblewrapupgradedone in a custom image until that image copies it again; the nightly
base rebuild keeps the published one current. Two documentation
suggestions were set aside: a note on images built before this change,
since Updates already says when a launch rebuilds one, and a
troubleshooting entry for the two errors, which lies outside this fix.