Problem
Go binaries (e.g., gh CLI) cannot make HTTPS connections inside the Claude Code macOS sandbox. TLS certificate verification fails with:
tls: failed to verify certificate: x509: OSStatus -26276
This prevents gh issue list, gh api, and all other gh commands from working.
Root Cause
The Claude Code sandbox on macOS blocks access to the Security framework (used by Go's crypto/x509 package with cgo for TLS certificate verification). This is an OS-level sandbox restriction that cannot be bypassed through:
excludedCommands in settings.json — the sandbox applies to the entire process tree
SSL_CERT_FILE env var — Go with cgo on macOS ignores this, preferring Security framework
GODEBUG=x509usefallbackroots=1 — doesn't trigger fallback for this failure mode
What Works vs. What Doesn't
| Command |
TLS Backend |
Works in Sandbox? |
curl |
SecureTransport / LibreSSL |
Yes |
python3 urllib |
OpenSSL |
Yes |
gh (Go binary) |
Security framework via cgo |
No |
| Any Go binary with cgo TLS |
Security framework via cgo |
No |
Current Workaround
The Claude wrapper script (setup-claude-sandbox.yml) exports GH_TOKEN so auth works without keychain access, but TLS remains broken. Using curl with GH_TOKEN header works as a fallback:
curl -s -H "Authorization: bearer \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" https://api.github.com/user
Potential Solutions
- Python HTTPS proxy — Start a lightweight Python proxy in the wrapper that Go binaries route through (Python uses OpenSSL, not Security framework)
- gh wrapper using curl — Replace
gh with a shell script that delegates common subcommands to curl + jq
- Compile gh with CGO_ENABLED=0 — Forces pure-Go TLS which respects
SSL_CERT_FILE (but may break other things)
- Upstream fix in Claude Code — Allow Security framework Mach services in the sandbox profile
Reproduction
- Start Claude Code with sandbox enabled on macOS
- Run:
gh auth status → fails with keychain error
- Run:
gh api user → fails with x509 OSStatus -26276
- Run:
curl -s https://api.github.com/zen → works
- Run with
dangerouslyDisableSandbox: true → works
Environment
- macOS (Apple Silicon)
- Claude Code sandbox enabled
- gh CLI installed via Homebrew
Problem
Go binaries (e.g.,
ghCLI) cannot make HTTPS connections inside the Claude Code macOS sandbox. TLS certificate verification fails with:This prevents
gh issue list,gh api, and all otherghcommands from working.Root Cause
The Claude Code sandbox on macOS blocks access to the Security framework (used by Go's
crypto/x509package with cgo for TLS certificate verification). This is an OS-level sandbox restriction that cannot be bypassed through:excludedCommandsinsettings.json— the sandbox applies to the entire process treeSSL_CERT_FILEenv var — Go with cgo on macOS ignores this, preferring Security frameworkGODEBUG=x509usefallbackroots=1— doesn't trigger fallback for this failure modeWhat Works vs. What Doesn't
curlpython3 urllibgh(Go binary)Current Workaround
The Claude wrapper script (
setup-claude-sandbox.yml) exportsGH_TOKENso auth works without keychain access, but TLS remains broken. UsingcurlwithGH_TOKENheader works as a fallback:curl -s -H "Authorization: bearer \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" https://api.github.com/userPotential Solutions
ghwith a shell script that delegates common subcommands tocurl+jqSSL_CERT_FILE(but may break other things)Reproduction
gh auth status→ fails with keychain errorgh api user→ fails with x509 OSStatus -26276curl -s https://api.github.com/zen→ worksdangerouslyDisableSandbox: true→ worksEnvironment