Claude Code's sandbox cannot start inside the client container #64
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Where
bin/azkaban,_azk_build_podman_args, which runs the Linux containerwith Podman's default masked
/procpaths, anddocs/configuration.md§ Nested sandboxes, which tells Claude Codeusers to set
sandbox.enableWeakerNestedSandboxtotrue. Seen atcd974cb, from aclaudeclient container, Claude Code 2.1.319.What happens
With
sandbox.enabled: true, every sandboxed Bash command fails beforeit runs. With the default settings:
With
enableWeakerNestedSandbox: true, as the documentation says, andalso with
allowNestedUserNamespaces: true:Inside the container,
/proc/self/mountinfoshows Podman's defaultmasks:
/proc/acpi,/proc/kcore,/proc/keys,/proc/scsi,/proc/sys,/proc/busand the rest, as tmpfs, devtmpfs, or bindmounts. The kernel refuses a fresh procfs mount in a child user
namespace while the parent's
/prochas such mounts over it, which isthe first error, reproduced without Claude Code:
The weaker nested sandbox binds the container's
/procinstead, as thesmoke test's probe does, and then applies seccomp from a second-level
user namespace. Writes to that namespace's
setgroupsanduid_mapthrough the bound outer
/procare refused, which is the second error,also reproduced with
bwrapalone:The same
unshare -Ur sh -c 'unshare -Ur true'succeeds outsidebwrap, so the container's user namespace limits are not the cause.tests/e2e/smoke_images.shpasses itsassert_bubblewrapcheck inthis situation, since that probe needs only one level of namespaces.
Scenario
A user turns on Claude Code's sandbox, from
/sandboxor from itssettings, to hide credential files and variables from Bash commands.
Every command then fails at sandbox start-up, and Claude Code's
unsandboxed retry is the only way on, so the sandbox's protection is
lost and the documented setting gives no working path.
Smallest fix
Add
--security-opt unmask=/proc/*to the Linuxpodman_argsin_azk_build_podman_args, which lets a child user namespace mount itsown
/procwhile the capability drop and the seccomp profile stay asthey are. Claude Code's regular sandbox then starts without
enableWeakerNestedSandbox, and the Nested sandboxes section can dropthat advice. A smoke probe that nests a second user namespace inside
bwrap, as the second reproduction above does, would catch aregression. I could not confirm the fix from inside a running
container, since the masks are set at launch.