Dev.to Security 🔐 Cybersecurity 👁 2 📖 8 min read

Bot-bottle: The Sandbox Your AI Agents Actually Need

The Credential Leak Nobody Talks About In 2026, according to McKinsey's State of AI 2024 report, 72% of organizations now use AI in at least one business function, up from 50% in previous years. Most of those organizat

The Credential Leak Nobody Talks About

In 2026, according to McKinsey's State of AI 2024 report, 72% of organizations now use AI in at least one business function, up from 50% in previous years. Most of those organizations are running coding assistants or autonomous pipelines directly on developer machines, often on the same filesystem that holds AWS credentials, database connection strings, and private keys. The question isn't whether an AI coding system can read ~/.aws/credentials. It can. The question is whether anything stops it from sending that file somewhere.

That gap is what bot-bottle addresses. It's an open-source runtime environment that wraps AI coding systems inside VM-level isolation, enforces Data Loss Prevention rules before any output leaves the sandbox, and gives operators a remote kill switch. The project is not a firewall bolt-on or a prompt-injection filter. It's a full containment layer designed for the specific threat model of an LLM that has shell access.

I've spent time thinking about this problem from the automation side. When we built input parsers for our Meeting Prep pipeline, we discovered how quickly an assumption about data format becomes a silent failure. The pipeline accepts events from three sources: direct webhook calls, Google Calendar API responses, and ITP test fixtures. Each source uses different field names for the same data. Webhooks send event_id and event_title; Calendar sends id and summary; test fixtures send either, depending on who wrote them. Our first version used a bypass flag to detect the format. It failed immediately because test data came through without the flag set. We fixed it by checking for distinguishing fields: if event_id exists, it's webhook format; if summary exists, it's Calendar format. No flags, no assumptions. The lesson transfers directly to agent security: you cannot rely on the system to announce what it's doing. You have to inspect the output itself.

Why Existing Approaches Fall Short

The standard response to agent security is prompt engineering. Add a system message that says "do not exfiltrate credentials." This works until it doesn't, and the failure mode is invisible. A sufficiently complex task can cause a reasoning model to rationalize credential access as a necessary step toward the goal. Prompt-level constraints have no enforcement mechanism outside the model's own inference process.

Container isolation is the next step most teams reach for. Docker gives you filesystem namespacing and network control, but it shares the host kernel. A kernel exploit, a misconfigured volume mount, or a --privileged flag added during debugging collapses the boundary entirely. We've documented the pattern of these incremental security failures in our 27 days of AI agent chaos in production post, where the most damaging incidents weren't dramatic breakdowns but quiet permission creep.

VM-level isolation is the meaningful step up. A hypervisor boundary means the guest OS cannot reach host memory, host filesystems, or host network interfaces without an explicit bridge. Bot-bottle uses this as its foundation, not as an optional hardening step.

How the Architecture Works

Bot-bottle runs the AI coding system inside a virtual machine. The host exposes only a narrow API surface to the guest: a task queue for receiving instructions and an output channel for returning results. The guest has no direct path to the host filesystem. If the LLM inside the VM decides to read /etc/passwd or enumerate environment variables, it reads the VM's environment, not yours.

The DLP layer sits at the output channel. Before any text, file, or API call leaves the VM, the system evaluates it against a policy set. Those policies are written in plaintext, not in a domain-specific language or a YAML schema that requires a security engineer to interpret. A policy might say: "block any output containing a string matching the pattern of an AWS access key." The plaintext format matters because it means a developer, a tech lead, or a compliance officer can read and modify the rules without translating between security concepts and configuration syntax.

The remote control layer gives operators the ability to pause, inspect, or terminate a running session from outside the VM. This is the piece that most sandboxing tools omit. Isolation without observability means you can contain a problem but you can't diagnose it. Bot-bottle's remote control surface lets you freeze execution mid-task, examine what the system was about to do, and decide whether to continue or abort. For teams running long-horizon coding tasks overnight, this is the difference between a recoverable incident and a discovered breach.

The model-agnostic design is a deliberate architectural choice. Bot-bottle doesn't care whether you're running a reasoning model from Anthropic, an open-weight model on local hardware, or a fine-tuned classification model. The containment layer wraps the execution environment, not the model API. This means you can swap the underlying LLM without rebuilding your security posture, which matters as the toolchain continues to shift. The technical debt implications of AI-generated code compound quickly when your security assumptions are baked into a specific model's behavior rather than the infrastructure around it.

Implementation Considerations

The VM overhead is real. Spinning up a full virtual machine for each coding session adds latency that a container-based approach doesn't. For interactive use cases where a developer expects sub-second responses, this tradeoff is noticeable. Bot-bottle is better suited to batch tasks, overnight runs, and CI pipeline integrations where the security guarantee justifies the startup cost. If you need low-latency interactive coding assistance and your threat model is low, a container with tight network egress rules may be the right call. Don't use VM isolation as a performance tax on workflows that don't need it.

Policy authoring requires discipline. Plaintext policies are readable, but they're also easy to write incorrectly. A policy that blocks "AWS" as a string will catch credential patterns but will also block any output that mentions AWS documentation, error messages, or service names. The flexibility that makes plaintext policies accessible also makes them easy to misconfigure. Teams adopting bot-bottle should treat policy files as code: version-controlled, reviewed, and tested against known-bad outputs before deployment.

The remote control surface introduces its own attack vector. If the control API is exposed on a network interface without authentication, an attacker who reaches that interface can terminate or manipulate running sessions. The project's documentation covers this, but it's the kind of detail that gets skipped during a fast deployment. Lock the control API to localhost or a private network segment before you run anything sensitive.

Integration with existing automation infrastructure is worth thinking through carefully. If you're running n8n pipelines that call out to AI coding systems as part of a larger orchestration chain, bot-bottle fits as a wrapper around the execution node rather than a replacement for it. The pipeline triggers the task, the task runs inside the VM, and the output passes through DLP before returning to the pipeline. This pattern keeps your automation logic outside the sandbox while containing the part that actually has shell access. For teams building these kinds of hybrid pipelines, our full blueprint catalog shows how we structure the handoff between orchestration layers and execution environments.

The Trilemma: Power, Isolation, Auditability

Most agent infrastructure optimizes for one of these three properties. Fully capable systems with direct filesystem and network access are powerful but not isolated. Heavily sandboxed systems are isolated but lose the ability to do useful work. Systems with detailed logging are auditable but often sacrifice either power or isolation to make the audit trail possible.

Bot-bottle's claim is that you can hold all three simultaneously. The VM gives you isolation without crippling capability, because the system inside the VM still has a full OS and can run arbitrary code. The DLP layer gives you auditability at the output boundary, where it matters most. The remote control surface gives you the ability to act on what the audit reveals.

Whether that claim holds in practice depends on your policy quality and your operational discipline. The architecture is sound. The execution is yours.

This is also where the comparison to alternative approaches gets concrete. Approaches like open-source versus proprietary AI tooling often frame the tradeoff as capability versus control. Bot-bottle reframes it: the question isn't whether to use a powerful system, but where to put the enforcement boundary. Putting it at the VM output channel rather than inside the model's prompt is a fundamentally different security posture, and it's one that survives model upgrades, prompt injection attempts, and the inevitable cases where the LLM does something unexpected.

What We'd Do Differently

Start with a threat model, not a tool. Before deploying bot-bottle or any sandboxing layer, write down exactly what you're afraid of. Credential exfiltration? Lateral movement to other services? Accidental deletion of production files? The answer changes which controls matter most. We've seen teams spend weeks configuring VM isolation for a use case where the actual risk was an LLM making unauthorized API calls, which a simple egress allowlist would have addressed in an hour.

Build policy testing into your CI pipeline from day one. The temptation is to write policies manually and test them by running the system and seeing what happens. That approach finds the obvious failures and misses the subtle ones. A better pattern: maintain a library of known-bad outputs (credential strings, internal IP addresses, private key patterns) and run every policy change against that library automatically. We'd apply the same field-detection logic we use in our input parsers: check for the distinguishing characteristic, don't assume the format.

Plan for the policy gap between what you block and what you allow. DLP policies are good at blocking known-bad patterns. They're poor at catching novel exfiltration methods, like an LLM encoding credentials in a base64 string inside a comment, or embedding them in a variable name. The next frontier for bot-bottle and tools like it is behavioral analysis at the output layer, not just pattern matching. If you're evaluating this for a high-stakes environment in 2026, factor in that the policy language will need to evolve as the threat model does.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.