← reports

#7625 · Shared storage parent in workspace permissions

BugPriority: MediumEffort: Mediumprovidershostprovider-claude-codeGitHub issue2026-11-16

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

Trusted base: da3e60b81d560e114a2bec724bb59c997aaaae7f on origin/main.

1. TL;DR

The host daemon puts the shared thread-storage parent into an environment-wide write-root list. Claude Code's workspace-scoped session builder advertises that parent as an additional directory and, when sandboxing is enabled, puts it in the filesystem write allowlist. The thread environment instead points BB_THREAD_STORAGE at a child directory belonging to that thread. A direct harness against the real manager, runtime, and session builder reproduced the mismatch twice, including in a second clean checkout. This verifies incorrect configuration, not a particular language-model decision to save a file or an executed cross-thread sandbox escape.

2. Claims vs findings

ClaimStatusEvidence
The shared parent is advertised rather than the thread child.VerifiedThe real manager produces the parent as a runtime write root; the real Claude session builder emits that same parent in additionalDirectories.
The thread environment uses its own directory.VerifiedThe production runtime resolves path.join(rootPath, threadId); the harness supplies that child to the production thread-environment builder and checks the final SDK environment.
This happens for every Claude thread, regardless of permissions.Refuted as a universal claimOnly workspace scope with acceptEdits or auto advertises these directories. The full-access negative control emits neither additional directories nor a workspace sandbox.
The parent also reaches the sandbox write configuration.Verified at the SDK-options boundarysandbox.filesystem.allowWrite contains the parent with sandboxing enabled. Disabling sandboxing does not remove the advertised additional directory.
A sibling thread's directory falls under the configured root.Verified as a path/configuration propertyA synthetic sibling lies under the advertised parent. No sibling files were read or changed, and no real provider sandbox was launched.
A model chose the parent and an inline preview rejected the resulting artifact.Unverified live behaviorNo real provider turn was run. Current inline-vis uses relative files and a thread-storage target; this investigation does not reproduce the historical error text.
The bug depends on a particular installation-directory name.RefutedThe reproduction creates a fresh temporary storage root on every run. The faulty logic is conditional on a configured root, not its spelling.

3. Environment

4. Minimal reproduction

This is a deterministic configuration-level reproduction. It does not depend on model output, screenshots, a network service, or a fake implementation of the manager/runtime/session builder. The existing runtime factory hook records manager options and returns the real runtime. The harness connects those roots to the real SDK-options builder; the intervening provider transport is inspected below, not exercised by the harness.

  1. Prepare the trusted source and generated prerequisites:
    git clone https://github.com/get-bb/bb.git bb-7625
    cd bb-7625
    git checkout --detach da3e60b81d560e114a2bec724bb59c997aaaae7f
    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 --filter=@bb/host-daemon
  2. Save the complete harness below as /tmp/bb-7625-storage-roots.mjs, then run from the repository root:
    node --conditions=source --import tsx /tmp/bb-7625-storage-roots.mjs
  3. Observe the diagnostic and intentional failed regression assertion. Expected: the shared parent is absent and the thread's child directory is present. Actual: the parent is present, the child is absent, and the command exits 1.

Actual output, identical in both final runs

The harness itself replaces its temporary-directory prefix with <fixture>. Only stack paths and runtime boilerplate are omitted here.

{
  "runtimeWriteRoots": [
    "<fixture>/thread-storage"
  ],
  "threadStorage": "<fixture>/thread-storage/thread-alpha",
  "additionalDirectories": [
    "<fixture>/thread-storage"
  ],
  "sandboxAllowWrite": [
    "<fixture>/thread-storage"
  ],
  "ownDirectoryAdvertised": false,
  "siblingDirectoryUnderAdvertisedRoot": true,
  "fullScopeAdditionalDirectories": [],
  "sandboxDisabledStillAdvertisesRoot": true
}
AssertionError [ERR_ASSERTION]: a thread must not advertise the shared storage parent as an additional directory

true !== false

actual: true
expected: false
operator: 'strictEqual'
exit: 1

Complete reproduction test

import assert from 'node:assert/strict';
import { mkdtemp, mkdir, rm } from 'node:fs/promises';
import os from 'node:os';
import path from 'node:path';
import { pathToFileURL } from 'node:url';

const repository = process.cwd();
const load = (relativePath) => import(pathToFileURL(path.join(repository, relativePath)).href);
const { RuntimeManager } = await load('apps/host-daemon/src/runtime-manager.ts');
const { createAgentRuntime } = await load('packages/agent-runtime/src/runtime.ts');
const { buildThreadShellEnvironment } = await load('packages/agent-runtime/src/thread-shell-environment.ts');
const { buildSessionOptions } = await load('plugins/provider-claude-code/src/bridge/session-options.ts');
const fixture = await mkdtemp(path.join(os.tmpdir(), 'bb-7625-fixture-'));
const workspacePath = path.join(fixture, 'workspace');
const storageRoot = path.join(fixture, 'thread-storage');
const ownStorage = path.join(storageRoot, 'thread-alpha');
await mkdir(workspacePath, { recursive: true });
await mkdir(ownStorage, { recursive: true });
let runtimeOptions;
const manager = new RuntimeManager({
  threadStorageRootPath: storageRoot,
  shellEnv: { PATH: '/usr/bin:/bin' },
  createRuntime(options) {
    runtimeOptions = options;
    return createAgentRuntime(options);
  },
});

try {
  await manager.ensureEnvironment({
    environmentId: 'environment-fixture',
    workspacePath,
  });
  assert.ok(runtimeOptions, 'environment creation must initialize the real runtime');
  const threadEnv = buildThreadShellEnvironment({
    environmentId: 'environment-fixture',
    threadId: 'thread-alpha',
    threadStoragePath: ownStorage,
    baseShellEnv: { PATH: '/usr/bin:/bin' },
  });
  const parameters = {
    additionalWorkspaceWriteRoots: runtimeOptions.additionalWorkspaceWriteRoots,
    cwd: workspacePath,
    instructionMode: 'append',
    permissionMode: 'acceptEdits',
    permissionScope: 'workspace',
    serviceTier: 'standard',
    workflowsEnabled: false,
    chromeEnabled: false,
    disable1MContext: false,
    artifactsEnabled: false,
    sandboxEnabled: true,
  };
  const options = buildSessionOptions(parameters, threadEnv);
  const fullAccess = buildSessionOptions({
    ...parameters,
    permissionMode: 'bypassPermissions',
    permissionScope: 'full',
  }, threadEnv);
  const sandboxDisabled = buildSessionOptions({
    ...parameters,
    sandboxEnabled: false,
  }, threadEnv);
  assert.equal(fullAccess.additionalDirectories, undefined);
  assert.equal(fullAccess.sandbox, undefined);
  assert.equal(sandboxDisabled.sandbox, undefined);
  assert.deepEqual(sandboxDisabled.additionalDirectories, options.additionalDirectories);
  const diagnostic = {
    runtimeWriteRoots: runtimeOptions.additionalWorkspaceWriteRoots,
    threadStorage: options.env.BB_THREAD_STORAGE,
    additionalDirectories: options.additionalDirectories,
    sandboxAllowWrite: options.sandbox?.filesystem?.allowWrite,
    ownDirectoryAdvertised: options.additionalDirectories?.includes(ownStorage) ?? false,
    siblingDirectoryUnderAdvertisedRoot: options.additionalDirectories?.some(
      (root) => path.relative(root, path.join(storageRoot, 'thread-beta')) === 'thread-beta',
    ) ?? false,
    fullScopeAdditionalDirectories: fullAccess.additionalDirectories ?? [],
    sandboxDisabledStillAdvertisesRoot: sandboxDisabled.additionalDirectories?.includes(storageRoot) ?? false,
  };
  console.log(JSON.stringify(diagnostic, null, 2).replaceAll(fixture, '<fixture>'));
  assert.equal(
    options.additionalDirectories?.includes(storageRoot) ?? false,
    false,
    'a thread must not advertise the shared storage parent as an additional directory',
  );
  assert.ok(options.additionalDirectories?.includes(ownStorage));
} finally {
  await manager.shutdownAll();
  await rm(fixture, { recursive: true, force: true });
}

5. Root cause

  1. RuntimeManager merges the shared storage parent into workspace write roots:
    const roots = [...args.workspaceRoots];
    if (args.threadStorageRootPath) {
      roots.push(args.threadStorageRootPath);
    }
    return [...new Set(roots)];
    Environment creation passes both that list and the shared root to the runtime. The list is not thread-specific.
  2. The provider process manager forwards the runtime-wide roots to its adapter. The registry adds them to static provider options, and Claude session-parameter assembly reads them unchanged.
  3. Workspace sandbox assembly uses the same list:
    const allowWrite = params.additionalWorkspaceWriteRoots ?? [];
    ...(allowWrite.length > 0
      ? { filesystem: { allowWrite: [...allowWrite] } }
      : {})
    Additional-directory assembly also uses it:
    const additionalDirectories = isWorkspaceWriteSession(params)
      ? (params.additionalWorkspaceWriteRoots ?? [])
      : [];
    The resulting SDK options therefore advertise the parent.
  4. In contrast, the thread-storage resolver joins the root and thread ID, thread-environment resolution supplies that child, and the shell-environment builder assigns it to BB_THREAD_STORAGE. These two paths disagree about scope.
  5. Current inline-vis resolves a thread-storage preview through that thread's storage location, not an environment-wide provider write list. Saving a file under the parent does not make it a child of the thread's artifact root. The historical absolute-path refusal is not asserted as a reproduced current UI behavior.

An existing runtime-manager test explicitly expects the shared root. This explains why the existing suite can pass despite the new isolation assertion failing.

6. Proposed fix and automation safety

Keep workspace/git-metadata roots environment-scoped, but derive a thread's artifact directory at a thread-aware session boundary. Grant and advertise that directory consistently with BB_THREAD_STORAGE without retaining the shared parent. Before implementing, verify how static adapter options interact with sessions sharing a provider process, resume/restart paths, and other providers; preserve legitimate workspace metadata access.

No automatic PR: this changes filesystem permission/security boundaries and spans host/runtime/provider responsibilities. Those are explicit exclusions from the simple-fix rule, irrespective of line count. No production patch, fix branch, or source push was made. An eventual maintainer-owned change should replace the existing parent-root expectation and demonstrate that sibling storage is not granted while each thread retains access to its own artifacts.

7. Verification: second clean checkout

The same agent repeated the harness in a separately created detached worktree of the trusted base commit. This is a repeat verification, not an independent review. A full build regenerated an unrelated web route file; that generated output was restored to the recorded commit before the final clean verification.

git worktree add --detach /tmp/bb-7625-verify da3e60b81d560e114a2bec724bb59c997aaaae7f
cd /tmp/bb-7625-verify
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
git restore --source=HEAD -- apps/web/src/routeTree.gen.ts
git status --porcelain
git rev-parse HEAD
node --conditions=source --import tsx /tmp/bb-7625-storage-roots.mjs
git status --porcelain

The two status checks emitted nothing. HEAD was the full base SHA. The reproduction emitted the same diagnostic and failed at the same isolation assertion with exit 1; each invocation allocated fresh temporary directories and deleted them in its cleanup block. No ports were used. No report conclusion changed after the second run.

Relevant existing checks, unchanged production source:

pnpm exec turbo run test --filter=@bb/host-daemon -- src/runtime-manager.test.ts
Test Files  1 passed (1)
Tests       48 passed (48)

pnpm exec turbo run build
Tasks: 74 successful, 74 total

8. Related issues and PRs

Repository search did not identify an open duplicate fix. The issue's connected/cross-referenced PR timeline was empty, and an open-PR search for this issue number returned no results. No linked PR code was checked out or executed. Nearby provider-directory reports did not supply a fix for this storage-scope mismatch.

9. Appendix: evidence and limits

> AGENT GENERATED