sandbox.excludedCommands does not bypass network restrictions (SSH blocked for git)
Bug Description
sandbox.excludedCommands does not exempt commands from network sandbox restrictions. Commands listed in excludedCommands are documented as running with "full system access (no isolation)", but the network sandbox still applies, blocking protocols like SSH (port 22) even for excluded commands.
This makes git push over SSH impossible when the sandbox is enabled, even with "git" in excludedCommands.
Reproduction Steps
- Configure sandbox settings:
{
"sandbox": {
"enabled": true,
"excludedCommands": ["git"],
"network": {
"allowedDomains": ["github.com"]
}
}
}
- Run
git pushvia the Bash tool on a repo with an SSH remote - Observe the error:
ssh: connect to host github.com port 22: Network is unreachable
fatal: Could not read from remote repository.
- Running
ssh -vT git@github.comdirectly also fails — confirming the network sandbox applies globally, not per-command:
debug1: Connecting to github.com [140.82.116.3] port 22.
debug1: connect to address 140.82.116.3 port 22: Network is unreachable
- SSH to github.com works fine outside of Claude Code.
Expected Behavior
Commands in excludedCommands should bypass all sandbox restrictions, including network filtering. git push over SSH should work when "git" is in excludedCommands.
Actual Behavior
excludedCommands appears to only bypass filesystem sandboxing (bubblewrap). The network sandbox (domain/port restrictions) is applied globally to all commands regardless of excludedCommands, blocking SSH (port 22) even when the domain is in allowedDomains.
Possible Solutions
excludedCommandsshould also bypass network restrictions for the excluded process and its children- Alternatively,
allowedDomainscould support port-aware entries or a protocol allowlist (e.g., allow SSH on port 22 in addition to HTTPS)
Environment
- Claude Code version: 2.1.39
- OS: NixOS, Linux 6.12.68
- Shell: zsh
- Git remote transport: SSH
6 Comments
+1
meanwhile, until it's fixed, if you use Github you can bypass it by using Github's https:// for Git's remote.
I am facing a similar issue.
Even with "git" and "glab" in excludedCommands, SSH-based git operations fail with:
```
hostkeys_find_by_key_hostfile: hostkeys_foreach failed for /Users/<user>/.ssh/known_hosts: Operation not permitted
Host key verification failed.
fatal: Could not read from remote repository.
Confirming this also affects macOS (arm64, Apple Silicon) on Claude Code 2.1.72.
The error manifestation is slightly different on macOS: instead of a direct "port 22 unreachable", the sandbox injects an
ncproxy wrapper (not from~/.ssh/config) that fails DNS resolution:Notable: even with
allowedDomains: ["*"]set, the SSH subprocess is still blocked. UsingdangerouslyDisableSandbox: trueworks around it immediately.(Closed #33300 as duplicate of this issue.)
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
This is still broken as of version
2.1.107? Closing the issue automatically doesn't make these things go away, it just infuriates the paying users?This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.