Sandbox blocks Go TLS cert verification on macOS (gh CLI fails)
Summary
Go-based CLI tools (notably gh) fail with TLS certificate verification errors when running inside the Claude Code sandbox on macOS. Tools using libcurl (curl, git) work fine.
Error
Post "https://api.github.com/graphql": tls: failed to verify certificate: x509: OSStatus -26276
Root Cause
Go's crypto/x509 package on macOS uses Security.framework via cgo for certificate verification. This requires mach service calls (likely com.apple.SecurityServer). The Claude Code sandbox appears to block these mach services, causing the cert verification to fail with errSecInternalComponent (OSStatus -26276).
Reproduction
- Add
github.comandapi.github.comtosandbox.network.allowedDomains - Run
gh api /rate_limitin sandbox → TLS error - Run
curl -s https://api.github.com/rate_limitin sandbox → works (200) - Run
gh api /rate_limitwithdangerouslyDisableSandbox: true→ works
Impact
Any Go binary that uses cgo TLS (default on macOS) will fail in the sandbox. gh is the most common case. Workaround is dangerouslyDisableSandbox: true per command, but this bypasses all sandbox restrictions rather than just the mach service needed for TLS.
Environment
- macOS 15.3 (Darwin 25.2.0)
- Claude Code (latest)
- gh 2.67.0
Suggested Fix
Allow mach-lookup for Security.framework services in the sandbox profile, or provide a per-tool sandbox override in settings.
Showing cached comments. Read the full discussion on GitHub ↗
5 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Root Cause Confirmation + Workaround
Great analysis on the Security.framework mach service blocking. This affects any Go binary using the default
crypto/x509cgo path on macOS.Quick Workaround (without full sandbox disable):
You can force Go to use a pure-Go TLS implementation by setting:
This bypasses the Security.framework calls entirely. Works for
ghand other Go CLIs.Caveats:
For
ghspecifically, you could also try:to confirm the failure point.
Potential Fix Scope:
If Anthropic wants to allow Security.framework access, the sandbox profile would need to allow mach-lookup for:
com.apple.SecurityServercom.apple.trustdcom.apple.trustd.agentThis is reasonably safe — it only enables cert verification, not keychain write access.
@xXMrNidaXx did you verify that the
export GODEBUG=x509usecgo=0approach works? I can't find any mention of ax509usecgoparameter anywhere besides this issue and am unable to getghto work in the sandbox even with the environment variable set.I've also tried
GODEBUG=x509usefallbackroots=1with no successPretty sure this is a duplicate of https://github.com/anthropics/claude-code/issues/23416
Enable
sandbox.enableWeakerNetworkIsolationto fix (see https://github.com/anthropic-experimental/sandbox-runtime/pull/120)