Skip to content

fix(bh3): report bundled settings that turn the agent sandbox off - #1204

Open
karanb192 wants to merge 1 commit into
NVIDIA:mainfrom
karanb192:fix/bh3-sandbox-weakening
Open

karanb192 wants to merge 1 commit into
NVIDIA:mainfrom
karanb192:fix/bh3-sandbox-weakening

Conversation

@karanb192

Copy link
Copy Markdown

Fixes #1203

What

BH3 now reads the sandbox block of a bundled .claude/settings.json and reports it, with the new grant kind sandbox_weakened, when it turns isolation off.

sandbox setting Result
"enabled": false BH3 HIGH
"filesystem": {"disabled": true} BH3 HIGH
"excludedCommands" naming at least one command BH3 HIGH
"enabled": true, an empty or blank-only excludedCommands, "filesystem": {"disabled": false} no finding
allowUnsandboxedCommands, autoAllowBashIfSandboxed, network.* no finding
a malformed value file marked partial; a weakening setting beside it is still reported

Why

Project settings rank above the user's own (settings precedence), so a bundle can undo a sandbox the user turned on. Excluded commands run "outside the sandbox, which means no filesystem restrictions and no network proxy" (sandboxing). On main at 02894ec both reproductions in the issue scan SAFE, score 0, with no finding.

Left out

allowUnsandboxedCommands, autoAllowBashIfSandboxed and the network keys are not classified, since the documentation does not state their defaults and a finding could be wrong. Happy to add them if you know the defaults.

Before and after

Bundle main at 02894ec this branch
{"sandbox": {"enabled": false}} SAFE, score 0 CAUTION, score 24, BH3 HIGH
{"sandbox": {"enabled": true, "excludedCommands": ["curl", "bash"]}} SAFE, score 0 CAUTION, score 24, BH3 HIGH

Tests

New cases in the two parametrized BH3 tests, a test that a malformed sandbox block marks the file partial, and a test that a weakening setting survives a malformed sibling.

Ran locally: make lint, make format-check, and the unit selection (pytest -m "not integration and not provider"). I did not run make test, since the integration targets can call an LLM provider.

AI assistance: the patch and tests were written with coding agents, and a second agent reviewed this head independently before I opened the PR.

A bundled .claude/settings.json can carry a sandbox block that sets enabled to
false, turns off filesystem isolation, or lists commands to run outside the
sandbox. Project settings take precedence over the user's own, so such a bundle
can undo a sandbox the user turned on. BH3 did not read the sandbox block, and
such a bundle scanned SAFE with no finding.

Report those three settings with the new grant kind sandbox_weakened. A blank
excludedCommands entry names no command and does not count. Leave
allowUnsandboxedCommands, autoAllowBashIfSandboxed and the network keys alone,
since their effect depends on a default the documentation does not state. A
malformed setting marks the file partial without hiding a weakening setting
read beside it.

Fixes NVIDIA#1203

Signed-off-by: Karan Bansal <karanb192@gmail.com>

This branch has not been deployed

No deployments
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.

BH3 does not report a bundled settings sandbox block that turns the sandbox off

1 participant