Skip to content

Inspect owned macOS processes when sandbox blocks ps #477

Description

@janicduplessis

Problem

On macOS, a sandbox that refuses execution of setuid tools can prevent Stim from inspecting its own collector processes. Cleanup safely refuses to signal an unverified collector, but cannot finish even when the collector belongs to the workspace.

Evidence

src/process-args.ts reads commands and start times through ps. A synthetic child-process probe under a macOS sandbox returns no command/start identity when /bin/ps cannot execute. A read-only native probe using proc_pidinfo(PROC_PIDTBSDINFO) and sysctl(KERN_PROCARGS2) can inspect the same child under that policy.

Cause

Process ownership currently depends on executing ps, rather than using the non-privileged native process APIs available to a same-user process. collector/ownership.ts correctly treats failed inspection as unverified.

Fix idea

Add a bounded macOS native inspection path with exact argument boundaries and stable start-time validation. Preserve fail-closed ownership, PID-reuse checks, and existing behavior on other platforms. Verify live, exited, zombie, denied, malformed, and changed-identity cases, plus real sandboxed collector cleanup. Package the helper reproducibly without requiring a global installation or weakening the sandbox.

Activity

  1. janicduplessis commented on Sep 7, 2026

    @janicduplessis
    CollaboratorAuthor

    Claimed: fix/macos-process-inspection-477

  2. janicduplessis commented on Sep 7, 2026

    @janicduplessis
    CollaboratorAuthor

    User-directed replacement for PR #478: persist exact unique-pid identities for Stim-launched supervisors, collectors, and managed tunnels. Do not reconstruct ownership from argv. Leave externally started Metro processes alone, including legacy live records without verifiable identity. Keep device-side adb shell ps. Claimed: fix/persisted-process-477

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions