fix(server): report a root preview browser as root, not AppArmor #18950
main fromrefs/pull/18950/head·opened View on GitHubOpening a preview while the server runs as root fails because Chrome will not start its sandbox as uid 0. Playwright rewrites that abort to "Chromium sandboxing failed!", and the server reports it as an AppArmor problem. t3 browser setup then says the host is ready, so the suggested fix cannot resolve the failure.
Change#
When the process uid is 0 and the sandbox is still on, launch diagnosis returns a separate root error. It names both workarounds: run the service as a nonroot User=, or set T3CODE_SERVER_BROWSER_SANDBOX=0. It does not mention AppArmor or t3 browser setup.
t3 browser setup warns about that same condition instead of saying the host is ready. A sudo invocation from a non-root user still reports ready when the AppArmor and library checks pass, because that process is root only for setup. Non-root AppArmor and library diagnosis is unchanged.
The server also logs the root warning at startup, before a tab is opened.
Scope and approval#
Fixes #18938. The accepted scope on that issue is the root diagnosis and the setup ready message.
Verification#
vp test run on:
apps/server/src/preview/PreviewBrowserHost.test.tsapps/server/src/cli/browser.test.tsapps/server/src/preview/ServerBrowserStream.test.ts
25 tests passed. A root process with the sandbox on reports the root error and does not mention AppArmor or browser setup. A non-root sandbox failure still reports AppArmor. Setup for a root service prints the warning; setup for a non-root user, and sudo setup for a non-root user, still prints ready. Server package typecheck reported no errors.
Head bdf1fd85ba145b20897109b72aa4117ba9a32ad6 on base upstream/main bbd98a5f8.
Limitations: not run against a real root systemd service; the root path is covered by unit tests that stub uid 0.
Model and harness: Grok 4.7 (high effort) in a Cursor Cloud Agent.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
Approvability#
Verdict: Approved at
bdf1fd8Macroscope's review found this PR approvable — This is a focused, well-tested diagnostic bug fix that distinguishes root Chrome sandbox failures from AppArmor problems without altering normal browser setup or other runtime paths. The added production logic is limited to warnings, error classification, and actionable messaging.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Advanced
- Run ID:
8f77f396-f10e-4cb9-b50c-278836726b40
📥 Commits
-
Reviewing files that changed from the base of the PR and between bbd98a5f873eaed5f5efbfbacc6913ee87804443 and bdf1fd85ba145b20897109b72aa4117ba9a32ad6.
📒 Files selected for processing (7)
-
apps/server/src/cli/browser.test.tsapps/server/src/cli/browser.tsapps/server/src/preview/PreviewBrowserHost.test.tsapps/server/src/preview/PreviewBrowserHost.tsapps/server/src/preview/ServerBrowser.tsapps/server/src/preview/ServerBrowserStream.test.tsdocs/user/remote-access.md
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
-
📝 Walkthrough
-
Preview browser diagnosis now distinguishes Chrome’s root sandbox refusal from host sandbox setup failures. Browser setup output accounts for root and sudo context. Startup diagnostics and user guidance include the root-specific case.
Changes: Root sandbox refusal handling
Layer / File(s) Summary Detect root sandbox refusal
apps/server/src/preview/PreviewBrowserHost.ts,apps/server/src/preview/PreviewBrowserHost.test.tsLaunch diagnosis recognizes Chrome’s root-refusal output and returns a root-specific error when the process runs as root without the sandbox override. Tests cover root and non-root cases, the override, and missing-library diagnosis. Report root launch errors
apps/server/src/preview/ServerBrowser.ts,apps/server/src/preview/ServerBrowserStream.test.tsServer startup and launch handling use the root-specific message. A stream test checks that this error does not use the host-setup close response. Report root context in browser setup
apps/server/src/cli/browser.ts,apps/server/src/cli/browser.test.ts,docs/user/remote-access.mdThe extracted setup handler uses root and sudo context when reporting readiness. Tests cover setup output across user and platform cases. Remote-access guidance recommends a nonroot service user and retains the sandbox override. Priority: ➖ Normal
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers:
juliusmarminge
Merge Risk: ⚪ Minimal · up to
bdf1f-
Preview browser failures under a root server now report a root-specific error instead of an AppArmor one. Setup output and the docs point to running as a non-root user or setting the sandbox override. The change looks low risk to merge.
Security architecture risk: ⚪ Minimal · up to
bdf1f-
The change identifies root-related browser failures more accurately without automatically disabling the sandbox, granting privileges, or opening new access paths. Running the service as a nonroot user remains the recommended remedy.
Retained concerns No architecture-level concerns identified.
Security review details
-
Security Blast Radius
- inferred — The effective exposure change is limited to diagnosis and operator guidance for existing browser consumers. The inspected paths do not expand remote reachability, browser launch privilege, or the scope of the existing sandbox opt-out.
Trust Boundaries and Controls
- observed — Preview-stream authentication remains upstream of viewer attachment, and operation-scope enforcement remains intact. The root diagnostic is consumed as a launch failure rather than an authorization decision.
- observed — The new sudo-origin heuristic can suppress the setup root warning, but it does not confer root authority or alter sandbox launch options. Privileged setup operations remain guarded by the process UID, whose default comes from process.getuid.
-
Pre-merge checks ·
4-
Passed checks (4 passed)-
Check name Status Explanation Title check The title clearly and concisely describes the main change: root preview-browser failures are reported as root sandbox issues instead of AppArmor issues. Description check The description explains the problem, change, scope approval, verification results, and limitation. The problem text appears before the Change heading instead of under an explicit Problem heading, but… Linked Issues check Issue #18938requires a distinct root diagnosis and setup output that does not claim readiness for a root service with sandboxing enabled.sandboxRefusedAsRootchecks uid 0 and the sandbox setting. …Out of Scope Changes check The changed source files implement issue #18938. The added tests cover root diagnosis, setup output, startup reporting, and preserved nonroot behavior. The remote-access documentation updates the same…
-
✨ Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
-
coderabbitai[bot](GitHub profile, opens in a new tab) approved these changes
Note
Written by
gpt-6.1-solon behalf of MariaThanks for investigating the root browser failure. This unvouched submission changes 518 lines across seven files, exceeding our current 500-line limit for taking over outside submissions. Under Read this first, review capacity is limited and right now we are only taking focused bug fixes from outside contributors. Please preserve the diagnosis problem in #18938 and request reconsideration with a substantially smaller patch focused on root diagnosis and the setup message.
maria-rcks closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes