#8296: fix(browser): bind sandbox browser bridge to 0.0.0.0 for container access
agents
stale
Cluster:
Sandbox Path Management Fixes
## Summary
Fixes #8273
The browser bridge server was binding to `127.0.0.1` by default, which is unreachable from inside Docker containers. When the sandbox agent tries to use the browser tool, the request times out because `127.0.0.1` inside the container refers to the container itself, not the host machine where the bridge is running.
## Root Cause
From the issue:
- `browser/bridge-server.ts` defaults host to `127.0.0.1`
- `agents/sandbox/browser.ts` calls `startBrowserBridgeServer()` without a host parameter
- The bridge URL is passed to containers as `http://127.0.0.1:PORT`
- Container's localhost is itself, so requests to the bridge timeout
## Fix
Added a `sandboxMode` parameter to `startBrowserBridgeServer()`:
- When `sandboxMode=true`: bind to `0.0.0.0` (all interfaces) and advertise the docker bridge IP (`172.17.0.1`) in the baseUrl
- When `sandboxMode=false` (default): maintain existing behavior (bind to `127.0.0.1`)
This allows sandbox agents to reach the browser bridge server while maintaining security for non-sandbox use (localhost-only binding).
## Changes
- `src/browser/bridge-server.ts`: Added `sandboxMode` parameter, conditional binding/advertising logic
- `src/agents/sandbox/browser.ts`: Pass `sandboxMode: true` when starting bridge for sandbox
## Testing
- Typecheck passes
- Lint passes on modified files
- Non-sandbox users unaffected (default behavior unchanged)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR fixes sandbox-agent browser connectivity by adding a `sandboxMode` option to `startBrowserBridgeServer()`. In sandbox mode the bridge server binds to `0.0.0.0` and returns a `baseUrl` intended to be reachable from agent containers (using the Docker bridge gateway IP). `ensureSandboxBrowser()` now enables this mode when starting the bridge for sandboxed agents.
The change fits into the existing browser tooling by keeping non-sandbox behavior (loopback binding and localhost baseUrl) as the default, while making sandbox container networking work without requiring callers to pass a host explicitly.
<h3>Confidence Score: 3/5</h3>
- This PR is likely safe to merge, but the sandbox networking assumptions may break in non-default Docker environments.
- The change is small and scoped, and preserves default non-sandbox behavior. The main concern is functional portability: hard-coding `172.17.0.1` and ignoring an explicit `host` in sandbox mode can cause sandbox browser to still be unreachable in common setups (Docker Desktop, rootless/custom networks, Podman).
- src/browser/bridge-server.ts
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#23805: Sandbox: default browser network to none and fail bridge without so...
by bmendonca3 · 2026-02-22
84.0%
#11054: fix(security): Add auth token to sandbox browser bridge (#11023)
by shadril238 · 2026-02-07
79.4%
#16509: Fix sandbox path validation rejecting Docker bind mount paths
by Clawborn · 2026-02-14
78.6%
#20991: fix(sandbox): fall back to gateway UID:GID when no user is configur...
by cluster2600 · 2026-02-19
76.3%
#8567: fix: Sandbox browser runs Chromium as root with --no-sandbox
by coygeek · 2026-02-04
75.7%
#7851: feat: secure sandbox defaults for new installs
by ichbinlucaskim · 2026-02-03
75.6%
#16922: fix: remove incorrect sandbox file tool guidance
by carrotRakko · 2026-02-15
75.4%
#11820: fix(sandbox): remap container paths in sandboxed file tools
by steflsd · 2026-02-08
75.4%
#4226: Fix/sandbox containerworkdir rw access
by ozgur-polat · 2026-01-29
75.3%
#3907: fix(sandbox): use absolute /bin/sh path + add allowedReadPaths config
by pvoo · 2026-01-29
75.2%