Postmortem: the macOS stop sweep killed unrelated processes
For about 25 minutes on Nov 26 2026, the macOS stop sweep SIGKILLed about 100 to 120 of the owner's own processes each time it ran.
Summary
The macOS stop sweep is meant to kill only the processes a stopped session left running. For about
25 minutes it also SIGKILLed about 100 to 120 unrelated processes of the same user, every time it ran. These
included desktop app helpers (Claude.app, Cursor) and Apple per-user daemons. It ran on every sandboxed stop, so the
real-sandbox tests triggered it many times per make check. No data was written or read, but processes died
without warning. Most respawned through launchd or their parent app.
Timeline (Nov 26 2026, US Eastern)
- 01:42: the sweep runs for the first time, in its own regression test, a few minutes before the commit.
- 01:43:53: the commit that introduced the kernel sweep lands it. Test and
make checkruns over the next 20 minutes each run it several times (every stop intest/sandbox/real.test.ts). - About 02:00: a review of the change finds that a dry run with a fresh marker matches about 200 processes.
- 02:06:21: the fix commit ("the macOS kernel sweep matched every other sandboxed process") adds a control file and a uid filter. A dry run then matches 0 processes.
- After that: the guards below.
Cause
Each spawn's sandbox profile denies reading a marker file. The sweep asked the kernel (sandbox_check) which
processes are denied that file, and killed them. The prototype compared one sandboxed process with one unsandboxed
process, and the check told them apart. It never asked about processes under other sandboxes. App sandboxes,
browser helpers and many system daemons deny reading almost everything outside their own container, so they were
"denied the marker" too. The only other filter was "not this process", and every matched process ran as the owner,
so the owner's uid stopped nothing either.
Impact
About 100 to 120 of the owner's processes per sweep, repeatedly, between about 01:42 and 02:06: app helper processes, Apple per-user agents and other sandboxed background processes. Some apps may have shown a crashed helper or lost unsaved state in that helper.
Fix and guards
- A control file per spawn (random name, created with the marker): a process matches only if it is denied the marker and allowed the control. Other sandboxes deny both, and other Viewport spawns allow both. A test with two live sessions checks that stopping one leaves the other's processes alone.
- This uid only: another user's process is never signalled.
- Ancestry plus start time: a kernel match counts only if it is a descendant the process-tree poller saw, or started after the spawn did. A reparented double fork is both new and matched. An unrelated process that started after the spawn is new but not matched, so it is never selected.
- No group-based selection: an earlier guard also killed members of process groups the spawn's descendants had led. A group id outlives its processes and can be reused by an unrelated leader, whose members then looked like targets. Group membership now selects nothing. A target must be a recorded descendant (same pid and start time) or a kernel match, and every target runs as the daemon's uid. A unit test replays crafted process table rows: a reused group id with unrelated and root-owned members selects nothing.
- A cap with abort: if a sweep would signal more than 64 processes, or any matched process started before the
spawn, the whole sweep is refused. It logs an error with the would-be pids and commands and kills known
descendants only (
planSweepinsrc/sandbox/index.ts, unit-tested). - One way to signal: daemon code sends every signal through
sendSignal(src/util/signal.ts), which tests can replace. - A guard in the test suite (
test/signal-guard-core.mjs):process.killrefuses any pid that is neither this process, a descendant of it, nor registered by the test after it verified the pid. It refuses a process group unless every member qualifies. Kill-type commands (kill,pkill,killall,launchctlstop/remove) are refused before they spawn, though that matching is a tripwire, not a sandbox. The guard runs in every vitest worker, and through NODE_OPTIONS in every node process a test spawns (daemons started byup, CLI subprocesses), which log refusals to a file the test checks. A violation fails the test even if the caller swallowed the error. Not covered: vitest's global teardown, whose leftover kill instead re-checks each pid's command, uid and group right before signalling, and non-node programs a test runs. The sweep tests assert the exact set they signalled (only the pids they started). - No pattern kills: the audit found no
pkill,killallor name matching. The only argv matching is the test leftover cleanup. It matches run-unique temp paths only, this uid only, and signals a group only when the leftover leads it.
Lessons
A kill list built from a negative test ("is denied X") needs a positive control ("is allowed Y"), checked against the whole process table and not just the processes the test made. Every code path that can signal a process it did not spawn needs a dry run that asserts the exact set, a cap, and an independent second check, before it ever runs for real on a developer machine.
Wire protocol
The contract between a Viewport Daemon, a Viewport Relay and any viewer (Console, CLI, mobile, CI). Session stream, control, pairing and approvals.
Viewport Relay
A self-hosted WebSocket relay that lets viewers reach Viewport daemons on other machines, forwarding end-to-end encrypted traffic it cannot read.