Sandbox blocks Go TLS cert verification on macOS (gh CLI fails)

Status Closed — duplicate
Maintainer reply None cached
Activity 6 comments · opened Feb 28, 2026 · closed Aug 19, 2026

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

  1. Add github.com and api.github.com to sandbox.network.allowedDomains
  2. Run gh api /rate_limit in sandbox → TLS error
  3. Run curl -s https://api.github.com/rate_limit in sandbox → works (200)
  4. Run gh api /rate_limit with dangerouslyDisableSandbox: 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.

View original on GitHub ↗

5 Comments

github-actions[bot] · 6 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/23416
  2. https://github.com/anthropics/claude-code/issues/28954
  3. https://github.com/anthropics/claude-code/issues/27966

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

xXMrNidaXx · 6 months ago

Root Cause Confirmation + Workaround

Great analysis on the Security.framework mach service blocking. This affects any Go binary using the default crypto/x509 cgo path on macOS.

Quick Workaround (without full sandbox disable):

You can force Go to use a pure-Go TLS implementation by setting:

export GODEBUG=x509usecgo=0

This bypasses the Security.framework calls entirely. Works for gh and other Go CLIs.

Caveats:

  • Pure-Go verifier uses its own root cert pool, not the macOS keychain
  • May not honor custom enterprise CAs in the system keychain
  • Performance slightly slower for cert chain validation

For gh specifically, you could also try:

GH_DEBUG=1 gh api /rate_limit 2>&1 | grep -i tls

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.SecurityServer
  • com.apple.trustd
  • com.apple.trustd.agent

This is reasonably safe — it only enables cert verification, not keychain write access.

connorbrinton · 5 months ago

@xXMrNidaXx did you verify that the export GODEBUG=x509usecgo=0 approach works? I can't find any mention of a x509usecgo parameter anywhere besides this issue and am unable to get gh to work in the sandbox even with the environment variable set.

I've also tried GODEBUG=x509usefallbackroots=1 with no success

TyceHerrman · 5 months ago
danra · 4 months ago

Enable sandbox.enableWeakerNetworkIsolation to fix (see https://github.com/anthropic-experimental/sandbox-runtime/pull/120)

Showing cached comments. Read the full discussion on GitHub ↗