Skip to content

Make sandbox network permission prompts grantable - #1048

Merged
SawyerHood merged 3 commits into
mainfrom
fix/sandbox-network-permission-grant
Aug 6, 2026
Merged

SawyerHood merged 3 commits into
mainfrom
fix/sandbox-network-permission-grant

Conversation

@SawyerHood

Copy link
Copy Markdown
Collaborator

Fixes #1041.

The problem

A first-run user could not get past a permission prompt. Allow and Deny both left the prompt on screen.

Claude asks with a SandboxNetworkAccess pseudo tool when a sandboxed command opens an outbound connection. It attaches exactly one suggestion:

{ type: "addRules",
  rules: [{ toolName: "WebFetch", ruleContent: `domain:${host}` }],
  behavior: "allow",
  destination: "localSettings" }

bb's suggestion schema accepted only destination: "session", so parseClaudePermissionUpdates dropped it. The prompt still opened, because the bridge falls back to the raw suggestion count, but it carried an empty permission profile. The client then sent an empty grant, and the server rejected it:

Allowed permission resolutions must grant at least one permission

So Allow could never resolve the prompt. Deny did resolve it, but Claude asked again on the next connection, so it looked equally stuck.

The fix

  • Accept every suggestion destination on the way in. The destination says where Claude would persist the grant, not what the grant covers. A separate schema keeps bb's own answers scoped to session, so bb still never writes a user's settings files.
  • Treat SandboxNetworkAccess as a network tool. The prompt stays grantable from the tool name alone if the suggestion shape changes again.
  • Carry Claude's prompt sentence into the banner title. The banner named the tool but never the host. Nobody can judge a network grant without it.
  • Accept an empty grant when the request has nothing to grant. A prompt that reaches the user must always be answerable. The rule still rejects an empty grant when the request did offer something.

The prompt now reads Allow network connection to registry.npmjs.org?, lists Permission: Network access, and offers Allow once / Allow for session / Deny.

Protocol version

HOST_DAEMON_PROTOCOL_VERSION goes to 75. The bridge runs in the host daemon, so enrolled machines need the update to get the fix. Both mixed pairings stay compatible: an old daemon sends the empty profile that the new server now accepts, and a new daemon sends a network profile that an old server already understands.

Tests

  • bridge.test.ts — a sandbox network ask with a localSettings suggestion now forwards a grantable network permission and the host-bearing reason.
  • pending-interactions.test.ts — an allow with an empty grant resolves a request that had nothing to grant. The existing rejection test still covers the case where the request did offer a permission.

internal-skill-trees.test.ts fails on this branch and on a clean main alike; it is unrelated.

🤖 Generated with Claude Code

Claude asks with a SandboxNetworkAccess pseudo tool when a sandboxed
command opens an outbound connection. It attaches one suggestion:
an addRules update with destination "localSettings".

bb accepted only destination "session", so it dropped that suggestion.
The prompt then reached the user with an empty permission profile.
The client sent an empty grant, and the server rejected it with
"Allowed permission resolutions must grant at least one permission".
Allow could never resolve the prompt, and Deny only made Claude ask
again on the next connection.

Changes:

- Accept every suggestion destination on the way in. The destination
  says where Claude would persist the grant, not what the grant covers.
  Answers stay scoped to the session through a separate schema, so bb
  still never writes a user's settings files.
- Treat SandboxNetworkAccess as a network tool, so the prompt is
  grantable from the tool name alone.
- Carry Claude's own prompt sentence into the banner title. The banner
  named the tool but never the host, so the user could not judge the
  grant.
- Accept an empty grant when the request has nothing to grant. A prompt
  that reaches the user must always be answerable.

Fixes #1041

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@SawyerHood

Copy link
Copy Markdown
Collaborator Author

🚨 SLOP COP 🚨 · review

I am the SlopCop. I am reviewing this change for security, code quality, performance, architecture, and end-to-end behavior.

The stack contains PR #1048 only. I found no later stack PRs and skipped no PRs.

Fixes #1041

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@SawyerHood

Copy link
Copy Markdown
Collaborator Author

🚨 SLOP COP 🚨 · review

End-to-end review complete. I started the branch dev server and a Claude Code thread in Accept Edits mode.

The app showed “Allow network connection to registry.npmjs.org?” with a Network access grant. “Allow once” resolved the prompt. The curl command then returned {} and the thread became idle.

@SawyerHood

Copy link
Copy Markdown
Collaborator Author

🚨 SLOP COP 🚨 · review

Performance review complete. I found no runtime or resource-use regression. The new parsing and validation work stays linear and adds negligible cost.

The protocol contract suite fails because its version assertion still expects 74. I posted the exact finding inline.

} from "./local.js";

export const HOST_DAEMON_PROTOCOL_VERSION = 74 as const;
export const HOST_DAEMON_PROTOCOL_VERSION = 75 as const;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

🚨 slopcop/review — High: Update the protocol-version contract test with this required bump. packages/host-daemon-contract/test/contract.test.ts:1045 still expects version 74, so pnpm exec turbo run test --filter=@bb/host-daemon-contract --force fails with 48 passes and one failure.

@SawyerHood

Copy link
Copy Markdown
Collaborator Author

🚨 SLOP COP 🚨 · review

Security review complete. I found no security defect.

The app shows a broad Network access permission before a user selects “Allow for session.” The session cache matches that contract. The change does not write provider suggestions into persistent settings.

@SawyerHood

Copy link
Copy Markdown
Collaborator Author

🚨 SLOP COP 🚨 · review

Code quality and architecture review complete. The only confirmed defect is the stale protocol-version test already reported inline.

The inbound suggestion schema and outbound session-update schema have separate contracts. This design keeps persistence scope clear. The project-wide scan found no duplicate mapper that should replace this implementation.

A small optional cleanup is to rename parseClaudePermissionUpdates so its name says that it parses suggestions.

@SawyerHood SawyerHood left a comment •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

🚨 SLOP COP 🚨 · review

One high-severity defect remains.

  • packages/host-daemon-contract/src/commands.ts:38 sets protocol version 75.
  • packages/host-daemon-contract/test/contract.test.ts:1045 still expects 74.
  • The host-daemon contract suite fails with 48 passes and one failure.

Security passed. The broad network session grant matches the permission shown before the user selects “Allow for session.” I found no persistent-settings write.

Performance passed. The new parsing and validation work adds negligible cost.

The architecture scan found no duplicate mapper that should replace this implementation. Separate inbound and outbound schemas correctly preserve the session-only response contract.

The end-to-end test passed. The branch app showed the registry.npmjs.org sandbox prompt with Network access. “Allow once” resolved it. Curl returned {}, and the thread became idle.

Focused checks passed: 61 bridge tests, 26 pending-interaction tests, and the agent-runtime and server type checks. The full server suite had one unrelated installer failure.

Fixes #1041

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@SawyerHood
SawyerHood merged commit 9daea17 into main Aug 6, 2026
10 checks passed
@SawyerHood
SawyerHood deleted the fix/sandbox-network-permission-grant branch August 6, 2026 03:38
amadad pushed a commit to amadad/bb that referenced this pull request Aug 14, 2026
Fixes get-bb#1041.

## The problem

A first-run user could not get past a permission prompt. Allow and Deny
both left the prompt on screen.

Claude asks with a `SandboxNetworkAccess` pseudo tool when a sandboxed
command opens an outbound connection. It attaches exactly one
suggestion:

```js
{ type: "addRules",
  rules: [{ toolName: "WebFetch", ruleContent: `domain:${host}` }],
  behavior: "allow",
  destination: "localSettings" }
```

bb's suggestion schema accepted only `destination: "session"`, so
`parseClaudePermissionUpdates` dropped it. The prompt still opened,
because the bridge falls back to the raw suggestion count, but it
carried an empty permission profile. The client then sent an empty
grant, and the server rejected it:

> Allowed permission resolutions must grant at least one permission

So Allow could never resolve the prompt. Deny did resolve it, but Claude
asked again on the next connection, so it looked equally stuck.

## The fix

- **Accept every suggestion destination on the way in.** The destination
says where Claude would persist the grant, not what the grant covers. A
separate schema keeps bb's own answers scoped to `session`, so bb still
never writes a user's settings files.
- **Treat `SandboxNetworkAccess` as a network tool.** The prompt stays
grantable from the tool name alone if the suggestion shape changes
again.
- **Carry Claude's prompt sentence into the banner title.** The banner
named the tool but never the host. Nobody can judge a network grant
without it.
- **Accept an empty grant when the request has nothing to grant.** A
prompt that reaches the user must always be answerable. The rule still
rejects an empty grant when the request did offer something.

The prompt now reads `Allow network connection to registry.npmjs.org?`,
lists `Permission: Network access`, and offers Allow once / Allow for
session / Deny.

## Protocol version

`HOST_DAEMON_PROTOCOL_VERSION` goes to 75. The bridge runs in the host
daemon, so enrolled machines need the update to get the fix. Both mixed
pairings stay compatible: an old daemon sends the empty profile that the
new server now accepts, and a new daemon sends a network profile that an
old server already understands.

## Tests

- `bridge.test.ts` — a sandbox network ask with a `localSettings`
suggestion now forwards a grantable network permission and the
host-bearing reason.
- `pending-interactions.test.ts` — an allow with an empty grant resolves
a request that had nothing to grant. The existing rejection test still
covers the case where the request did offer a permission.

`internal-skill-trees.test.ts` fails on this branch and on a clean
`main` alike; it is unrelated.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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.

Allowed permission resolutions must grant at least one permission

1 participant