Skip to content

Go binaries fail TLS in Claude Code macOS sandbox (Security framework blocked) #149

@jaeyeom

Description

@jaeyeom

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

  1. Python HTTPS proxy — Start a lightweight Python proxy in the wrapper that Go binaries route through (Python uses OpenSSL, not Security framework)
  2. gh wrapper using curl — Replace gh with a shell script that delegates common subcommands to curl + jq
  3. Compile gh with CGO_ENABLED=0 — Forces pure-Go TLS which respects SSL_CERT_FILE (but may break other things)
  4. Upstream fix in Claude Code — Allow Security framework Mach services in the sandbox profile

Reproduction

  1. Start Claude Code with sandbox enabled on macOS
  2. Run: gh auth status → fails with keychain error
  3. Run: gh api user → fails with x509 OSStatus -26276
  4. Run: curl -s https://api.github.com/zen → works
  5. Run with dangerouslyDisableSandbox: true → works

Environment

  • macOS (Apple Silicon)
  • Claude Code sandbox enabled
  • gh CLI installed via Homebrew

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions