Rightshold™ Sign up

Answers · agent safety

How do I restrict which sites my AI coding agent can reach on the network?

Last updated

TL;DR: Start from default-deny and add an allowlist of the hosts the task actually needs (your package registries, your git host, your own APIs). An agent's shell commands otherwise run with the same network reach as the person or machine that launched them, including internal hosts and cloud metadata endpoints. The three big coding agents ship controls for this. Claude Code's Bash sandbox (off by default) gives shell commands no direct route out: traffic goes through a local proxy that checks each host against allowedDomains, which start empty, and strictAllowlist or managed allowManagedDomainsOnly turn prompts into refusals. Codex CLI's default workspace-write sandbox has network access off; if you turn it on, enable its network_proxy feature with domain allow rules, or outbound access is unrestricted. GitHub Copilot's cloud agent runs behind a firewall by default with a recommended allowlist of package registries, and owners can add custom rules. Know the gaps: each vendor says its filter covers commands the agent runs, not MCP servers, hooks or other helper processes, and filters that only check hostnames can be bypassed (Claude Code's docs name domain fronting). For a hard boundary, also run the whole agent in a container or VM with its own egress firewall.

What should I check, step by step?

1. List the hosts the task needs (package registry, git host, your API, model provider) and allow only those; leave broad domains such as all of github.com off unless the task needs them, because an allowed domain is also a place data can be sent.

  1. Claude Code: set sandbox.enabled, add network.allowedDomains, and set strictAllowlist (user, managed or --settings) so unlisted hosts are refused instead of prompted. Set allowUnsandboxedCommands to false and failIfUnavailable to true so commands can't fall back to running outside the sandbox.
  2. Claude Code for a team: put the sandbox keys in managed settings with allowManagedDomainsOnly, so only the managed allowlist counts and a repository's .claude/settings.json can't widen it.
  3. Codex CLI: keep the default workspace-write sandbox with network_access off. If a task needs the network, turn on network_access together with features.network_proxy and domain allow rules; without the proxy, enabled network access is unrestricted.
  4. GitHub Copilot cloud agent: keep the firewall enabled, review the recommended allowlist, add only the custom hosts you need, and as an organization owner consider turning off repository custom rules.
  5. Block cloud metadata and private ranges: Claude Code's sandbox proxy refuses hostnames that resolve only to local addresses such as 169.254.169.254, and Codex's proxy blocks loopback, link-local and private destinations by default; confirm the same for any custom setup.
  6. Cover what the agent's filter doesn't: MCP servers, hooks and other helper processes run outside these filters, so give them their own network limits or run the whole agent in a container or VM with an egress firewall.
  7. Test it: from inside the agent, try a host that isn't allowed (Claude Code's docs suggest curl --noproxy '*' https://example.com) and confirm it fails, and watch the blocked-host warnings the tools report.

What each agent filters, and what it doesn't

Claude Code: the sandbox covers Bash, PowerShell and Monitor commands and the processes they start. Its docs say the file and web tools, command hooks, local MCP servers and other helper processes run outside it, and WebFetch follows permission rules instead of allowedDomains. On Linux and WSL2 sandboxed commands run in a separate network namespace; on macOS Seatbelt blocks connections other than the one to the sandbox proxy.

Why hostname allowlists are not the whole answer

The built-in proxies decide from the hostname the client asks for. Claude Code's docs warn that because its proxy does not inspect TLS by default, code inside the sandbox could use domain fronting or similar techniques to reach hosts outside the allowlist, and that allowing broad domains such as github.com creates paths for data exfiltration.

How do I ask Rightshold about this (free, no key)?

Add the MCP server https://www.rightshold.com/mcp to Claude, Cursor, ChatGPT, Grok or VS Code, then ask: “Before I allow my coding agent to reach this MCP server's host, is it a listed server, what tools does it expose, and have its tool definitions changed?”

One-click setup

{
  "tool": "precall_check",
  "arguments": {
    "url": "<the MCP server's https URL>"
  }
}

Rightshold does not run or configure your agent's sandbox, firewall or proxy, and does not see your network traffic. It checks MCP servers you ask about. Not legal advice.

What are the sources?

Related

Not legal advice. JSON · Markdown · All answers

Get a free API key in one call

No card and no email needed. 100 free credits; the license and policy checks stay free without a key.

curl -s -X POST https://www.rightshold.com/v1/accounts/signup -H "Content-Type: application/json" -d '{"accept_terms":true}'
export RIGHTSHOLD_API_KEY=rs_...   # the api_key from the reply (shown once)
curl -s https://www.rightshold.com/v1/licenses/check -H "Authorization: Bearer $RIGHTSHOLD_API_KEY" \
  -H "Content-Type: application/json" -d '{"license":"MIT","intended_use":{"commercial_use":true}}'