Skip to content

fix(security): extension sandbox hardening - #373

Merged
hanthor merged 5 commits into
mainfrom
sec/compass-0.28.5
Nov 17, 2026
Merged

hanthor merged 5 commits into
mainfrom
sec/compass-0.28.5

Conversation

@hanthor

@hanthor hanthor commented Nov 17, 2026

Copy link
Copy Markdown
Member

Security fixes for the extension sandbox. Details follow in the security advisories when the release is out.

🤖 Generated with Claude Code

hanthor and others added 2 commits November 17, 2026 18:51
…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>
@tuna-reef-hive

Copy link
Copy Markdown
2b080c3

ℹ️ Sentinel notice — informational; author is trusted (owner), merge is not blocked

Hive flagged this PR (author @hanthor, head 2b080c37188e) because it matches behaviors that can override security controls, escalate privileges or damage the codebase. This is a heuristic, not an accusation — a maintainer should confirm the change is intended before it merges.

  • sensitive_path — changes 3 sensitive path(s) (Touches a sensitive path (OWNERS, workflows, policies, hive config, security docs, …))
    • SECURITY.md
    • crates/compass-input-server/Cargo.toml
    • crates/compass-worker-host/Cargo.toml
  • security_policy_edit — edits security policy, scanner config, rulesets or hooks (Edits SECURITY.md, dependabot/CodeQL config, rulesets or git hooks)
    • SECURITY.md

Hive did not add the sentinel-alert label because this author is trusted. The finding remains recorded for audit and the dashboard Security tab; set sentinel.trusted_authors_block: true to require the blocking label for trusted authors too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: James Reilly <jreilly1821@gmail.com>

@tuna-reef-hive tuna-reef-hive Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-encoded file:// 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 via DBUS_SYSTEM_BUS_ADDRESS. Verdict::Unknown (no logind) serves anyone who can run the helper. That is a deliberate fail-open, stated in packaging/README.md, so I am not asking about it.
  • EngineCommands::new filtering by extension_id, Listener::admit (peer uid vs socket owner) and worker_env match 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

@tuna-reef-hive

tuna-reef-hive Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor.

hanthor this PR is held at stage/071-needs-author and the hive will not merge it yet.

Failing checks:

  • check-failure

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>

@tuna-reef-hive tuna-reef-hive Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 from peer_cred() and is compared to the socket owner's uid. In the serve loop (:192) a refused peer is logged and skipped with continue, so a foreign connection cannot end the listener. The other accept() callers I found are tests.
  • compass-core/src/wallpaper.rs kde_script: the path now goes through Url::from_file_path and then serde_json::to_string, so a quote or ) in a file name stays inside the JS string literal.
  • compass/src/extension_runner/sandbox.rs WORKER_ENV is a real allowlist. TMPDIR and COMPASS_VERSION are set separately at extension_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.json changes store.vicinae.bluetooth:devices from rendered to crashed ("connect EPERM /var/run/dbus/system_bus_socket").
  • crates/compass-core/src/onboarding.rs:321 recommends bluetooth, and the test at :598-614 (suite_1_shows_every_recommendation_rendering) requires every recommended extension to be rendered.
  • CI shows store.vicinae.bluetooth with 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>
@hanthor
hanthor merged commit 9b5d435 into main Nov 17, 2026
33 of 34 checks passed
@hanthor
hanthor deleted the sec/compass-0.28.5 branch November 17, 2026 20:26

@tuna-reef-hive tuna-reef-hive Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 after policy(..).command(..), but the policy is passed to compass-sandbox-exec as arguments (compass-sandbox/src/lib.rs:353), not environment, so nothing the launcher needs is dropped. TMPDIR and COMPASS_* are set after the clear.
  • IPC peer check (transport.rs:192): the serve loop continues on a foreign peer, so a refused connection cannot end the listener. Only the bare accept() returns the error, and its callers are tests.
  • seat.rs: the system bus is dialled at a fixed path, never from the environment. Refused and Unknown are 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 by extension_id, so another extension's command is No such command. A test pins it.
  • Application/open: files under the support or assets directories ignore appId, and only viewer types open.

The two choices a maintainer should make (they are policy, not bugs):

  1. Blanket AF_UNIX deny (syscalls.rs:884). It closes the Landlock V1 hole on connect, and the PR owns the cost: expected.json flips bluetooth:devices, dbus:explore-bus and systemd:services to crashed, and podman:containers to error-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.
  2. Fail-open without logind (seat.rs:391,401). A privileged helper on a system with no system bus socket, or no logind on it, returns Unknown, and allows() 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::verdict blocks 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 and Build, lint and test was 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant