All posts

Agent security

Is a Dev Container Enough to Sandbox an AI Agent?

Inspect dev-container mounts, privileges, credentials and network boundaries. Test the actual agent route instead of relying on a sandbox label.

Harden cover: Dev Container Limits. Code and a laptop sit inside a dashed workspace boundary with a separate host identity. Conceptual editorial artwork; no measured result is depicted.

Executive summary

A dev container is useful isolation only to the extent that its mounts, identity, privileges, credentials, network, and host interfaces constrain the agent's actual workflow. The label alone is insufficient. Review what the container can affect and test those boundaries with harmless fixtures. Our worked review examines a repository mount and a staging credential. It does not claim a universal container escape, a benchmark result, or protection from every container configuration.

Start with what crosses into the container

List the repository, home-directory paths, environment variables, secrets, sockets, and devices exposed to the workspace. Include configuration added by development tooling rather than inspecting only the base image.

An agent can act on resources available through those interfaces. If the container has a host directory mounted read-write, the intended boundary includes that directory. If a credential reaches a remote production service, local filesystem isolation does not remove the credential's remote authority.

Record the task before judging the setup. A unit-test fix may require repository writes and package access. It does not automatically require a full home-directory mount, deployment tokens, or control of the host's container daemon.

Review the resolved configuration after development tooling starts the workspace. Defaults and inherited settings can differ from the checked-in template. Preserve that effective state so the acceptance record describes the environment the agent actually used.

Keep the review reproducible: container image reference, runtime configuration, mounts, user, network settings, credential source, and agent version. A developer's description of the environment can guide the investigation, but the configured execution path is the relevant evidence.

Review bind mounts as host access

Docker's bind-mount documentation explains that bind mounts expose host paths and are writable by default unless configured otherwise. Review each mount's source, destination, access mode, and purpose.

For the worked example, a repository mount permits the agent to edit the task's source files. An unrelated synthetic secrets directory should remain unavailable or appropriately constrained. Use controlled fixtures to distinguish the two without exposing real credentials.

A read-only mount limits writes through that mount; it does not make the contents non-sensitive. If the agent can read a private file and reach an external recipient, the disclosure question remains. Review read authority and transfer authority separately.

Check generated files and ownership on the host after the exercise. The useful result is an observed boundary, not merely a configuration flag. If the runtime or development tool changes the mount arrangement, repeat the affected cases.

Inspect identity and privileged interfaces

Docker's security documentation describes relevant daemon and container security considerations. Apply it to the actual runtime and operating system. Do not treat behavior on one development platform as evidence for every host architecture.

Review the container user, Linux capabilities where applicable, privileged mode, and access to host interfaces. An exposed daemon socket or broad privilege can materially change the environment's authority. Document why any such interface is necessary and who approves it.

Avoid turning this review into a live escape exercise on a developer machine. Inspect configuration and use harmless operations on disposable resources. A test should establish the intended access boundary without risking the host or unrelated workloads.

If the required workflow depends on a powerful host interface, record that residual authority. The team may choose a different environment or keep consequential operations outside the agent's assignment. Calling the workspace “sandboxed” should not conceal that decision.

Follow credentials beyond the local boundary

Assume the container receives a staging API token. Record its audience, permitted resources, operations, expiry, and revocation owner. Verify which identity the remote service actually sees when the agent calls it.

The prohibited variation is a request aimed at production or an unrelated recipient. Test the boundary in an approved disposable setup. A local process restriction and a remote authorization failure are different outcomes, and both need accurate attribution.

Minimize environment inheritance. A workspace can acquire credentials through shell setup, development extensions, helper commands, or mounted configuration. Review the actual source instead of assuming that only explicitly declared variables are available.

Plan for cleanup and active sessions. Removing a variable from the next container start does not necessarily revoke a token already obtained by an existing process. Use the identity system's revocation mechanisms and the organization's response process where exposure is suspected.

Test the engineering task and its unsafe variation

Use a repository fixture, an unrelated synthetic file, a controlled network recipient, and a non-production service identity. Define expected results before execution: permitted edits complete, unrelated file access is constrained, and unapproved remote effects remain outside scope.

Inspect actual files, requests, and recipient-side receipts where available. A process returning an error is not enough to identify which control acted. Preserve the configuration and evidence so another reviewer can distinguish the security boundary from a broken build or unavailable endpoint.

Include agent-specific routes. A terminal inside the container may be constrained while an IDE tool runs elsewhere. A remote MCP server may use its own identity. Record those paths separately instead of assuming the container encloses every operation presented in one chat interface.

Repeat relevant cases after changes to images, mounts, tooling, credentials, or agent permissions. Avoid an open-ended testing quota; recheck the boundaries affected by the change and unresolved gaps that still matter to the task.

Add action context to isolation

Isolation constrains what a process can reach. A permitted resource can still be used for the wrong task, recipient, or environment. Review the proposed action as well as the execution boundary.

Harden evaluates supported pending agent calls against relevant task context and policy. Verify the configured integration in the environment where the call occurs. A local installation does not establish coverage of every container, remote tool, or independent process.

Our sandbox guide provides the broader layering checklist. Bring the environment map and a harmless allowed/prohibited pair to Control. Book a Call if the workflow crosses host, container, and remote-service boundaries that need separate evaluation.

FAQs

Does a dev container make host files inaccessible?

Only the configured boundary can answer that. Review mounts, sockets, devices, and helper processes. A development tool may intentionally expose host resources. Verify the actual access using harmless fixtures, and keep sensitive host material out of the workspace unless the task requires it.

Is a read-only mount safe for secrets?

Read-only limits modification through the mount. It does not prevent a permitted reader from learning the contents or proposing a transfer. Review whether the agent needs the data, which recipients are reachable, and what controls govern subsequent use.

Can a container prevent production API calls?

It can contribute network and environment constraints when configured accordingly. Remote authority also depends on credentials and the service's authorization. Verify the actual destination and identity. A staging prompt does not remove a production token already available inside the environment.

Should we run the agent as root?

Choose the least authority required by the development workflow and review platform-specific behavior. A container user label alone does not describe capabilities, host mounts, or privileged interfaces. Record necessary exceptions and test the resulting boundary on disposable resources.

Is another runtime check redundant inside a container?

It depends on the required outcome and verified coverage. Isolation limits reach; supported action checks can evaluate proposed use of available authority against the task. Preserve both responsibilities and test the actual integration rather than assuming either layer establishes universal protection.