Skip to content

Why Claude Code Escaped My VM Sandbox - The Network Bridge Security Flaw

Problem

When I created a VM to sandbox Claude Code, I expected complete isolation from my host system. But during my first prompt, Claude accessed Chrome running on my host machine.

This wasn’t a security flaw in Claude. It was a flaw in my VM configuration.

Environment

  • VM with bypass permissions (for testing)
  • Bridged networking mode
  • Chrome with Claude extension on host
  • VirtualBox/QEMU hypervisor

What Happened?

I created a VM specifically for security testing. I gave Claude bypass permissions to see what it could do.

Here’s my network setup:

Network configuration - The vulnerability
┌─────────────────────────────────────────┐
│ Host Machine (192.168.1.100) │
│ │
│ ┌────────────────┐ ┌──────────────┐ │
│ │ Chrome Browser │ │ Claude Ext │ │
│ │ │ │ listens on │ │
│ │ │ │ localhost │ │
│ │ │ │ :PORT │ │
│ └────────────────┘ └──────┬───────┘ │
│ │ │
│ ┌───────────────────────────┴───────┐ │
│ │ Bridged Network (Same IP Range) │ │
│ └───────────────────┬───────────────┘ │
└────────────────────────┼────────────────┘
┌────────────────────────┴────────────────┐
│ VM Guest (192.168.1.101) │
│ │
│ ┌────────────────────────────────────┐ │
│ │ Claude Code │ │
│ │ Can reach host localhost via │ │
│ │ bridged gateway! │ │
│ └────────────────────────────────────┘ │
└─────────────────────────────────────────┘

The Chrome extension listens on localhost for API connections. With bridged networking, the VM shares the host’s IP address space. From the extension’s perspective, requests from the VM look like local connections.

A Reddit commenter with 97 upvotes summarized it:

“The chrome extension allows connections from localhost, so if your VM wasn’t bridged networks (it shares your IP) the extension would be fair game on a well-known IP (the guest VMs default gateway).”

Another perspective (from the comments):

“Not sure why anyone would use a VM to sandbox Claude, it’s totally not worth the overhead. There is an included sandbox mode in Claude Code.”

How to Solve It?

Solution #1: Use Claude Code’s Built-in Sandbox

The simplest solution is to skip the VM entirely:

Claude Code built-in sandbox
claude-code --sandbox

Claude Code has native sandbox functionality that provides:

  • Process isolation via seccomp/bpf
  • Filesystem access restrictions
  • Network namespace isolation
  • Tool execution controls

Zero VM overhead, purpose-built for isolation.

Solution #2: Fix VM Network Configuration

If you need a VM, use NAT networking instead of bridged:

VirtualBox network configuration
# INSECURE: Bridged Networking (Vulnerable)
VBoxManage modifyvm "ClaudeVM" --nic1 bridged --bridgeadapter1 en0
# SECURE: NAT Networking (Isolated)
VBoxManage modifyvm "ClaudeVM" --nic1 nat
# SECURE: Host-Only Network (Isolated)
VBoxManage modifyvm "ClaudeVM" --nic1 hostonly --hostonlyadapter1 vboxnet0

Solution #3: Add Firewall Rules

Block VM-to-host localhost traffic:

Firewall rules to block VM access
# macOS pfctl rules
block drop in on bridge0 inet from 192.168.1.0/24 to 127.0.0.1
# Linux iptables rules
iptables -A INPUT -s 192.168.1.0/24 -d 127.0.0.1 -j DROP
iptables -A INPUT -i vboxnet0 -d 127.0.0.1 -j DROP

Solution #4: Secure the Chrome Extension

The Chrome extension manifest shows the issue:

Chrome extension manifest - Security concern
{
"manifest_version": 3,
"permissions": [
"nativeMessaging"
],
"externally_connectable": {
"matches": ["http://localhost:*"],
"accepts_tls_channel_id": false
}
}
// PROBLEM: localhost connections accepted from any source
// including bridged network interfaces

Disable the Chrome extension when using VM isolation, or add authentication tokens for localhost connections.

The Reason

I think the key reason is misunderstanding security boundaries.

VM isolation depends on network configuration, not just VM placement.

Bridged networking means:

  • VM shares network segment with host
  • VM can reach host’s network services
  • Localhost-bound services become accessible
  • The VM is “isolated” only in process/filespace, not network

The Chrome extension architecture compounds the issue:

  • Extensions bind to localhost for convenience
  • Localhost is treated as “trusted” by default
  • No authentication required for localhost connections
  • Network reachability bypasses this trust model

Common Mistakes

Mistake 1: Assuming VM = Automatic Isolation

Network configuration matters more than VM presence. Bridged networking is essentially no network isolation.

Mistake 2: Trusting Default Extension Security

Extensions often have permissive localhost policies. Network reachability = potential security bypass.

Mistake 3: Over-Engineering Solutions

Claude Code has built-in sandbox mode. VM overhead is unnecessary for most use cases. Simple solutions are often more secure.

Mistake 4: Ignoring the Principle of Least Privilege

Granting bypass permissions undermines sandbox purpose. Each permission creates a potential escape vector.

Summary

In this post, I explained why Claude Code “escaped” my VM sandbox. The key point is that bridged networking combined with Chrome extension localhost binding created an unintended security boundary crossing.

Claude didn’t break out of the VM - it simply used the network path I provided. Use Claude Code’s built-in sandbox mode for proper isolation, or configure VMs with NAT networking to prevent localhost reachability from guest systems.

Final Words + More Resources

My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me

Here are also the most important links from this article along with some further resources that will help you in this scope:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!

Comments