Repository navigation
1.1.78: sealed X servers, one shared X11 socket, Wayland security context, jail display for services - #273
Merged
Conversation
…text, jail display for services The three items 1.1.77 left open in TODO §7. X servers crate starts (Xvfb, Xephyr, Xorg) ran without access control (-ac, or no -auth). Each run now makes a MIT-MAGIC-COOKIE-1, starts the server with -auth and gives the cookie to the jail (/var/run/crate-Xauthority, XAUTHORITY), x11vnc, the embedded VNC server and `crate gui screenshot`. The shared X11 mode mounted the host's whole /tmp/.X11-unix read-write; it mounts a private directory with a hard link to the socket of the display DISPLAY names, read-only. websockify had no listen address (every interface); it listens on gui/vnc_bind, which is now accepted in every mode with a VNC server. gui: auto / gui.mode: wayland bound the host compositor's own socket, privileged protocols included. crate asks the compositor for a security context (wp_security_context_v1, hand-written wire client, no libwayland) and mounts that restricted socket. New key gui/wayland_security_context: auto | require | off; `crate doctor` and `crate audit` know about it. Services, hooks and the healthcheck get the jail's DISPLAY, XAUTHORITY, WAYLAND_DISPLAY and XDG_RUNTIME_DIR on both exec paths; exec_in_jail gains the optional fields lang, display, xauthority, wayland_display, xdg_runtime_dir, each validated by the daemon. Jail env values are quoted on the sh -c line. Checked on Linux stand-ins (Xvfb, websockify, sway 1.9); not yet on FreeBSD — docs/on-hardware-validation.md §4t. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X6t6tzVypHye5bDGLxzmZK
own_x_socket_dir took a Check pointer out of a temporary Report and read it after the Report was gone (ASan: heap-use-after-free). Test only. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X6t6tzVypHye5bDGLxzmZK
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.
The three items 1.1.77 left open in TODO §7 (two MED, one LOW).
What changes
1. The X servers crate starts are sealed (MED).
Xvfb ran with
-ac; Xephyr and Xorg had no-auth, which an X server reads as "every local client is welcome". Their sockets are in the host's/tmp/.X11-unix, so any local user or shared-mode jail could read another tenant's display.MIT-MAGIC-COOKIE-1and starts its server with-auth./var/run/crate-Xauthority(XAUTHORITY), to x11vnc, to the embedded VNC server and tocrate gui screenshot.DISPLAYnames, read-only. It used to mount the host's whole/tmp/.X11-unixread-write.gui/vnc_bind(loopback by default). It had no listen address and served noVNC on every interface.gui/vnc_bindis now accepted in every mode that can have a VNC server.2. Wayland: a socket the compositor restricts (MED).
gui: auto/gui.mode: waylandbound the host compositor's own socket, privileged protocols included.wp_security_context_v1) and mounts that restricted socket instead.lib/wayland_wire_pureandlib/wayland_security_context.gui/wayland_security_context:auto(default; falls back to the raw socket with a warning),require(restricted or no run),off(raw on purpose).crate doctorreports whether the compositor can do it;crate auditreports the restricted socket as a PASS.3. Services and hooks see the jail's display (LOW).
DISPLAY,XAUTHORITY,WAYLAND_DISPLAYandXDG_RUNTIME_DIRwent on the main command's env(1) line only. JailExec now carries them on both exec paths.exec_in_jailprivops request gains optional fieldslang,display,xauthority,wayland_display,xdg_runtime_dir. The names are fixed and the daemon checks each value's shape.sh -cline.Behaviour changes to know about
127.0.0.1unlessgui/vnc_bindsays otherwise.headless/nested/gpudisplay.x11shared jail sees one socket, read-only; a host X server restart needs a jail restart.gui: auto/waylandjail loses layer-shell, screencopy, virtual input and data-control. A jail meant to have them setsgui/wayland_security_context: off.How it was checked
-Werrorwayland_security_context_testunder ASan + UBSan127.0.0.1:portlistens on loopback only; bare port listens on every interfacekill -9of the owner stops new connections; nesting answered "not offered"The new unit test drives the client against a stand-in compositor written in the test from the protocol text, including both passed file descriptors.
Not run on FreeBSD. Everything above is from Linux stand-ins. The on-hardware checks are in
docs/on-hardware-validation.md§4t.Left open (TODO §7)
/var/run/cratelooks unreachable (plausible, needs hardware; found while doing this, not fixed here).jexecwith crate's environment.Generated by Claude Code