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
The podman backend needs a locally built image, and the agent CLI baked into it drifts behind the host's until someone rebuilds. Claude Code and Codex CLI sandbox with bubblewrap over the host's own filesystem instead, which removes the image entirely.
backend = "bwrap" mirrors the podman layout (/workspace, /opt/scripts, /home/sandbox) so workflows work under either backend. The sandbox root starts empty and only gets the host's /usr and /etc read-only; that hides $HOME and the sockets under /run/user (D-Bus session bus, keyring, ssh-agent), which a Landlock-only approach would have left reachable. The step's program is resolved on the host PATH and its directory mounted read-only, so agents installed outside /usr (~/.local, linuxbrew) run at the host's version.
Host /opt stays hidden: it is read-only, so bwrap could not create the /opt/scripts mount point inside it.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Unconditionally mounting an executable’s parent directory can expose home-directory credentials inside the sandbox, violating the backend’s isolation guarantee.
Adds an experimental Bubblewrap sandbox backend that runs host-installed tools without a container image, while retaining Podman as the default and matching its workflow directory layout.
Changes:
Adds backend selection to workflow configuration and sandbox command construction.
Implements Bubblewrap isolation, mounts, networking, and host executable resolution.
Documents the experimental backend and adds configuration, command-generation, and sandbox tests.
File
Description
USAGE.md
Documents backend selection, behavior, requirements, and limitations.
crates/otter-core/src/types.rs
Adds the backend configuration enum and parsing tests.
crates/otter-core/src/sandbox.rs
Passes workflow backend selection into sandbox configuration.
crates/otter-core/src/process.rs
Resolves and exposes host executables for Bubblewrap.
crates/agentbox/src/main.rs
Keeps the standalone CLI explicitly configured for Podman.
crates/agentbox/src/lib.rs
Adds Bubblewrap command construction and isolation tests.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The Bwrap TTY configuration permits host-shell command injection on systems allowing TIOCSTI, while executable mounting also mishandles hidden symlink chains and relative PATH entries.
Resolve relative PATH entries against the step working directory
crates/otter-core/src/process.rs:218
Relative or empty entries in the login PATH are resolved against the service's current directory here, not the step's working directory. With PATH="." and a tool in both directories, this can expose and run the service directory's tool instead of the workspace's tool. Pass the step's working directory into this helper and resolve relative PATH entries against it before checking executability and constructing the mount.
Document writable Claude home mounts as a sandbox exception
USAGE.md:476
This isolation description omits writable host-home mounts: for Claude agent steps, resolve_sandbox_config automatically mounts ~/.claude and ~/.claude.json into /home/sandbox. Those files contain authentication, configuration and session data that the sandboxed agent can read and modify. Document this exception so users do not mistake the fresh home directory for isolation of their Claude data.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Active issues can break symlinked CLIs by relocating them away from adjacent dependencies and disable DNS when resolver symlink chains include hidden aliases.
Resolver mount omits intermediate aliases used by resolv.conf
crates/agentbox/src/lib.rs:103
Mounting only the canonical resolver target leaves /etc/resolv.conf dangling when it points through a hidden alias, such as /var/run/NetworkManager/resolv.conf with /var/run -> /run. Only /run/NetworkManager/resolv.conf is mounted in that case, so DNS fails with the default bridge networking. Preserve the path that /etc/resolv.conf follows, including intermediate aliases, and add a regression test for this layout.
The reason will be displayed to describe this comment to others. Learn more.
Tested this locally and works as expected. Nice work. A few nits inline, mainly an idea about the cpu_quota combination.
Could you squash the fix(bwrap)/test(bwrap) follow-ups into e641b19 though? Or into a few logical commits, before merging? Most of them fix things introduced earlier in this same PR, and the two merge commits don't need to land on main either.
The reason will be displayed to describe this comment to others. Learn more.
Just and idea which I like, but not blocking as it's listed in the experimental section.
Claude:
With backend = "bwrap" and a cpu_quota, agent steps arrive here already wrapped as systemd-run --scope --user … -- claude …, because the agent runners (e.g. agent_runner/claude.rs) apply the limiter regardless of the sandbox. expose_host_binary then only exposes systemd-run, and the step fails with Failed to find executable claude. Even if claude were found, systemd-run --user couldn't reach the user bus, since /run/user is hidden.
Since bwrap runs as a direct child of the daemon, unlike Podman, could we apply the limiter around bwrap itself, here? Then cpu_quota would just work for shell and agent steps.
The reason will be displayed to describe this comment to others. Learn more.
Claude:
Related: for bwrap, the cpus computed above is never used, and steps/shell.rs skips the limiter for any sandbox, so shell steps silently lose the quota. My step with cpu_quota = "50%" saw all 8 cores and ran in cgroup 0::/, and nothing was logged. If we don't wire it up in this PR, I'd rather warn, or reject the combination at load time, than have the docs be the only place this shows up.
The reason will be displayed to describe this comment to others. Learn more.
Bit of a nit since Podman's -e already does the same, but --setenv NAME value puts the requires secrets into bwrap's argv, where any local user can read them via ps. With bwrap we don't have to: bwrap passes its own environment through to the sandboxed process. So we could drop --clearenv/--setenv and build the exact sandbox env on the bwrap process in build_subprocess_command instead.
The podman backend needs a locally built image, and the agent CLI baked
into it drifts behind the host's until someone rebuilds. Claude Code and
Codex CLI sandbox with bubblewrap over the host's own filesystem
instead, which removes the image entirely.
`backend = "bwrap"` mirrors the podman layout (/workspace, /opt/scripts,
/home/sandbox) so workflows work under either backend. The sandbox root
starts empty and only gets the host's /usr and /etc read-only; that
hides $HOME and the sockets under /run/user (D-Bus session bus, keyring,
ssh-agent), which a Landlock-only approach would have left reachable.
The step's program is resolved on the host PATH and only its executable
file is mounted, not its directory, so a tool in ~/.local/bin does not
expose its neighbours. Resolution has to hold up against what PATH
lookups meet in practice: relative entries and commands (resolved from
the workspace), non-executable candidates, and symlink chains through
hidden directories, while keeping the invocation name tools like
busybox dispatch on. Absolute commands are validated before any host
path is exposed. /etc/resolv.conf is often a symlink into /run, which
the sandbox replaces with tmpfs, so the real resolver file is mounted
explicitly. The controlling terminal is always detached, so a sandboxed
step cannot inject input into the user's terminal.
Host /opt stays hidden: it is read-only, so bwrap could not create the
/opt/scripts mount point inside it.
Tests write their mock scripts from the test process while parallel
tests spawn subprocesses. A subprocess forked in that window inherits
the open write handle until it execs, and executing the script then
fails with ETXTBSY. Letting a child process write the file means the
test process never holds a write handle that a fork could inherit.
The sync_all that was there could not prevent this; durability was
never the problem.
Trying the bwrap backend means installing both otter and agentbox from
this checkout, and agentbox is not part of the releases. One command
does both with the locked dependencies.
It also restarts a running service. Otherwise the service keeps running
the replaced binary, so the CLI and the service silently run different
versions and `otter status` reports the old service's stale update check.
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.
The podman backend needs a locally built image, and the agent CLI baked into it drifts behind the host's until someone rebuilds. Claude Code and Codex CLI sandbox with bubblewrap over the host's own filesystem instead, which removes the image entirely.
backend = "bwrap"mirrors the podman layout (/workspace, /opt/scripts, /home/sandbox) so workflows work under either backend. The sandbox root starts empty and only gets the host's /usr and /etc read-only; that hides $HOME and the sockets under /run/user (D-Bus session bus, keyring, ssh-agent), which a Landlock-only approach would have left reachable. The step's program is resolved on the host PATH and its directory mounted read-only, so agents installed outside /usr (~/.local, linuxbrew) run at the host's version.Host /opt stays hidden: it is read-only, so bwrap could not create the /opt/scripts mount point inside it.