[BUG] sandbox: SOCKS5 proxy requires authentication that BSD nc cannot negotiate, breaking SSH git operations
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report
- [x] I am using the latest version of Claude Code
What's Wrong?
When sandbox.enabled: true is set (via managed settings), Claude Code injects GIT_SSH_COMMAND into the shell to route SSH traffic through its SOCKS5 proxy:
GIT_SSH_COMMAND=ssh -o ControlMaster=no -o ControlPath=none -o ProxyCommand='nc -X 5 -x localhost:<PORT> %h %p'
The sandbox's SOCKS5 proxy requires authentication, but BSD netcat (/usr/bin/nc on macOS) only supports unauthenticated SOCKS5. No credentials are provided in the injected GIT_SSH_COMMAND. The authentication negotiation fails and every SSH git operation (git pull, git push, git fetch) fails.
What Should Happen?
SSH git operations should succeed through the sandbox proxy. Either the proxy should not require SOCKS5 authentication, or credentials should be embedded in the injected GIT_SSH_COMMAND.
Error Messages/Logs
nc: authentication method negotiation failed
Connection closed by UNKNOWN port 65535
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
Steps to Reproduce
- Enable sandbox via managed settings (
sandbox.enabled: true) - Open Claude Code
- Run
git pullon any repo with an SSH remote (git@github.com:org/repo.git) - Observe the error above
To confirm the injected proxy is the cause:
# Inside a Claude Code bash session:
echo $GIT_SSH_COMMAND
# Shows: ssh ... -o ProxyCommand='nc -X 5 -x localhost:PORT %h %p'
# Workaround that confirms root cause:
env -u GIT_SSH_COMMAND git pull # succeeds
Claude Model
Not applicable (sandbox/tooling bug)
Is this a regression?
Yes — previously worked, broke with a recent sandbox update
Claude Code Version
2.1.190
Platform
Anthropic API
Operating System
macOS
Terminal
iTerm2
Additional Information
/usr/bin/nc on macOS does support SOCKS5 (-X 5) but only without authentication — there are no flags for SOCKS5 credentials. The proxy is requiring an auth method nc cannot satisfy.
Workaround: export GIT_SSH_COMMAND="" before launching Claude Code bypasses the proxy injection.
Showing cached comments. Read the full discussion on GitHub ↗
3 Comments
I think this is an issue that exists in 2.1.186 and higher. I am still seeing it in 2.1.191.
The authentication token is injected into
HTTP_PROXY,ALL_PROXYbut it is not set intoGIT_SSH_COMMAND(and probably doesn't get supported as pointed out in the issue above).The root cause is in
sandbox-utils.tsgenerateProxyEnvVars(). On macOS,GIT_SSH_COMMANDis set unconditionally withnc -X 5, even whenproxyAuthTokenis set:The comment documents the known incompatibility but the code still sets the broken value. This regressed when PR #310 (merged June 15) added proxy authentication. The Linux path handles auth correctly via
socat --proxyauth; the macOS path does not.The simplest fix would be to skip
GIT_SSH_COMMANDon macOS whenproxyAuthTokenis set:Workaround: Add a SessionStart hook to override the injected variable via
CLAUDE_ENV_FILE:I tried the workaround suggested by @cblecker , but it did not work for me. ~Instead, I found I needed to unset the env var:~ Actually, this is also not a viable workaround.