Repository navigation
devcloud 0.12.0: a headless Chromium and poppler in the image, for the web fetch tool (board #133) - #374
Merged
Conversation
…e web plugin's fetch tool (board #133) packages.sh gains poppler-utils in part apt and a fourth part, chromium (its own Dockerfile layer): Playwright's Chrome Headless Shell pinned by playwright-core 1.64.1 (chromium_headless_shell-1248, the build the Macs run) under /opt/ms-playwright, the shared libraries it links, a stable /usr/local/bin/chrome-headless-shell, and an AppArmor profile granting the binary user namespaces, which Ubuntu 24.04 grants no unconfined program and Chromium's sandbox needs; loaded where AppArmor runs (a VM). The boot writes WEB_CHROME into /etc/devcloud/env as an image default under the profile's pairs (steps.IMAGE_ENV), so a session a service starts finds the renderer as a shell's does. Tests: the image renders a script-built page sandboxed and extracts a PDF's text as the user; the user's zsh runs $WEB_CHROME on a booted host. Sminos-Session: web-fetch-plugin#700c5e84 (doperpowers on macbook)
The first gate run failed at the chromium part's --version check on the runners: Chrome for Testing's linux64 build needs libatk-bridge-2.0, which Playwright's arm64 build does not link (readelf NEEDED of both). Sminos-Session: web-fetch-plugin#700c5e84 (doperpowers on macbook)
…does and what a container needs Sminos-Session: web-fetch-plugin#700c5e84 (doperpowers on macbook)
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Board #133: devcloud hosts serve the
webplugin's fetch tool (mcp__web__fetch) at the Macs' fidelity. Before this, a host could not render pages that need their scripts ("rendering unavailable on this machine: no Chromium found") and could not extract a PDF's text ("pdftotext is not on PATH").What changes on hosts
pdftotext:poppler-utilsinpackages.sh's apt part.packages.shpart,chromium, which the Dockerfile builds as its own layer. It installs Playwright's Chrome Headless Shell at/opt/ms-playwright, pinned by[email protected](chromium_headless_shell-1248, Chrome for Testing 156.0.8078.4, the same build the Macs run), and only the shared libraries the binary links (checked against readelf's NEEDED list on both architectures). It also adds the link/usr/local/bin/chrome-headless-shelland an AppArmor profile,/etc/apparmor.d/devcloud-chrome-headless-shell, that grants that binary user namespaces. The profile is loaded at once wherever AppArmor runs (a VM's setup) and byapparmor.serviceat every boot.WEB_CHROME: the boot writes it into/etc/devcloud/envas an image default (steps.IMAGE_ENV), below the profile's own values. Services read that file too, so a seat started by the sminos daemon finds the browser the same way a shell does. SettingWEB_CHROME=noneinprofile.envturns rendering off on every host.The Chromium sandbox (the deciding question)
The clipper starts Chromium with its sandbox on. That sandbox needs unprivileged user namespaces, and Ubuntu 24.04 (
kernel.apparmor_restrict_unprivileged_userns=1) allows them only for a program that an AppArmor profile names. Ubuntu ships such profiles for Google Chrome and others, but none for Playwright's paths.VMs: the sandbox works with the image's profile. I tested both forms setup.sh builds, starting from this branch's recipe:
On each, a running renderer had its own user and pid namespaces and seccomp mode 2. With the profile unloaded, the same fetch fails with
No usable sandbox!and the tool keeps the plain fetch. After a reboot the profile was loaded again from/etc/apparmor.d(shown on GCE), so a baked image also gets it.Containers: a default
docker runcannot start the sandbox. Docker's default seccomp profile refuses to create a user namespace withoutCAP_SYS_ADMIN. The fetch then keeps the plain page with a "rendering failed … No usable sandbox!" note. It does not render unsandboxed. I measured four ways of running the container, as a non-root user, on colima (Docker 29.5.2) and on the Hetzner VM's Docker 29.9.2:docker runwith--security-opt seccomp=unconfined(Docker's AppArmor profile stays on)--cap-add SYS_ADMIN--privilegedFor you to decide: I did not add
--no-sandboxanywhere. If sandbox containers should render, these are the options, in my order of preference:clone/unsharewithCLONE_NEWUSER, or simplyseccomp=unconfined. It loosens the container boundary somewhat, but keeps Chromium's sandbox and Docker's AppArmor profile.--no-sandboxin containers only, and treat the container as the boundary. That is what Playwright does by default, but the container holds the user's credentials as the same uid, so a compromised renderer reaches all of them.Image size
docker history): 2.48 → 3.04 GB, +562 MB.chromiumlayer is 537 MB: the browser is 280 MB, and libgbm1 pulls in mesa-libgallium and libllvm20 (with libicu74), about 220 MB.run.shprints on the CI runners (x86_64): 0.7 → 0.9 GB. On colima the samedocker image inspectfigure (which looks like the compressed size) went from 0.776 to 0.987 GB.Verification
ci-gateis GREEN on x86_64 runners for the final HEAD (https://github.com/SSFSKIM/doperpowers/actions/runs/40230673533). This includes a new image case: as the user, in a container with seccomp unconfined standing in for a VM, the clipper renders a page built by script (106 words, rendered, no notes) and extracts a 3-page PDF (one outline entry per page;pdftotext version 24.02.0). It also includes a new host check: the user's zsh runs$WEB_CHROME.pdftotext -vreports 24.02.0.clip.mjs fetch https://excalidraw.com/renders 51 words with no notes.clip.mjs fetch https://arxiv.org/pdf/1706.03762savespage.txt(61,843 bytes) with 15 outline entries, one per page.WEB_CHROMEis set for the sminos daemon and the other services on the GCE VM (read from/proc/<pid>/environ).Not verified
apparmorpackage that loads the profile.devcloud vm image builditself: the reboot shows the profile loads at boot, but I did not bake an image.check_imageon arm64. Locally it failed closed under colima's virtiofs (logged in the friction tracker). It passed in CI on x86_64.Sminos-Session: web-fetch-plugin#700c5e84 (doperpowers on macbook)