Skip to content

Audit — 2026-11-13 ​

On this page ​

One pass over the compositor for general improvements and fixes. Four subsystem sweeps (protocols/views/lock, input/portals, backends/render/capture, IPC/config/shell/services) plus a main-loop and notification-service pass; every finding below was traced in the current tree, and the rejected list at the bottom records what was suspected, checked, and cleared. Ranked by how much a session can lose to each one.

The gate this was audited against: cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace, and the JavaScript shell suites — all green at commit 3f03eaeb.

F1 — A session locked by an external locker is treated as a built-in lock ​

Crates: crates/viewport. Effort S, risk low. Behavioural.

Four code paths ask the configured lock mode (lock_mode.is_built_in()) where the rest of the tree correctly asks who actually took the lock (lock_owned_by_shell). They come apart the moment an ext-session-lock-v1 locker (swaylock, gtklock) locks a session whose config left idle.lock_command unset — which is the default. shell_owns_lock in state/lock_power.rs:429 and refocus_lock in handlers/session_lock.rs:403 already state the rule; these four were missed:

  • state/capture.rs:204 — the pointer/touch hit-test while locked. With an external locker drawing on a built-in-configured session, lock_mode.is_built_in() && lock_screen_is_drawing() is both true, so surface_under answers shell_under(pos): clicks, scrolls and taps pass through the lock screen into the live shell behind it (taskbar, clipboard picker, notification centre, power menu). A touch tap also moves wl_keyboard off the locker onto the shell. Fixed by refocus_lock's twin (FIXES.md-adjacent, render_frame.rs:741 has the same shape for the same reason).
  • render_frame.rs:741 — the shell_lock frame gate. Same confusion; while an external locker holds the session, the shell's desktop buffer can be composited as a "lock screen" (the shell page is still live behind the locker), which paints the desktop over the locker exactly as the fail-closed rule in lock_screen_is_drawing exists to prevent.
  • apply.rs:468 — SessionQuery. The comment above it describes the shell-owned case only. Under an external locker, session.query (sent by viewport msg -t session.query, or by the shell after a reload) emits Event::SessionLock and calls focus_lock_shell() — which is a shell_owns_lock-gated no-op for the focus half, but the SessionLock event still tells the shell to draw a second lock screen and forget_lock_screen() fires. A page is instructed to draw a lock screen for a lock it does not own, and session.unlock against it is ignored by try_unlock (state/lock_power.rs:317) — a second, unreachable lock screen.
  • handlers/session_lock.rs:175 — unlock(). The self.lock_mode.is_built_in() disjunct tells the shell to clear a lock screen when the configured mode is built-in, even when an external locker owns the session. A shell page left holding a lock screen over an external locker's session is a desktop nobody can click; a page that never drew one misses the SessionUnlock it needs after the takeover case the comment describes.

How it was verified. Read all four sites and every caller of lock_screen_is_drawing, focus_lock_shell, forget_lock_screen; read shell_owns_lock/shell_lock_message_applies and their tests (state/lock_power.rs:455–492), which document the exact bug ("an external locker on the default config used to hit" this); traced SessionLockHandler::lock/unlock and lock_with_shell to see which flag each path sets; grepped every lock_mode.is_built_in() use in the tree and classified each.

Minimal fix. Replace the four lock_mode.is_built_in() gates with ownership: capture.rs:204 and render_frame.rs:741 with self.lock_owned_by_shell, apply.rs:468 with state.lock_owned_by_shell, and session_lock.rs:175 with self.lock_owned_by_shell. One behavioural test pins the whole family.

F2 — launcher.launch and shell.overview bypass the lock gates ​

Crates: crates/viewport. Effort S, risk low. Behavioural.

Two more members of the same family, with sharper edges:

  • apply.rs:58–70 — acts_while_locked refuses ShellExec while locked but not LauncherLaunch (apply.rs:768). Behind a lock screen, a trusted socket client can launcher.query + launcher.launch and start any .desktop Exec= line via spawn_with_env (state/clipboard_launcher.rs:181) — a command execution path on the host, reachable while the user believes the machine is locked. ShellExec is in the list for exactly this reason; the launcher's twin is missing.
  • apply.rs:31–36 — moves_focus guards ViewFocus, BackgroundFocus, ShellFocus but not ShellOverview (apply.rs:411–429). While locked, shell.overview active=true runs focus_shell_at(None) / drops keyboard focus to None — moving the seat keyboard off an external locker's lock surface (the next key press's refocus_lock repairs it, but the in-flight keystroke is already gone; a password character can land nowhere).
  • apply.rs:2106 — set_view_minimized clears keyboard focus when minimizing the focused window, with no state.locked guard. state.focused still names the pre-lock window after a lock, so view.minimized on that id drops the lock screen's keyboard focus the same way.

How it was verified. Read moves_focus, acts_while_locked, reads_only (apply.rs:28–92) against every Request variant handled in apply; traced LauncherLaunch → launcher_launch → spawn_with_env; read ShellOverview's focus block and set_view_minimized's; checked the SessionQuery comment for which lock shape it believes it is serving.

Minimal fix. Add Request::LauncherLaunch { .. } and Request::ShellOverview { .. } to their respective lists (overview both focuses and clears per-view state, so moves_focus is the right list), and guard set_view_minimized's focus drop with !state.locked. Same test as F1 pins these.

F3 — A notification's owner is forgotten while its centre entry is still live ​

Crates: crates/viewport. Effort S, risk low. Behavioural.

Notifications::closed (notification.rs:214–219) removes the id's owner from the owners map unconditionally. But a popup expiry (apply.rs:699) or dismissal (apply.rs:694) deliberately leaves the notification in notification_history — that is what the centre is. From that moment, for every notification sitting in the centre:

  • may_close (notification.rs:322) falls through to true — any process on the session bus can CloseNotification(id) and delete the entry;
  • invoke_action → emit_to_owner (notification.rs:227) finds no owner and broadcasts ActionInvoked to every connection on the bus, violating the unicast invariant at notification.rs:203–206;
  • the owner's own Notify(replaces_id=id) no longer resolves (notification.rs:293) and stacks a duplicate instead of updating.

Conversely, History::forget/clear (notification.rs:665–676) drop entries without dropping their owners, so an id forgotten from the centre leaks its row in owners (the eviction path trim/forget_owners handles only age-out). Also fixed with it: NotificationForget/clear (apply.rs:713–724) now prune owners for the ids they drop.

How it was verified. Traced Server::notify/close_notification, resolve_id, may_close, emit_to_owner, closed; the History record / forget / clear / trim / share_owners paths; and the four Request::Notification* arms in apply.rs:676–724. Confirmed the centre's contract: expiry/dismissal keep the entry (apply.rs comments at :683–689 say so in as many words).

Minimal fix. An id's owner lives as long as the notification does in either place: closed() stops removing from owners when the id is still in the history; History::forget/clear return (or are told) the ids they dropped so their owners go too. Unit-tested in notification.rs's existing owner-map harness.

F4 — wp-pointer-warp-v1 computes the wrong target and skips the serial check ​

Effort S, risk low. Behavioural (test would fail pre-fix).

handlers/mod.rs:1356: let to = at - origin + position; — surface_under returns origin = pos − local, the surface's global origin, so the sum is local + position in global coordinates. A client at (1920,0) warping to surface-local (400,300) with the cursor at (2000,100) lands at (480,400) — on the wrong monitor. hint_target (handlers/mod.rs:1019) does the same arithmetic correctly (hint + origin). The enter serial is also accepted unverified, and position is not checked against the surface, so a hovered client may warp the pointer onto other windows/outputs and out of confinement.

F5 — XWaylandKeyboardGrabHandler hands back a Wayland focus for an X11 surface ​

Effort S, risk low.

handlers/mod.rs:1439–1444 returns surface.clone().into() — the stale shape from before KeyboardFocus grew the X11 arm (keyboard_focus.rs:1–52 documents why the arm exists). Smithay's XWaylandKeyboardGrab re-sets that focus on the first key event: KeyboardFocus::Wayland != KeyboardFocus::X11, so Smithay fires leave on the X11 window — X focus back to PointerRoot, the exact bug keyboard_focus.rs:12–22 describes — and a background X11 client's XGrabKeyboard also steals the seat from a focused Wayland window (the resolver checks neither locked nor current ownership).

F6 — Layer-shell popups are never unconstrained ​

Effort S, risk low.

unconstrain_popup (handlers/xdg_shell.rs:734–741) resolves the root via self.views.find_by_surface, which layer surfaces are never in, and WlrLayerShellHandler::new_popup (handlers/layer_shell.rs:124–139) never calls it at all — so xdg_popups parented to layer surfaces (waybar menus, launcher completion lists) are clipped at output edges instead of flipping/sliding.

F7 — XWayland property updates other than _NET_WM_STATE are dropped ​

Effort S, risk low. Behavioural.

handlers/xwayland.rs:309–313 matches only WmWindowProperty::NetWmState; Title, Class and TransientFor changes never reach notify_props / notify_parent, so shell titlebars and taskbar entries freeze at the map title — and the conservative re-derivation of capture: false rules in notify_props (handlers/xdg_shell.rs:593–603) never runs for X11 windows, so an X11 window whose title turns sensitive after map stays capturable. Twin of FIXES.md #15's view.close gap: ForeignToplevelHandler::close_toplevel (handlers/mod.rs:422–426) also only asks window.toplevel(), so an X11 window's foreign-toplevel close is a no-op.

F8 — viewport msg breaks --rules JSON and silently drops two reply types ​

Effort S, risk very low.

"rules" in the global STRING_FIELDS (msg.rs:130, added for config.keyboard --rules) makes config.layer_rules --rules '[…]' and config.workspaces --rules '{…}' send a JSON string; the compositor refuses both with a type error. Per-type overrides already exist (Type::strings, msg.rs:146). Separately, reply_for (msg.rs:931–943) has no arm for clipboard.query / notification.list, so the CLI swallows the clipboard.history / notification.history event and exits 0 printing nothing.

F9 — GPU recovery ladder disarms mid-reset; removed-GPU device is reopened deadlocked ​

Effort S, risk medium.

Three error paths in recovery.rs fail without recording the error (reactivate_device :560–563, rebuild_renderer :601–606, install_device :691–701), so a multi-second GPU reset that outlives one step zeroes device.errors and the ladder disarms with the screen still frozen. on_gpu_removed (:953–980) drops a device without releasing its logind seat fd, so a same-node Reopen fails TakeDevice forever; the offline slot also spins the tick at 400 ms instead of backing off (:357–360).

F10 — Lock screen, cursor, screenshots and clipboard cross capture boundaries ​

Effort S, risk low.

render::layers (render.rs:415–439) ignores the capture flag in the locked branch, so an output capture streams the live lock surface and cursor (window captures correctly answer window_elements' self.locked guard, state/screencast.rs:1170). handle_screenshot (state/screencast.rs:1372–1399) and ClipboardRead/ClipboardSet (:1346–1368) have no self.locked guard at all, unlike every picker path.

F11 — send_frame_callbacks walks every window on every monitor ​

Effort S, risk low.

state/frame_clock.rs:125–163 iterates self.space.elements() with |_, _| Some(output.clone()) per output per vblank; the same bug in the render walks was already fixed (udev.rs:4428's test pins it). A 240 Hz monitor drives a 60 Hz monitor's clients at 240 fps; wallpaper terminals are also never invited by the fallback tick.

F12 — viewport-shell-cef/-chromium re-open their reload gate on the method result ​

Effort S, risk low.

shell.reload closes the event gate until Page.loadEventFired (FIXES.md #9/#10's shape), but the reload's own Page.reload result callback re-opens it (viewport-shell-cef/src/main.rs:876–905, viewport-shell-chromium/src/main.rs:562) before the new document's scripts have attached, so queued events are evaluated into a page nobody is listening on and lost.

F13 — Small ones, each with its own trace ​

Effort S each.

  • state/shell_lifecycle.rs — servoshell drops startup Wake::Compositor events queued before App::Running and evaluates private events with no origin check (viewport-shell-servo/src/main.rs:260–262,399).
  • inhibit.rs — logs unbounded untrusted strings at INFO before the caps (:321–323,482–489); cookie advance on refused holds (:177–186); a SimulateUserActivity from any bus peer cancels an in-progress lock_delay (:365).
  • hyprcursor.rs — Resize::None uses an unclamped define_size, so a hostile theme overflows u32 (:205–215,596) or OOMs; cursor animation .sum::<u32>() overflows on two long delays (cursor.rs:295,355).
  • settings::apply (settings.rs:536–554) drops ten motion/group fields the overlay schema carries, and config.layout_extensions sent over the socket skips the built-in-name/remote-URL validation the file path enforces (config.rs:1264–1291).

Considered and rejected ​

Each was suspected, traced, and cleared. Keeping the list so the next audit does not re-open them.

  • post_error without data_init.init on New<T> refusals (color_management.rs:490, color_representation.rs:293, tearing.rs:180, output_management.rs:631). Looks like the uninitialized-new_id crash FIXES.md #1 was, but wayland-backend only panics when the client is still alive after post_error, which kills it synchronously. Verified in wayland-backend 0.3.17.
  • trim_carried_acquire_points evicting pending points ahead of signalled ones (handlers/compositor.rs:125–138). Inverted-looking on purpose: the cap exists so a client with never-signalled fences cannot wedge capture, and the newest commit's point is inserted after the trim. Unit-tested.
  • Unbounded icon::pixmap_url dimension multiply (icon.rs:488). Dimensions are filtered positive on the line above, bounding the product below 2⁶⁴ on this target.
  • servoshell token leak via Access-Control-Allow-Origin: * (viewport-shell-servoshell/src/main.rs:859). The userscript's window.top !== window and origin gates exit before TOKEN is installed, and the directory is 0700.
  • replaces_id = u32::MAX pinning the id counter (notification.rs:304). That branch is gated on owned, which requires the sender to already hold the id.
  • Pointer-constraint region arithmetic panics (pointer.rs:107, cursor.rs:500). Widen to i64/saturating first, and degenerate regions fall back to the whole surface rather than a f64::clamp panic.
  • Magnifier transforms skipped on relative mouse / libei absolute events (input.rs:2103, libei.rs:435). Deliberate: the cursor lives in unmagnified logical coordinates; only panel-glass devices (touch, absolute tablets) need glass_to_content. magnify.rs:14–40 documents it.
  • Idle Activity::Release swallowing the wake after a timer blank (idle.rs:126–145). awaiting_release is armed only by chord-initiated blanks and cleared on the first deliberate act; timer blanks never set it.
  • Explicit-sync fences deadlocking capture readbacks (state/capture.rs:85). Capture is gated behind capture_service_ready(), which checks every carried point's signalled state and arms a retry timer instead of waiting.
  • Private-window blur leaking through ext-background-effect-v1 (render.rs:476–521). layers assembles front-to-back and the private window's pixels are replaced in place by an opaque element before any later element's capture can read the framebuffer.

Compositor licensed under GPL-3.0-or-later · Protocol, shell, bridges and renderer licensed under MIT.