Repository navigation
fix(security): extension sandbox hardening - #373
Conversation
…t helper to the seat user Extension sandbox: - The seccomp filter refuses socket(AF_UNIX, ...). Landlock V1 does not mediate connect() on a pathname socket, so a worker could reach the session bus (and through systemd or a portal start an unconfined process) or the engine's IPC socket. socketpair stays allowed for Node's child stdio. - The worker starts with a cleared environment plus an allowlist, so the bus, display, agent and COMPASS_SOCKET addresses are not handed over. - The IPC listener refuses a peer whose uid is not the socket owner's. Input helper: - While it holds CAP_DAC_OVERRIDE (or runs as root), it reads keys and injects only when its real user has the active logind session on a seat, asked over the system bus at its fixed address and rechecked at most once a second. Seatless (SSH) and switched-away users get nothing. - createSnippet with an empty keyword is refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: James Reilly <jreilly1821@gmail.com>
The extension worker is confined; the engine that answers its calls is not. Four calls let an extension use the engine to act outside the sandbox: - Application/runInTerminal started any command line on the host. It now starts nothing and answers false. HostCommand/run, which takes a bare program name from the overrides list and asks first, stays the way to run a host program. - Command/launchCommand found every installed extension's commands. It now finds only the running extension's own; another extension's command is "No such command". - Wallpaper/set on KDE pasted the path into a Plasma script. The image is now a JSON string literal of a percent-encoded file URI. - Application/open honoured appId for a file the extension wrote. For a file under the extension's support or assets directory it now ignores appId and opens only a viewer type with the default opener. Divergences from upstream are recorded in docs/rust-engine/PARITY.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: James Reilly <jreilly1821@gmail.com>
2b080c3
ℹ️ Sentinel notice — informational; author is trusted (owner), merge is not blockedHive flagged this PR (author @hanthor, head
Hive did not add the |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: James Reilly <jreilly1821@gmail.com>
There was a problem hiding this comment.
Decision needed: @hanthor should io_uring_setup be denied in the seccomp filter (or confirmed unreachable from the worker) before the new AF_UNIX socket() rule is relied on as the sandbox boundary?
Read the diff against the tree at 80bfe2d. The changes look coherent and each has a test beside it, but this PR is a sandbox boundary, SECURITY.md and a privileged helper, so I am routing it rather than signing off.
Open question (not a confirmed bypass). The new rule denies socket(AF_UNIX, …) by argument (crates/compass-sandbox/src/syscalls.rs:215, applied at :231). It is a filter on the socket syscall only. io_uring_setup is not on the denylist, and grep -rn uring crates/compass-sandbox finds nothing but unrelated comments. Newer kernels can create and connect sockets through io_uring (IORING_OP_SOCKET, IORING_OP_CONNECT) without going through the filtered syscall. I have not shown that Node or an extension can reach io_uring here, since that needs native code in the worker. The new test a_unix_socket_outside_every_grant_cannot_be_reached only probes socket(2) directly, so it would not notice. The env_clear() layer (extension_runner.rs:257) still holds in that case. If it is already unreachable (for example because loading a native addon is blocked), a sentence in syscalls.rs saying so would settle it.
CI. Suite 1 on the host: 120 store extensions, first frame is red and cargo-deny (advisories) is red. The run was still in progress, so I could not read either log. The PR's own PARITY.md row 2a says an extension that talks to a local daemon over its socket now fails by design, so the Suite 1 failure may be that, or may be a regression. Someone should confirm which. The advisories failure looks like the one #372 addresses, but I did not verify that.
What I checked and found correct
kde_script(wallpaper.rs): the path becomes a percent-encodedfile://URI, then a JSON string literal. A quote or)stays inside the literal. The new test round-trips an injection-shaped name.seat.rs: unprivileged callers are never refused, and the system bus is reached at its fixed socket, not viaDBUS_SYSTEM_BUS_ADDRESS.Verdict::Unknown(no logind) serves anyone who can run the helper. That is a deliberate fail-open, stated inpackaging/README.md, so I am not asking about it.EngineCommands::newfiltering byextension_id,Listener::admit(peer uid vs socket owner) andworker_envmatch what their tests assert.
One small note: the gate calls logind with block_on on the helper's main loop, at most once a second (server.rs, per key event). A logind that hangs would stall key handling for as long as the call runs. This is not a security problem, just worth knowing.
I have not approved, closed or labelled anything.
— hive: agent=reviewer backend=claude model=claude-sonnet-5-5 effort=high claude=2.1.322
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. hanthor this PR is held at Failing checks:
Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path. |
Extension workers can no longer open unix sockets, by design, so the store extensions that talk to the system bus (bluetooth, systemd, the D-Bus explorer) or to podman's socket now fail at first frame. Record the new verdicts so Suite 1 keeps guarding everything else. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: James Reilly <jreilly1821@gmail.com>
There was a problem hiding this comment.
Decision needed: @hanthor should decide whether to accept that the AF_UNIX seccomp denial turns four store extensions (bluetooth, dbus, podman, systemd) from rendering to crashing, and whether this fix should be public before the advisory is published.
Not ready to merge as it stands: one required check fails because of this diff, and two decisions are the owner's. The hardening itself looks sound where I read it.
What I verified (read at 7afe421)
compass-ipc/src/transport.rs: the peer uid comes frompeer_cred()and is compared to the socket owner's uid. In the serve loop (:192) a refused peer is logged and skipped withcontinue, so a foreign connection cannot end the listener. The otheraccept()callers I found are tests.compass-core/src/wallpaper.rskde_script: the path now goes throughUrl::from_file_pathand thenserde_json::to_string, so a quote or)in a file name stays inside the JS string literal.compass/src/extension_runner/sandbox.rsWORKER_ENVis a real allowlist.TMPDIRandCOMPASS_VERSIONare set separately atextension_runner.rs:259,262, which matches the PARITY.md text.
Finding 1 (medium): the Build, lint and test failure is caused by this PR.
scripts/suite1/expected.jsonchangesstore.vicinae.bluetooth:devicesfromrenderedtocrashed("connect EPERM /var/run/dbus/system_bus_socket").crates/compass-core/src/onboarding.rs:321recommendsbluetooth, and the test at:598-614(suite_1_shows_every_recommendation_rendering) requires every recommended extension to berendered.- CI shows
store.vicinae.bluetoothwith left["crashed"]and right["rendered"], the only failing test (929 of 930 passed). - Consequence: the check is red. Even with the test relaxed, a new user's first-run recommendation would be an extension that now crashes. Either drop or replace the recommendation, or keep that extension working.
Finding 2 (decision, not a defect): the AF_UNIX denial is a deliberate regression for four extensions. expected.json also moves dbus:explore-bus to crashed, systemd:services to crashed and podman:containers to error-toast. PARITY.md row 2a says "fails, by design". I cannot tell whether that trade is acceptable. Any extension that talks to a local daemon over a Unix socket stops working.
Finding 3 (decision): disclosure timing. The body says "details follow in the security advisories when the release is out". The diff itself spells out the mechanisms in SECURITY.md, docs/rust-engine/PARITY.md, packaging/README.md and code comments:
- a worker reaching the session bus to start an unsandboxed process;
- script injection through a KDE wallpaper file name;
- other users driving the input helper.
If the advisory is meant to precede the details, merging to a public main first reverses that order.
Unrelated to this diff: cargo-deny (advisories) fails on RUSTSEC-2026-0459 (libsqlite3-sys) and an xattr unsound advisory. This PR changes only 3 lines of Cargo.lock, and #372 targets these advisories.
I have not approved, merged or closed anything.
— hive: agent=reviewer backend=claude model=claude-sonnet-5-5 effort=high claude=2.1.322
The Bluetooth extension talks to the system bus, which an extension can no longer reach, so it crashes at first frame. Recommend Color Converter instead, which Suite 1 shows rendering and needs no account or socket. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: James Reilly <jreilly1821@gmail.com>
There was a problem hiding this comment.
Decision needed: @hanthor should decide whether denying every AF_UNIX socket() to extension workers is worth the loss of the Bluetooth, D-Bus explorer, systemd and Podman extensions, and whether the input helper should keep serving anyone when logind is absent (Verdict::Unknown).
No defect found in the diff; routing to a human because it rewrites trust surfaces (sandbox syscall policy, a file-capability helper, the worker environment).
I read the changed code at cd3cc97 and the callers it touches. What I checked and found sound:
- Worker env (
extension_runner.rs:257):env_clear()runs afterpolicy(..).command(..), but the policy is passed tocompass-sandbox-execas arguments (compass-sandbox/src/lib.rs:353), not environment, so nothing the launcher needs is dropped.TMPDIRandCOMPASS_*are set after the clear. - IPC peer check (
transport.rs:192): the serve loopcontinues on a foreign peer, so a refused connection cannot end the listener. Only the bareaccept()returns the error, and its callers are tests. seat.rs: the system bus is dialled at a fixed path, never from the environment.RefusedandUnknownare the only two failure outcomes, and the unprivileged path never touches the bus.kde_script: the path now reaches Plasma as a JSON string literal of a percent-encoded URI, and the new test covers a quote-and-paren name.launchCommand: the filter is byextension_id, so another extension's command isNo such command. A test pins it.Application/open: files under the support or assets directories ignoreappId, and only viewer types open.
The two choices a maintainer should make (they are policy, not bugs):
- Blanket
AF_UNIXdeny (syscalls.rs:884). It closes the Landlock V1 hole onconnect, and the PR owns the cost:expected.jsonflipsbluetooth:devices,dbus:explore-busandsystemd:servicestocrashed, andpodman:containerstoerror-toast(scripts/suite1/expected.json:116,152,310,376). Any other extension that uses a local daemon socket will fail the same way. If that is the intended trade, it should be in the release notes. - Fail-open without logind (
seat.rs:391,401). A privileged helper on a system with no system bus socket, or no logind on it, returnsUnknown, andallows()treats that as allowed (seat.rs:357). The README says so (packaging/README.md, "serves whoever can run it"), so the file-capability exposure the PR describes stays open on seatd-only systems unless the admin adds the group restriction. That may be right, but it is a decision.
Smaller notes, none blocking:
- The PR body gives no detail ("Details follow in the security advisories"). That is fine if it is deliberate, but the diff is wider than "extension sandbox": it also changes the input helper, the engine IPC socket, KDE wallpaper and the onboarding recommendations (Bluetooth swapped for Color Converter).
Gate::verdictblocks the helper's single loop on a D-Bus round trip at most once a second (seat.rs:384). I did not measure it, so this is an open question about typing latency, not a finding.- CI:
cargo-deny (advisories)fails andBuild, lint and testwas still running when I looked. #372 is open and says it clears two cargo-deny advisories; I did not verify they are the ones failing here.
— hive: agent=reviewer backend=claude model=claude-sonnet-5-5 effort=high claude=2.1.322
Security fixes for the extension sandbox. Details follow in the security advisories when the release is out.
🤖 Generated with Claude Code