fix(web): launch Chromium with its sandbox on where it can start

Merged
VA
5d ago
+388-21

Issue

Fixes #1613.

  • @e2e-dev/web launched Chromium without chromiumSandbox, so Playwright added --no-sandbox to every browser process.
  • The agent can follow the app to another origin, so a renderer exploit on a page it reaches ran unsandboxed as the user running e2e run.

What changed

  • A locally launched Chromium runs with its OS sandbox on by default on macOS and Windows.
  • On Linux the default stays off. The sandbox needs unprivileged user namespaces there, which root, most containers, and Ubuntu 23.10+ block, so on would fail the launch on most CI hosts.
  • web({ chromiumSandbox }) sets it either way: true on a Linux host that can sandbox, false elsewhere.
  • A sandbox that is on and cannot start fails with an ENGINE_FAILURE that names the option, in place of Playwright's launch call log.
  • connect, browser providers, Firefox and WebKit are untouched.
web({ chromiumSandbox: true }); // default: true on macOS and Windows, false on Linux
  • packages/web/src/browser-connection.ts: defaultChromiumSandbox(), and acquire takes an options object.
  • Docs: docs/reference/web.mdx, docs/security.mdx (plus ja and zh), SECURITY.md, the skill's setup.md.

Verified

Ran it locally: yes

  • testbed, e2e run tests/todos.e2e.ts on macOS, watching the Chromium the CLI spawned:
mainthis branch
browser process carries --no-sandboxdefault: no --no-sandbox, renderers start with --seatbelt-client; 7 passed
no option to change itweb({ chromiumSandbox: false }): --no-sandbox is back; 7 passed
  • Web integration suite on macOS, now sandboxed by default: 484 passed, 1 skipped.
  • Not run: chromiumSandbox: true on a Linux host that allows user namespaces. Linux CI runs the default, which is the same launch as main.