Network access is the setting that turns a mistake in an agent's run from contained to serious. A command that misbehaves with no network can only damage the machine it is on. With open access, it can send what it can read to anywhere.
Most of what an agent does while working does not need the internet at all. Running unit tests, a linter, a type checker or a formatter works on local files. This post is about sorting the work into groups so the network is off where it can be, narrow where it must be, and a person decides the rest. The Sandscale details come from the CLI (1.4.1) help.
Three groups
Group 1: no network. Anything that works on files already on the machine. Unit tests that do not call out. Lint, format and type checks. Running the compiler. Reading logs. For most repositories this is the largest group by the number of commands, and it is the loop: edit, test, read the failure.
Group 2: a short allowlist. Things that need to fetch from a known place. Installing dependencies from a package registry. Cloning the repository. Downloading a toolchain. The access can be limited to the specific hosts, not the whole internet.
Group 3: needs a person. Anything that talks to a service the team did not name in advance. A test that calls a third-party API. An agent that wants to curl a URL it found in an issue. These should not be granted by the agent's own say-so.
What the CLI offers
Sandscale sandboxes start with the network off. The CLI's help describes the options: --network none is the default, and allowlist reaches only your organization's egress allowlist and the package registry presets, where your organization's policy and plan allow it:
sandscale sandbox create --template-id builtin:node --network none sandscale sandbox create --template-id builtin:node --network allowlist What a given account may choose depends on its plan and its organization's policy. Check sandscale sandbox launch-options for what you may start. A workspace is a longer-lived machine for an agent. Its network access follows your plan and your organization's policy, and the agent itself needs to reach its model provider, so a workspace is not the place for "no network at all". The sandbox is.
That points at a pattern. The agent works on its own machine, with the access its work needs. When it wants to run code it has not reviewed, it sends that code to a sandbox with the network off, and reads the result. For routing commands there automatically, see Claude Code hooks that route Bash to a sandbox.
Finding out which group a task is in
Do not guess. Run the task once with the network off, and read what fails:
- Start a sandbox with
--network none, send the project in, and run the test command. - If it passes, the task is Group 1. Put it in the loop.
- If it fails, read the first error, not the last. Name resolution failures, connection refused and timeouts on a hostname are the signs of a network call. The error names the host.
- Decide about that host as a team. Is it a package registry? Group 2: add it to the allowlist. Is it a test calling a real third-party service? Mock it, so the test is Group 1 after all. Is it something you do not recognize? Treat it as a finding, not a configuration problem.
An agent that hits a network failure will try to fix the test, or to open the network itself. Tell it not to:
## Network - Run tests and checks with no network. If one fails because it cannot reach a host, stop and report the hostname. Do not retry with another approach, add a mirror, or change the test to avoid the call. - Do not run `curl`, `wget` or `pip`/`npm` installs outside the documented setup steps. - Do not ask for more network access in a PR. Name the host and the reason in the PR description. Installing, then running offline
Group 2 and Group 1 often alternate on the same task: dependencies are fetched once, then the tests do not need the network. Where the package tool supports it, use that. Two examples from those tools' own options: npm ci installs from the lockfile and does not change it (see npm ci for coding agents), and pip can be told to use only hashed, pinned requirements (see Python installs for coding agents). Both make the install step the one place the machine reaches out, and make it a step you can name.
The agent's own machine keeps its disk between tasks, so a warmed dependency cache is still there when the next task starts.
DNS is part of the network
An allowlist that permits only some hosts has to cover name resolution too, or data can leave inside DNS lookups. If you write your own allowlist, read our post on DNS exfiltration, which explains how data leaves that way and how to test for it.
A short policy for the team
- Tests, lint and type checks run with no network. A test that needs the network is a bug to fix or a mock to write.
- Installing dependencies uses the allowlist for the package registry and nothing more.
- A new host is a decision for a person, recorded with a reason.
- The agent never changes its own network settings.
If you have written a policy for your coding agents, the third item belongs in its "needs a person" list. Every machine start and every approval is recorded in the audit log, which is how you check afterwards that the policy was followed.
Originally published on the Sandscale blog.