Skip to content

Update the linux sandbox architecture to actually be able to pass its own tests#142

Open
ebendler wants to merge 3 commits intoanthropic-experimental:mainfrom
ebendler:update_deps
Open

Update the linux sandbox architecture to actually be able to pass its own tests#142
ebendler wants to merge 3 commits intoanthropic-experimental:mainfrom
ebendler:update_deps

Conversation

@ebendler
Copy link
Copy Markdown

@ebendler ebendler commented Feb 19, 2026

This PR (mostly by Opus 4.6) changes the architecture of the Linux sandbox to where the integration tests actually pass with bun/latest with three major changes:

  1. apply-seccomp is replaced for the network restriction case with a double-bwrap so that the seccomp restrictions are only applied to the agent's session commands and not the sandbox itself. This lets CC actually talk to its proxy.
  2. socat calls are double-forked to prevent bun from nuking them. This is mostly to fix the integration tests, but probably does not hurt anything in normal use.
  3. Integration tests are changed to use async spawns, so that the sandbox can actually give responses to the test runner.

The other commit updates the devDepends to their latest versions, but this did not result in any changes. zod was bumped to the last 3.x version, as 4.x requires significant API changes.

@ebendler ebendler changed the title Update deps Update the linux sandbox architecture to actually be able to pass its own tests Feb 19, 2026
@ebendler
Copy link
Copy Markdown
Author

This should be seen as a companion to #140 for the Linux side.

…pdated to new major versions as they require some API changes
Replace the apply-seccomp binary approach with a nested bwrap for applying
seccomp filters when network restrictions are active. This fixes a critical
bug where socat's fork() children inherited the seccomp filter, causing
socket(AF_UNIX, ...) calls to fail and silently dropping all proxy responses.

The new architecture:
- Outer bwrap/bash: starts socat bridges (no seccomp) that relay traffic
  between Unix socket bridges and TCP proxy listeners
- Inner bwrap: launched with --share-net + --seccomp so only the user
  command's process tree has Unix socket creation blocked
- Writable bind mounts from the outer bwrap are replicated into the inner
  bwrap to avoid EROFS errors

Additionally:
- Detach socat bridge processes via double-fork (execSync + shell
  backgrounding) so they are reparented to PID 1 and invisible to the bun
  test runner, which previously killed them between test cases
- Store raw PIDs instead of ChildProcess objects in LinuxNetworkBridgeContext
- Simplify bridge cleanup in sandbox-manager using a polling loop
- Convert integration tests from synchronous spawnSync to async execCommand
  helper to keep the event loop alive for in-process proxy servicing
- Export and deduplicate isProcessAlive across modules
- Use shellquote.quote() in spawnDetachedSocat for safe shell escaping
- Fix indentation in test cleanup blocks
- Update wrapCommandWithSandboxLinux docstring to reflect new architecture
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.

1 participant