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
{{ message }}
Repository navigation
Opt-in to keep Chrome's sandbox on when agent-browser launches Chrome in a container
#2623
When agent-browser launches Chrome inside a container it always adds --no-sandbox, even when the container is set up so that Chrome's sandbox works. There is no setting to say "this environment supports the sandbox, keep it". I'd like an opt-in for that.
This is the documented behaviour (engines/chrome.mdx), so I'm filing it as an idea, not a bug.
Why
We run the browser for an agent that reads untrusted pages. The container is the main boundary, and Chrome's own sandbox (namespaces plus seccomp-bpf for the renderer) is a second one. Playwright's Docker guide recommends exactly this setup for untrusted sites: a non-root user and a seccomp profile that allows user namespaces. With that setup Chrome starts sandboxed, but not when agent-browser is the one launching it.
What happens today (v0.43.0)
should_disable_sandbox returns true whenever /.dockerenv or /run/.containerenv exists, when CI is set, when the user is root, or when /proc/1/cgroup mentions docker, kubepods or lxc. The only way to make it return false is to pass --no-sandbox yourself:
FROM node:22-bookworm
RUN npm install -g agent-browser@0.43.0 \
&& agent-browser install --with-deps \
&& useradd -m -u 10001 u
USER u
RUN agent-browser install
CMD ["sleep", "infinity"]
seccomp_profile.json is Playwright's profile (Docker's default plus clone, setns and unshare for user namespaces).
SYS_CHROOT is in Docker's default capability set; it is listed only because the run drops all the others. The profile allows chroot only when the container has that capability, and Chrome's namespace sandbox calls chroot.
Inside the container, as uid 10001:
CHROME=$(find "$HOME/.agent-browser" -type f -name chrome | head -1)# 1. Chrome started directly: the sandbox works here"$CHROME" --headless=new --remote-debugging-port=9222 --user-data-dir=/tmp/direct about:blank &
agent-browser --session direct --cdp 9222 open chrome://sandbox
agent-browser --session direct get text body
agent-browser --session direct close; pkill -f remote-debugging-port=9222
# 2. Chrome started by agent-browser
agent-browser open chrome://sandbox
agent-browser get text body
ps -eo args | grep -c -- '[-]-no-sandbox'
Output of step 1:
Sandbox Status
Layer 1 Sandbox Namespace
PID namespaces Yes
Network namespaces Yes
Seccomp-BPF sandbox Yes
Seccomp-BPF sandbox supports TSYNC Yes
Ptrace Protection with Yama LSM (Broker) Yes
Ptrace Protection with Yama LSM (Non-broker) No
You are adequately sandboxed.
Output of step 2:
Sandbox Status
Layer 1 Sandbox None
PID namespaces No
Network namespaces No
Seccomp-BPF sandbox No
Seccomp-BPF sandbox supports TSYNC No
Ptrace Protection with Yama LSM (Broker) No
Ptrace Protection with Yama LSM (Non-broker) No
You are NOT adequately sandboxed.
13
(13 is the number of Chrome processes carrying --no-sandbox.)
Proposal
An explicit opt-in that makes should_disable_sandbox return false, checked before the container heuristics. For example:
AGENT_BROWSER_CHROME_SANDBOX=1, with a --chrome-sandbox flag and a chromeSandbox config key, as a launch setting.
With it set, agent-browser would not add --no-sandbox. If Chrome then fails to start, the existing launch error and its --no-sandbox hint already explain why. Nothing changes for anyone who doesn't set it.
Playwright has the same switch as the chromiumSandbox launch option.
Workaround today
Launch Chrome ourselves and attach with --cdp. That works (it is step 1 above), but it gives up agent-browser's own launch handling, and --allowed-domains is rejected with --cdp.
Environment
agent-browser 0.43.0 (npm), Chrome for Testing 157.0.8103.78 from agent-browser install
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Summary
When agent-browser launches Chrome inside a container it always adds
--no-sandbox, even when the container is set up so that Chrome's sandbox works. There is no setting to say "this environment supports the sandbox, keep it". I'd like an opt-in for that.This is the documented behaviour (engines/chrome.mdx), so I'm filing it as an idea, not a bug.
Why
We run the browser for an agent that reads untrusted pages. The container is the main boundary, and Chrome's own sandbox (namespaces plus seccomp-bpf for the renderer) is a second one. Playwright's Docker guide recommends exactly this setup for untrusted sites: a non-root user and a seccomp profile that allows user namespaces. With that setup Chrome starts sandboxed, but not when agent-browser is the one launching it.
What happens today (v0.43.0)
should_disable_sandboxreturnstruewhenever/.dockerenvor/run/.containerenvexists, whenCIis set, when the user is root, or when/proc/1/cgroupmentions docker, kubepods or lxc. The only way to make it returnfalseis to pass--no-sandboxyourself:cli/src/native/cdp/chrome.rs#L1621-L1660--args:chrome.rs#L591-L593Reproduction
Dockerfile:seccomp_profile.jsonis Playwright's profile (Docker's default plusclone,setnsandunsharefor user namespaces).SYS_CHROOTis in Docker's default capability set; it is listed only because the run drops all the others. The profile allowschrootonly when the container has that capability, and Chrome's namespace sandbox callschroot.Inside the container, as uid 10001:
Output of step 1:
Output of step 2:
(
13is the number of Chrome processes carrying--no-sandbox.)Proposal
An explicit opt-in that makes
should_disable_sandboxreturnfalse, checked before the container heuristics. For example:AGENT_BROWSER_CHROME_SANDBOX=1, with a--chrome-sandboxflag and achromeSandboxconfig key, as a launch setting.With it set, agent-browser would not add
--no-sandbox. If Chrome then fails to start, the existing launch error and its--no-sandboxhint already explain why. Nothing changes for anyone who doesn't set it.Playwright has the same switch as the
chromiumSandboxlaunch option.Workaround today
Launch Chrome ourselves and attach with
--cdp. That works (it is step 1 above), but it gives up agent-browser's own launch handling, and--allowed-domainsis rejected with--cdp.Environment
agent-browser installnode:22-bookworm(Debian 12), uid 10001,no-new-privilegesReproduced in a throwaway container on 2026-11-16. Drafted with AI assistance.
All reactions