Why AI Coding Tools Should Run in a Sandbox by Default

An AI coding agent can edit code, run tools, and inspect files. That makes it useful. It also means the tool’s access deserves the same scrutiny as any other program running with a developer’s permissions.

Not every agent ships with unrestricted filesystem and network access. Products differ, and individual deployments may enable sandboxing, workspace restrictions, or approvals by default. The relevant question is not the product name. It is what the actual process can read, write, execute, and send to another service.

The boundary is a configuration, not a promise

Imagine an agent asked to refactor a module. It may only need one repository and a controlled test environment. If it can also read the user’s home directory, load cloud credentials, contact arbitrary endpoints, and modify unrelated projects, the available privilege exceeds the task.

That is a security-design problem even when the agent behaves as intended. A dependency, script, or tool call can have effects beyond the target module. A compromised repository may contain instructions that try to exploit whatever access the agent has.

A restricted filesystem, approved workspace, explicit tool permissions, and a clear network boundary reduce the potential damage. They do not prove that no data can escape; that requires configuration inspection and testing.

What a sandbox can and cannot enforce

Linux namespaces and tools such as bubblewrap can restrict which filesystem paths a process sees. Containers can give an agent an isolated development environment. Tool approval policies can restrict commands and external actions. Each operates at a different layer.

A mount namespace does not automatically restrict outbound networking. For example, a wrapper that uses a shared network namespace may still allow the process to contact external services. Clearing environment variables reduces accidental credential exposure, but explicitly passing an API key into a sandbox restores that key’s availability to the process. A read-only bind mount of a sensitive directory still exposes its contents for reading.

A tmpfs home directory may isolate and discard temporary files, but it does not independently guarantee that other host paths are inaccessible. An effective wrapper must define its mounts and runtime privileges, then verify the resulting access from inside the environment.

For hosted coding agents, permissions and network policy may be enforced by the provider rather than a local wrapper. Read the actual product documentation, verify the deployment settings, and test with a non-sensitive fixture. A configuration sample is not an audited security control.

What an acceptance test looks like

A useful security test tries to access a harmless sentinel file outside the approved workspace, read a deliberately absent credential variable, modify a forbidden path, and contact a test endpoint that the network policy should deny. It should also confirm the intended code and tests still work.

Record what was tested and under which runtime version. A result from one machine and configuration does not automatically transfer to another. Neither a reassuring CLI banner nor a policy document proves the boundary works.

For regulated or contractual work, there is a further question: where does model input go? A local filesystem sandbox does not settle vendor retention, model-training terms, data residency, audit requirements, or whether a file’s contents will be included in an API request. Those must be assessed separately.

Why the constraints are useful

A narrow boundary helps a team make a precise promise: this agent may work on these files, run these commands, and reach these services. The promise is credible only if tests and logs demonstrate it. An audit trail can support investigation; it cannot retroactively prevent unauthorized access.

The aim is not to turn every programming task into a security ceremony. It is to make a default development environment proportionate to the value of the information at risk. A public toy project and a repository containing proprietary research need different controls.

The better question is not “how much power can we give an agent?” It is “what is the least authority it needs to finish this task and leave evidence we can review?”

That tradeoff is one part of the decision-support and workflow engineering McIntosh Consulting helps teams reason through. The outcome is a proposed and tested boundary, not a guarantee of compliance or client results. Discuss a workflow.

Dr. Vernon McIntosh

Dr. Vernon McIntosh

Independent practice in biotech, data, and AI/ML

Vernon McIntosh writes about hard biology, data systems, and the practical edge of AI in scientific work. If a post raised a question you want to talk through, book a call or reply by email.

Keep in touch

New essays by email

New essays arrive as they publish. Every so often there is a shorter note when something in the work is worth passing along. If you would rather not do email, the same posts go out on the RSS feed.

Your email is used only for these essays. See the privacy notice.

Send Vernon a message

For consulting inquiries or employment opportunities. A valid return email is required. All other fields are optional.

Messages are processed by Web3Forms and emailed to Vernon. Please do not include confidential information. See the privacy notice.

Prefer email? consulting@vernonmcintosh.com