Skip to content

feat(scene): run browser sources' renderers in Chromium's sandbox on Linux and macOS - #223

Draft
kixelated wants to merge 4 commits into
mainfrom
quest/m1/browser-sandbox
Draft

kixelated wants to merge 4 commits into
mainfrom
quest/m1/browser-sandbox

Conversation

@kixelated

@kixelated kixelated commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Works on quest/m1/browser-sandbox.md: Linux and macOS land here; Windows stays in the quest, behind Browser sources on Windows.

Problem

Every platform started CEF with --no-sandbox, so a page that exploited a renderer bug (a hostile page, or an overlay site that got compromised) ran with the creator's full rights: their files, keys, and stream credentials. The README told users to add only pages they trust.

Approach

  • No --no-sandbox. Each page's renderer, and CEF's GPU and utility processes, run in Chromium's own sandbox.
  • Linux: Chromium's namespace sandbox needs unprivileged user namespaces. moq_scene::browser::sandbox::check (new, rs/moq-scene/src/browser/sandbox.rs) asks the kernel the same question Chromium does before CEF starts: in a forked child, make a user namespace, map the user into it, and make another inside it. Where the kernel refuses (Ubuntu's AppArmor since 23.10, a user.max_user_namespaces of 0), or the studio runs as root, the helper fails with a reason saying what to allow, and every browser source shows it. No page ever renders unsandboxed, and the browser never reaches Chromium's own No usable sandbox! abort.
  • macOS: each helper app enters its Seatbelt sandbox through CEF's libcef_sandbox.dylib (cef::sandbox::Sandbox) before it loads CEF's framework, as CEF's sample helpers do. CEF moved from the static cef_sandbox.a the quest named to this dylib, which the bundle already carries in the framework's Libraries, so nothing links in and sign.sh needs no change: the existing allow-jit entitlements suffice (the bundle job's browser tests show it).
  • Test: a_renderer_cannot_read_the_user_s_files writes a file outside the profile and checks that the helper can reach it and no renderer can: on Linux by looking through /proc/<pid>/root, which the sandbox moves to a dead thread's fdinfo; on macOS by asking Seatbelt with sandbox_check(pid, "file-read-data", path).
  • Nightly: the software render job, on Ubuntu 24.04, installs the README's AppArmor profile for the studio it tests, so the README's recipe is exercised on the distribution it is for.

Impact

  • Browser sources render each page sandboxed on Linux and macOS.
  • On Linux, browser sources now fail, with the reason, where user namespaces are refused or the studio runs as root. The README says how to allow them on Ubuntu with an AppArmor profile. (Browser sources on Linux are only in builds from source with cef; the Flatpak has none.)
  • Public API: none (sandbox is private to moq_scene::browser). Wire: none.

Decisions

Taken without the maintainer, each one a review can undo:

  1. Linux, namespaces only. The setuid-root chrome-sandbox fallback is not counted on: it takes root to install, and the copy CEF leaves beside the binary is not setuid. A user who installs it setuid still gets the namespace check's failure. Recommendation: keep, as the Plan recommended; Ubuntu's own guidance is the AppArmor profile.
  2. The studio's own check rather than Chromium's abort. Chromium decides the same thing inside the zygote host and aborts the browser with a log line; checking first turns that into a reason every browser source shows. The check mirrors Chromium's Credentials::CanCreateProcessInNewUserNS (nested CLONE_NEWUSER with the user mapped) minus its capability drop, which no mainline kernel's answer depends on.
  3. Prove it from outside the renderer. The test asks the kernel (Linux) and Seatbelt (macOS) what the renderer's process can reach, rather than adding a file-open hook to the production renderer for the test to call.
  4. CEF crate's loader on macOS. cef::sandbox::Sandbox panics if the bundle lacks libcef_sandbox.dylib or Seatbelt refuses; every bundle has it, so a panic there is a broken bundle, and loud.
  5. Nightly installs the AppArmor profile rather than sysctl kernel.apparmor_restrict_unprivileged_userns=0, so it tests what the README tells users to do.

Validation

  • Linux, CPU raster (fedora, lavapipe): all 17 browser tests pass sandboxed, just render-sw's way. The renderer under test shows the sandbox: root /proc/<pid>/fdinfo of an exited thread, Seccomp: 2, NoNewPrivs: 1, nested PID namespaces.
  • Differential: with --no-sandbox put back, a_renderer_cannot_read_the_user_s_files fails (renderer … reads …/stream-key) on both fedora and nixos; without it, it passes.
  • Linux, GPU path (nixos, RTX 3070 Ti, headless sway with its GLES renderer): unsandboxed baseline 16/17 (the sandbox test fails, as it should); sandboxed, 16/17 on the first run and 17/17 on two more runs. The first run's miss was a_click_reaches_the_page staying black past its 20 s wait on a loaded host (the CARLA demo and CI runners share it; that run's every test ran 2 to 4 times slower), and it passed three times more on its own. With sway's pixman renderer, or on fedora's AMD iGPU through the dev shell's Mesa, the GPU path draws black with or without the sandbox, so neither says anything about it.
  • Refusal: under bwrap --unshare-user --disable-userns, a page fails at once with browser: Chromium sandboxes pages in user namespaces, and this system refuses to make a user namespace: allow them, as the README describes for browser sources on Linux.
  • just ci passes locally.
  • CI: nightly dispatched on this branch (run 44848291984): RESULTS

Follow-ups

  • quest/m1/browser-sandbox-mac-check.md (new, XS): the maintainer runs a browser source in the Developer ID signed, notarized app from its disk image and checks Activity Monitor's Sandbox column; no reachable Mac runs a signed app, and CI tests only the ad hoc bundle. No open decisions.
  • quest/m0/nightly-macos-check.md (new, S): nightly's macOS just ci has failed on main since 2026-11-19 with two macOS-only compile errors (IOSurfaceRef::id in a mach.rs test, dead ids in controls.rs), found when this branch's nightly hit them. No open decisions.
  • quest/m1/browser-sandbox.md is rewritten to the Windows part.

Models

Size: L
Implementer: Claude Code, claude-opus-5-5, unknown effort

🤖 Generated with Claude Code

Review

Rewritten by quest review after each round.

  • Head: d46d481

  • Base: origin/main at 9b77182

  • Risk: high, it changes .github/workflows/nightly.yml, which is always high: workflows run with the repository's secrets and decide what merges and ships

  • Classified: high by the always-high paths

  • Reviewer: Codex, gpt-6.1-sol, xhigh effort

  • Session: 01a1fbc1-f0b6-7b03-a430-c4d24e56c96e, round 1

  • Score: 8/10, Source inspection found no actionable defects, but builds and tests were not run, leaving runtime behavior unverified.

  • Rounds: 1; first round 0; findings 0: fixed 0, refuted 0, open 0

  • Findings: none

  • Reviewer: Codex, gpt-6.1-sol, high effort, shadow

  • Session: 01a1fbc1-f0b6-7ae2-9a73-dad5715d85ff, round 1

  • Score: 9/10, No actionable defects were found; the source changes appear sound, but builds, tests, and platform runtime behavior were not independently verified.

  • Rounds: 1; first round 0; findings 0: fixed 0, refuted 0, open 0

  • Findings: none

kixelated and others added 4 commits November 20, 2026 16:43
…Linux and macOS

The helper no longer passes --no-sandbox. On Linux it first checks, as
Chromium does, that the kernel lets the studio's user make a user namespace
and another inside it, and fails every browser source saying what to allow
where it cannot, rather than let the browser abort. On macOS each helper app
enters its Seatbelt sandbox through CEF's libcef_sandbox.dylib before it
loads CEF's framework.

A browser test proves a page's renderer cannot reach a file the helper can,
through its moved root on Linux and its Seatbelt policy on macOS. The
nightly software render job allows the studio user namespaces with the
AppArmor profile the README gives for Ubuntu.

Windows stays in quest/m1/browser-sandbox.md, behind browser sources on
Windows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title Chromium's sandbox for browser sources feat(scene): run browser sources' renderers in Chromium's sandbox on Linux and macOS Nov 21, 2026

This branch has not been deployed

No deployments
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