Skip to content

claude-code template: the sandbox firewall allows whole shared CDN IPs, so each allowlisted CDN host likely opens unrelated sites #296

Open

Description

@gatezh

Summary

The sandbox firewall allows the IPv4 addresses each name in allowed-domains.txt resolves to, once, at container start: ipset add allowed-domains "$ip", and outbound traffic is accepted by --match-set allowed-domains dst. Many hosts a Claude Code sandbox needs sit on shared CDN anycast ranges, Cloudflare's especially. Those addresses are shared by many unrelated sites, which the CDN tells apart by hostname (SNI and Host). So an allowed CDN-hosted name probably opens every other site on the same addresses, and the allowlist is much wider than it reads.

In one downstream project, every added host resolves into Cloudflare's ranges:

Host Resolved (getent ahostsv4)
api.cloudflare.com 104.19.192.x
dash.cloudflare.com 104.17.110.184
mcp.cloudflare.com 104.18.24.159
mcp.linear.app 104.18.40.45
mcp.resend.com 104.20.29.242
chatgpt.com 104.18.32.47, 172.64.155.209

Unverified

The probe that would confirm this was blocked in the reporting session. Run it inside the sandbox:

ip=$(getent ahostsv4 mcp.linear.app | awk 'NR==1{print $1}')
# Any other Cloudflare-proxied site, reached through an allowed IP:
curl -sS -o /dev/null -w '%{http_code}\n' --resolve "example-cf-site.com:443:$ip" https://example-cf-site.com/

A response (any HTTP status), rather than a connection timeout, confirms the bypass.

Options

  • Filter by hostname instead of IP: an SNI-aware egress proxy (e.g. a small allowlisting forward proxy with HTTPS_PROXY set for the container), or nftables/iptables string matching on the TLS ClientHello's SNI as a cheaper partial measure.
  • Re-resolve periodically. This doesn't fix the shared-IP problem, but it stops long-lived containers from drifting off rotated CDN IPs.
  • At minimum, document the limitation next to allowed-domains.txt, so projects add only hosts they need. That project now carries the note.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions