fix(web): launch Chromium with its sandbox on by default

VA
9d ago
+677-55

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, with the checkout, .env, and model keys in reach.
  • There was no config option to turn the sandbox on.

What changed

  • Chromium launches with chromiumSandbox: true by default. Firefox and WebKit never receive the option.
  • web({ chromiumSandbox: false }) opts out, as does E2E_CHROMIUM_SANDBOX=0 in the run's environment. An explicit option wins over the variable.
  • The flag resolves from the option, then the run's environment, then on. The process environment never decides a launch, per the EngineInitInfo.env contract, so a host that exports the variable in its shell cannot silently turn the sandbox off for an in-process run.
  • BrowserConnection.acquire takes the resolved flag as a required argument; the two integration tests that launch a browser directly pass false explicitly, the way they ran before.
  • Docs updated next to the no-origin-allowlist note (docs/reference/web.mdx, docs/security.mdx, SECURITY.md, skills/e2e/references/setup.md), with a .changeset entry (@e2e-dev/web, patch).
  • CI opts out explicitly (E2E_CHROMIUM_SANDBOX: '0' in spec.yml, benchmark.yml, agent.yml, examples.yml): the ubuntu-2404 runners restrict unprivileged user namespaces, so a sandboxed launch fails there. Tests that launch a real browser forward the flag into the run's environment instead of reading the process environment.
  • The smol VM's --no-sandbox is unchanged: the VM is the boundary there, and the guest browser runs inside it.

Limits

  • The sandbox contains the renderer; it does not fix the known Chromium CVEs by itself. Playwright 1.65.0 and Chromium 158 cover those through #1609.
  • Test, config, and engine code still run with the runner's full OS authority; nothing here sandboxes them.
  • On a host where the sandbox cannot start, leaving it on fails the launch with Playwright's "Chromium sandboxing failed!" error; set false or E2E_CHROMIUM_SANDBOX=0 there.

Verified

Ran it locally: yes

  • pnpm check: green (lint, dead-code, typecheck, error codes, peer ranges, changeset bumps, plugins, mcp-server, docs).
  • pnpm --filter @e2e-dev/web exec vitest run --project unit: 354 passed.
  • pnpm --filter @e2e-dev/web exec vitest run --project integration with E2E_CHROMIUM_SANDBOX=0: 379 passed, 3 failed, 1 skipped. The 3 failures are the load-sensitive app-log, provider-downloads, and semantic-fallback tests; each passes in isolation, and all three fail intermittently under parallel load, including on a main checkout in this environment.
  • Real CLI on the testbed (apps/testbed, node node_modules/e2e/dist/cli/bin.js run tests/browser.e2e.ts):
    • default: 6 failed, every one with "Chromium sandboxing failed!"
    • E2E_CHROMIUM_SANDBOX=0: 6 passed
  • pnpm --filter e2e exec vitest run tests/integration/mcp-test-run.test.ts with E2E_CHROMIUM_SANDBOX=0: 13 passed.
mainthis branch
testbed browser suite passes: the launch is unsandboxed by default, the same launch the opt-out run exercises (6 passed)testbed browser suite fails by default (6 failed, "Chromium sandboxing failed!") and passes with the opt-out (6 passed)
new sandbox unit tests fail: no such option (6 of 7 failed before the fix)13 new tests pass
web integration suite: same 3 load flakes on a main checkoutsame 3 load flakes, no new failures