#1238
sandbox: user-level carveouts for credential stores and a per-run or per-MCP-server network option
Summary
There is no supported way for a user to let selected tools through the sandbox, which makes some everyday tools unusable inside it, while the direction of #815 (approved) is to deny more credential stores. This asks for an explicit, user-level escape hatch that keeps the current security posture.
What happens today (Linux, linux-bwrap, v0.14.0 and main at 8288ae81)
ghcannot see its login.internal/sandbox/profile.goputs theghconfig directory (ghConfigDirs, fromGH_CONFIG_DIRor~/.config/gh) on the credential read-deny list. Inside the sandbox a shell commandgh auth statusprintsYou are not logged into any GitHub hosts. To log in, run: gh auth login(exit 1), while the same command outside the sandbox is logged in. On this machine the token lives in the OS keyring (hosts.ymlhas no token), so I have not isolated whether the denied path or the keyring access is what fails.- Stdio MCP servers get a private network namespace when
sandbox.networkisdeny. A local MCP server that needs a loopback relay on the host (the OpenCodebrowseMCP server, relay on127.0.0.1:19988) reportsbrowse relay did not start. The process runs in a different network namespace from the host (checked with/proc/<pid>/ns/net). Withsandbox.network: allowit runs in the host namespace and works, but that setting is global and also loosens every shell command. sandbox.networkis binary and global. There is no CLI flag, no slash command and no per-server option, so the only choices are deny everywhere or allow everywhere.
Proposal
Keep the defaults and the project-config restrictions exactly as they are, and add, honored only from the global user config and CLI (the same rule already used for sandbox.enabled, network and additionalWriteRoots):
sandbox.credentialCarveouts: a list of credential paths the user explicitly lets commands read (for example~/.config/gh), shown inzero sandbox policy.- A per-run network override (for example
--network allow|deny) and/or a per-MCP-servernetworksetting for stdio servers.
This pairs with #815: if more stores are denied by default, users need a visible way to allow the few they actually trust.
Notes
- The reproduction was done on a build of v0.14.0 carrying fork patches that do not touch
internal/sandbox/analyzer.goorprofile.go. - Happy to send a PR once this has the
issue-approvedlabel, per CONTRIBUTING.
Thanks. The three observations hold on main at
8288ae81: theghconfig directory is on the credential read-deny list,sandbox.networkisallowordenyfor the whole run, and neither can be loosened from project config.Labelled
enhancement. I am not marking it approved, because both halves change what the sandbox promises, and that is an owner decision and not a triage one:@kevincodex1 this needs your call on direction before anyone writes it. It would also help to split it into two issues, since the second could land without the first.
For the
ghcase specifically, #1237 is approved and will makeghcommands reach the network prompt. Whetherghcan then read its login is the carveout question here.