Repository navigation
feat(sandbox): support secure Chromium isolation (#4098) #5946
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
sunilteja93
wants to merge
4
commits into
ai-openshell:main
Choose a base branch
from
sunilteja93:feat/4098-secure-browser/sunilteja93
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+565
−0
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f78f8fd
test(sandbox): preserve nested userns denial baseline
sunilteja93 527c67c
test(sandbox): verify Chromium isolation boundary invariants
sunilteja93 77860a3
test(browser): verify native Chromium sandbox in restricted Podman
sunilteja93 a1fbbe7
feat(podman): define isolated Chromium browser container spec
sunilteja93 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| FROM debian:bookworm-slim | ||
|
|
||
| RUN apt-get update && \ | ||
| DEBIAN_FRONTEND=noninteractive apt-get install -y \ | ||
| --no-install-recommends \ | ||
| chromium ca-certificates util-linux fonts-liberation \ | ||
| && rm -rf /var/lib/apt/lists/* \ | ||
| && groupadd -g 1000 sandbox \ | ||
| && useradd -u 1000 -g 1000 -m -s /bin/sh sandbox \ | ||
| && mkdir -p /sandbox \ | ||
| && chown sandbox:sandbox /sandbox | ||
|
|
||
| COPY --chmod=0555 verify-sandbox.sh /usr/local/bin/verify-sandbox | ||
|
|
||
| USER sandbox:sandbox | ||
| WORKDIR /sandbox | ||
| ENV HOME=/sandbox | ||
| CMD ["sleep", "infinity"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| # Chromium isolation for OpenShell — #4098 | ||
|
|
||
| > **Design and verification work in progress.** This directory does not yet | ||
| > provide supported Chromium execution, and the existing browser probe is | ||
| > currently expected to fail. Do not use `--no-sandbox` to make it pass. | ||
|
|
||
| ## Goal and non-negotiable invariants | ||
|
|
||
| Enable Chromium/Playwright with Chromium's **own user-namespace and seccomp | ||
| sandbox** while preserving the existing *agent workload* restrictions: | ||
|
|
||
| - Ordinary agent processes continue to lack effective and bounding | ||
| capabilities, with `no_new_privs=1` and OpenShell seccomp enforcement. | ||
| - The workload cannot create nested user namespaces or invoke `chroot`. | ||
| - The browser cannot access supervisor credentials, gateway secrets, | ||
| agent workspace files by default, or another sandbox's control/data. | ||
| - The browser has no direct Internet-facing interface, no host network, | ||
| no privileged container, and no broad host mounts. | ||
| - Browser egress is mediated by OpenShell's supervisor **before** any | ||
| destination connection; the browser cannot override DNS or proxy routes. | ||
| - Control is authenticated and bound to sandbox identity and runtime | ||
| generation, not exposed as an unauthenticated CDP TCP listener. | ||
| - If any required enforcement cannot be established or inspected, | ||
| provisioning fails closed. No `--no-sandbox` fallback. | ||
|
|
||
| The ordinary workload baseline is executable as | ||
| `e2e/rust/tests/chromium_boundary_baseline.rs` in the Podman E2E lane. | ||
|
|
||
| ## Current evidence (not an implementation) | ||
|
|
||
| At OpenShell base `8ff5b6087`, the baseline Podman E2E suite passed 77 | ||
| conformance tests, and the ordinary-workload nested-userns denial test passed. | ||
| In a **separate standalone Podman control**, Chromium failed with | ||
| `sys_chroot("/proc/self/fdinfo/") == 0`; direct `chroot /` also returned `EPERM` | ||
| under `--cap-drop=all --security-opt=no-new-privileges`. A nested user | ||
| namespace could be created in that standalone container, but could not make | ||
| `chroot` succeed. This is consistent with an inherited OCI seccomp decision, | ||
| not definitive proof of the specific denying layer. | ||
|
|
||
| In an earlier *diagnostic-only* OpenShell worktree, user namespace creation | ||
| could be made to succeed through opt-in changes, yet mount namespace creation | ||
| continued to fail with `EPERM` and Chromium reported `No usable sandbox!`. | ||
| Those opt-in changes are **not** part of the proposed production solution. | ||
|
|
||
| ## Candidate architecture (not yet approved) | ||
|
|
||
| ```text | ||
| ordinary agent workload | ||
| existing seccomp/Landlock, network=none | ||
| | | ||
| authenticated, sandbox-scoped browser control | ||
| | | ||
| isolated browser execution boundary | ||
| no agent mounts, no supervisor secrets, no direct egress | ||
| | | ||
| authenticated, policy-mediated egress adapter | ||
| | | ||
| trusted OpenShell supervisor -> approved destination | ||
| ``` | ||
|
|
||
| Do not treat a local Chrome proxy flag as the egress security boundary. | ||
| A browser can initiate non-proxy sockets, DNS and loopback requests. The | ||
| **outer** browser network fence must prevent all unauthorized routes, | ||
| including when the browser or renderer is compromised. The egress adapter | ||
| must retain policy attribution, DNS validation, TLS/L7 rules, policy reload | ||
| semantics and audit events; inability to enforce these means fail closed. | ||
|
|
||
| The browser boundary also needs independent security review: Chromium requires | ||
| operations that the existing agent workload forbids. Enabling them in a new | ||
| boundary is not equivalent to proving that the boundary is secure. A Podman | ||
| sidecar may require an explicitly validated runtime profile; a microVM | ||
| implementation may instead require a separate guest. Neither is implemented | ||
| or approved by this document. | ||
|
|
||
| ## Required implementation gates | ||
|
|
||
| 1. **Product scope:** Maintainer acceptance that a separately managed browser | ||
| execution boundary satisfies #4098's *in-guest* Chromium requirement. | ||
| 2. **Identity and lifecycle:** Only gateway/driver-authorized sandbox sessions | ||
| can create and access the browser. Close control connections and terminate | ||
| the browser on stop/delete, restart or generation mismatch, and supervisor | ||
| failure. Reconnection and cleanup must be idempotent. | ||
| 3. **Filesystem and process isolation:** No supervisor secrets or implicit | ||
| workspace mounts; non-root default, capability budget justified per | ||
| boundary; all mount points and runtime identity verified after creation. | ||
| 4. **Network and control:** No host/bridge route from the browser; authenticated | ||
| non-public CDP bridge; every external connection governed by the same | ||
| destination and L7 rules as the agent, including after a policy reload. | ||
| 5. **Native Chromium sandbox:** Verify `chrome://sandbox` in addition to | ||
| renderer namespace, seccomp, `NoNewPrivs` and capability state. Verify | ||
| that Chromium does not automatically fall back to `--no-sandbox`. | ||
| 6. **Adversarial tests:** Unauthorized CDP access, raw TCP/UDP/DNS egress, | ||
| metadata/loopback access, secret and agent-file reads, policy reload, | ||
| symlink/mount attacks, driver crash, and cross-sandbox access must fail. | ||
| 7. **Runtime support:** Podman and microVM coverage per the issue, with an | ||
| explicit unsupported-runtime error when any mandatory isolation feature | ||
| cannot be provided. | ||
|
|
||
| A PR is **not complete** merely because it starts Chromium or because the | ||
| agent-workload regression test passes. Native Chromium sandbox operation, | ||
| policy-governed networking, and a real adversarial E2E pass are the merge | ||
| criteria. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| #!/bin/sh | ||
| set -eu | ||
|
|
||
| baseline_ns=$(readlink /proc/self/ns/user) | ||
| baseline_filters=$(awk '/^Seccomp_filters:/ {print $2}' /proc/self/status) | ||
|
|
||
| chromium \ | ||
| --headless \ | ||
| --disable-gpu \ | ||
| --disable-dev-shm-usage \ | ||
| --no-first-run \ | ||
| --user-data-dir=/tmp/chromium-e2e-profile \ | ||
| about:blank >/tmp/chromium-e2e.log 2>&1 & | ||
|
|
||
| browser_pid=$! | ||
| trap 'kill "$browser_pid" 2>/dev/null || true' EXIT | ||
|
|
||
| sleep 5 | ||
|
|
||
| verified=0 | ||
|
|
||
| for proc in /proc/[0-9]*; do | ||
| executable=$(readlink "$proc/exe" 2>/dev/null || true) | ||
|
|
||
| case "$executable" in | ||
| */chromium|*/chrome) ;; | ||
| *) continue ;; | ||
| esac | ||
|
|
||
| args=$(tr '\000' ' ' < "$proc/cmdline" 2>/dev/null || true) | ||
|
|
||
| case "$args" in | ||
| *--type=renderer*) ;; | ||
| *) continue ;; | ||
| esac | ||
|
|
||
| namespace=$(readlink "$proc/ns/user" 2>/dev/null || true) | ||
| nnp=$(awk '/^NoNewPrivs:/ {print $2}' "$proc/status" 2>/dev/null || true) | ||
| seccomp=$(awk '/^Seccomp:/ {print $2}' "$proc/status" 2>/dev/null || true) | ||
| filters=$(awk '/^Seccomp_filters:/ {print $2}' "$proc/status" 2>/dev/null || true) | ||
| capabilities=$(awk '/^CapEff:/ {print $2}' "$proc/status" 2>/dev/null || true) | ||
|
|
||
| if [ "$namespace" != "$baseline_ns" ] && | ||
| [ -n "$namespace" ] && | ||
| [ "$nnp" = 1 ] && | ||
| [ "$seccomp" = 2 ] && | ||
| [ "$capabilities" = 0000000000000000 ] && | ||
| [ -n "$filters" ] && | ||
| [ "$filters" -gt "$baseline_filters" ]; then | ||
| verified=$((verified + 1)) | ||
| fi | ||
| done | ||
|
|
||
| if [ "$verified" -lt 1 ]; then | ||
| echo "CHROMIUM_SANDBOX_VERIFICATION_FAILED" | ||
| tail -n 30 /tmp/chromium-e2e.log | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "CHROMIUM_SANDBOX_VERIFIED renderers=$verified" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these podman-only? What are the expectations for the other drivers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @elezar, that's a valid point.
The initial implementation is podman-specific because I started with the runtime where I could reproduce the Chromium namespace restriction and validate native chromium renderer sandboxing in a standalone, restricted container.
I don't intend podman-only support to be the final scope of #4098. The issue explicitly covers both Podman and microVM, so both need supported implementations and regression coverage. For Docker and Kubernetes, I haven't validated an equivalent boundary yet, and I wouldn't want to claim support or relax their existing security restrictions.
My preference is to keep the security requirements runtime-independent, while allowing each driver to implement and verify an appropriate isolation mechanism. Unsupported configurations should fail explicitly without falling back to "--no-sandbox".
Would you prefer a shared browser-execution capability or contract across compute drivers, with runtime-specific implementations, rather than introducing the browser specification directly in the Podman driver?
I also want to confirm whether the separately managed browser boundary is an acceptable direction before extending the implementation.
Happy to adjust the design based on your guidance.