← reports

#7435 · Cleanup recovery blocked by unrelated private processes

BugPriority: MediumEffort: Highworkspaces · hostGitHub issueNovember 11, 2026

Verdict: REPRODUCED · Root-cause confidence: high · Reproduction label: confirmed-repro

1. TL;DR

Cleanup recovery can be blocked by a live same-user Linux process that has no working directory or mapped file in the workspace. The daemon scans all same-user processes, and an access-denied error while reading a process's working directory or mappings adds that process to a global uninspectable list. The server refuses recovery whenever that list is nonempty. A real process with dumpability disabled reproduces this with all four UIDs unchanged, so filtering on real UID alone cannot resolve the general case.

This is also a deliberate fail-closed deletion-safety guard: a non-dumpable process actually inside the workspace produces the same inspection result. Automatically ignoring access-denied errors would allow that genuinely active process through. No automatic fix or pull request is safe under the simple-fix rule without a reviewed safety/product decision.

2. Claims vs findings

ClaimFindingEvidence
An unrelated non-dumpable same-user process blocks recovery.VerifiedReal Linux helper outside the workspace; actual cwd/maps reads return EACCES; inspector returns zero workspace PIDs and one unreadable PID. The server's existing recovery route test returns HTTP 409 for this inspection shape.
Any of the four UIDs can qualify a process.Verified in sourceThe inspector matches any real, effective, saved, or filesystem UID. Existing inspector coverage exercises a mixed-UID fixture. No real setuid executable was run.
Recovery can never succeed on every desktop Linux machine.Not established universallyThe failure requires a live qualifying process whose metadata the daemon cannot read. A readable outside process does not block. The privileged initial control could inspect the private helper; dropping CAP_SYS_PTRACE was required to reproduce ordinary access restrictions.
The specific session services and reporter's exact remote setup fail this way.Not individually reproducedThe equivalent kernel visibility condition was recreated with an isolated helper, not the reporter's machine, desktop services, SSH session, or installed release.
Very large teardown-attempt counts and repeated message nesting occur.Unverified in this reportThese secondary symptoms were not reproduced. Current main contains a five-attempt ceiling and a prefix check; this investigation does not attribute the reported historical counter/message to the visibility defect.

3. Environment and isolation

4. Minimal reproduction

The only filesystem mock limits /proc enumeration to the helper PID. UID/status, cwd, maps, canonicalization, and the access errors all come from the real operating system; neither EACCES nor the inspector result is mocked. The helper executable and all its mapped files live outside the workspace even in the working-directory-positive control.

  1. Use a fresh checkout of the public main commit and install/build using the normal frozen commands. Building the SDK first avoids an observed clean-build ordering failure in the GitHub plugin; this is a setup issue, not the reported bug.
    git clone https://github.com/get-bb/bb.git bb-repro
    cd bb-repro
    git checkout --detach 365d7c5237ae270be0555b5b44ea61020252713e
    pnpm install --frozen-lockfile --prefer-offline
    pnpm exec turbo run build:types --filter=@get-bb/plugin-sdk
    pnpm exec turbo run build --filter=@get-bb/plugin-sdk
    pnpm exec turbo run build
  2. Save the complete test below as apps/host-daemon/src/cleanup-process-visibility.repro.test.ts. The C helper is compiled inside a new temporary directory by the test itself.
  3. On an ordinary Linux user account without CAP_SYS_PTRACE, run the test command directly. When reproducing from a privileged root shell, use the capability-dropping form shown here. Do not grant extra ptrace privileges: that removes the prerequisite.
    setpriv --bounding-set=-sys_ptrace pnpm exec turbo run test --force --filter=@bb/host-daemon -- src/cleanup-process-visibility.repro.test.ts src/workspace-processes.test.ts --silent=false
  4. Verify the existing server route's fail-closed behavior using the real database harness:
    pnpm exec turbo run test --force --filter=@bb/server -- test/services/environments/provider-orchestration.test.ts -t 'recovers interrupted cleanup only after a clear process inspection'

Expected for an unrelated process: no workspace-use blocker. Actual: the non-dumpable helper is included in unreadablePids despite being outside the workspace, and recovery policy rejects that nonempty list. The test deliberately fails its final empty-blocker assertion for that one case; this is the intended reproduction failure, not a passing fix.

DumpableCWD inside workspaceWorkspace PIDsUnreadable PIDsResult
YesNo00Correct negative control
YesYes10Correct active-process control
NoNo01Unrelated process blocks recovery
NoYes01Same result for a genuinely active hidden process

Observed diagnostic output in both final runs (dynamic PIDs omitted):

{"dumpable":true,"inside":false,"supported":true,"activeWorkspaceProcesses":0,"uninspectableProcesses":0}
{"dumpable":true,"inside":true,"supported":true,"activeWorkspaceProcesses":1,"uninspectableProcesses":0}
{"dumpable":false,"inside":false,"supported":true,"activeWorkspaceProcesses":0,"uninspectableProcesses":1}
{"dumpable":false,"inside":true,"supported":true,"activeWorkspaceProcesses":0,"uninspectableProcesses":1}

FAIL inspects a real process with dumpable=false inside=false
AssertionError: expected [HELPER_PID] to deeply equal []
Test Files: 1 failed | 1 passed (2)
Tests: 1 failed | 9 passed | 1 skipped (11)

Server route tests:
Test Files: 1 passed (1)
Tests: 2 passed | 74 skipped (76)
Complete reproducible test (expand)
import { spawn, execFileSync } from "node:child_process";
import { once } from "node:events";
import {
  mkdtemp,
  mkdir,
  readFile,
  readdir,
  readlink,
  rm,
  writeFile,
} from "node:fs/promises";
import { tmpdir } from "node:os";
import path from "node:path";
import { afterEach, expect, it, vi } from "vitest";
import { inspectWorkspaceProcesses } from "./workspace-processes.js";

vi.mock("node:fs/promises", async (importOriginal) => {
  const actual = await importOriginal<typeof import("node:fs/promises")>();
  return { ...actual, readdir: vi.fn(actual.readdir) };
});

afterEach(() => vi.resetAllMocks());

it.skipIf(process.platform !== "linux").each([
  { dumpable: true, inside: false },
  { dumpable: true, inside: true },
  { dumpable: false, inside: false },
  { dumpable: false, inside: true },
])(
  "inspects a real process with dumpable=$dumpable inside=$inside",
  async ({ dumpable, inside }) => {
    const scratch = await mkdtemp(path.join(tmpdir(), "cleanup-visibility-"));
    const workspace = path.join(scratch, "workspace");
    const outside = path.join(scratch, "outside");
    await mkdir(workspace);
    await mkdir(outside);
    const source = path.join(scratch, "helper.c");
    const executable = path.join(scratch, "helper");
    await writeFile(
      source,
      `
#include <stdio.h>
#include <stdlib.h>
#include <sys/prctl.h>
#include <unistd.h>
int main(int argumentCount, char **argumentValues) {
  if (argumentCount != 3) return 2;
  if (chdir(argumentValues[1]) != 0) return 3;
  if (prctl(PR_SET_DUMPABLE, atoi(argumentValues[2]), 0, 0, 0) != 0) return 4;
  puts("ready");
  fflush(stdout);
  for (;;) pause();
}
`,
    );
    execFileSync("cc", [source, "-o", executable]);
    const helper = spawn(
      executable,
      [inside ? workspace : outside, dumpable ? "1" : "0"],
      {
        stdio: ["ignore", "pipe", "pipe"],
      },
    );
    const exited = once(helper, "exit");
    try {
      await once(helper.stdout, "data");
      const pid = helper.pid;
      expect(pid).toBeDefined();
      const status = await readFile(`/proc/${pid}/status`, "utf8");
      expect(status).toMatch(
        new RegExp(`^Uid:\\s+${process.getuid!()}\\s`, "m"),
      );
      vi.mocked(readdir).mockResolvedValue([String(pid)] as never);
      if (dumpable) {
        expect(await readlink(`/proc/${pid}/cwd`)).toBe(
          inside ? workspace : outside,
        );
      } else {
        await expect(readlink(`/proc/${pid}/cwd`)).rejects.toMatchObject({
          code: "EACCES",
        });
        await expect(
          readFile(`/proc/${pid}/maps`, "utf8"),
        ).rejects.toMatchObject({ code: "EACCES" });
      }
      const inspection = await inspectWorkspaceProcesses(workspace);
      console.log(
        JSON.stringify({
          dumpable,
          inside,
          supported: inspection.supported,
          activeWorkspaceProcesses: inspection.pids.length,
          uninspectableProcesses: inspection.unreadablePids.length,
        }),
      );
      expect(inspection).toEqual({
        supported: true,
        pids: dumpable && inside ? [pid] : [],
        unreadablePids: dumpable ? [] : [pid],
      });
      if (!inside) expect(inspection.unreadablePids).toEqual([]);
    } finally {
      helper.kill("SIGKILL");
      await exited;
      await rm(scratch, { recursive: true, force: true });
    }
  },
);

5. Root cause

  1. Global enumeration and UID qualification, lines 43–58: every numeric procfs entry is considered, and any matching UID qualifies it. The algorithm reads cwd and maps before it can determine workspace membership.
  2. Unreadable-process classification, lines 63–81: a live process with EACCES goes into unreadablePids without evidence tying it to this workspace. Only genuine process disappearance is tolerated.
  3. Daemon RPC assembly, lines 134–149: the raw inspection is returned along with tracked setup/hook activity; no further workspace relevance filter is applied.
  4. Server recovery gate, lines 1073–1091: any unreadable PID triggers HTTP 409. This explains why zero positively identified workspace processes is insufficient.

The existing recovery route contract table explicitly expects 409 for an inspection with empty active PIDs and nonempty unreadable PIDs. The existing inspector test similarly enforces refusal for unreadable same-user processes. The new real-process experiment establishes the overlooked everyday source of that unreadability rather than pretending this was an untested conditional.

6. Proposed fix and safety decision

First choose an explicit recovery policy for processes whose workspace membership cannot be established. Preserve the fail-closed default until that policy is reviewed. A possible direction is an explicitly acknowledged, narrowly scoped operator recovery override that still blocks positively identified workspace users and active tracked hooks; it would require coordinated CLI/SDK/server/daemon contract and safety review as applicable. This report does not recommend or implement an unchecked ignore-EACCES change.

Testing only real UID is insufficient: both hidden helper cases retain the daemon's UID in all four positions. Ignoring unreadability also cannot distinguish the safe outside case from the unsafe inside case. A future regression contract must cover both outcomes and keep the active-process control.

Simple-fix decision: stopped before making a production change. Altering the fail-closed deletion-safety boundary or introducing an operator override violates the rule's no-security-boundary/no-product-decision conditions, regardless of patch size. No fix branch was pushed and no pull request was opened.

7. Pull requests and related evidence

No open pull request linked to issue #7435 was found in the issue timeline or open-PR metadata search at investigation time. No linked branch or issue-supplied code was checked out or run.

Related repository history: guarded cleanup recovery was introduced with bounded retries; #4158 concerns interrupted teardown. These explain why weakening the guard requires care; this report does not claim either resolves the current false blocker.

8. Verification

The same agent repeated the reproduction in a second clean trusted clone at 365d7c5237ae270be0555b5b44ea61020252713e; this is repeat verification, not independent review. Separate installs and builds were performed. No production source changes were copied. The exact inline test and commands in section 4 were used in each checkout, with fresh helper PIDs and temporary workspace directories. No server ports or runtime data directories were shared because no app instance was started.

9. Trust boundary and limitations

The issue body, including its proposed remedies, was treated only as untrusted claims. No issue-supplied command, script, patch, binary, external URL, or branch was executed. The helper and regression test were authored from the trusted repository code path. The demonstrated guard defect is high confidence; individual desktop services, remote macOS-to-Linux transport, original teardown EACCES, large attempt counts, and nested error text remain outside the reproduced scope.

Agent-generated SlopCop reproduction report. Complete test and sanitized evidence are embedded above; no raw logs or test files are published as separate artifacts.