Internet Access Control
Controlling internet access is crucial for AI agents and secure code execution. VoidRun provides granular network control at the MicroVM level, allowing you to restrict outbound connections to prevent data exfiltration and protect against malicious sites.Why Network Control Matters
🔒 Data Protection
Prevent AI agents from leaking sensitive data to external servers.
🛡️ Security
Block access to malicious domains and unauthorized endpoints.
📋 Compliance
Meet regulatory requirements for isolated code execution.
Use Cases
| Use Case | Configuration |
|---|---|
| AI Code Execution | Allow only API endpoints needed for the task |
| CI/CD Pipelines | Allow package registries, block everything else |
| Sandbox Testing | Disable all internet access for maximum isolation |
| Data Processing | Allow database connections, block public internet |
Enabling/Disabling Internet Access
Disable Internet Access
Completely disable outbound internet access for maximum security:import { VoidRun } from '@voidrun/sdk';
const vr = new VoidRun({ apiKey: process.env.VR_API_KEY });
// Create sandbox with internet disabled
const sandbox = await vr.createSandbox({
name: 'isolated-sandbox',
cpu: 2,
mem: 2048
});
// TODO: Verify exact method - network config may be via exec or dedicated API
// Disable outbound internet (except DNS)
await sandbox.exec({
command: 'iptables -A OUTPUT -p tcp --dport 80 -j DROP && iptables -A OUTPUT -p tcp --dport 443 -j DROP'
});
// Verify internet is blocked
const result = await sandbox.exec({ command: 'curl -s --connect-timeout 5 https://google.com || echo "Internet blocked"' });
console.log(result.data?.stdout); // "Internet blocked"
from voidrun import VoidRun
import os
vr = VoidRun(api_key=os.environ.get("VR_API_KEY"))
# Create sandbox with internet disabled
sandbox = vr.create_sandbox(
name="isolated-sandbox",
cpu=2,
mem=2048
)
# TODO: Verify exact method - network config may be via exec or dedicated API
# Disable outbound internet (except DNS)
sandbox.exec('iptables -A OUTPUT -p tcp --dport 80 -j DROP && iptables -A OUTPUT -p tcp --dport 443 -j DROP')
# Verify internet is blocked
result = sandbox.exec('curl -s --connect-timeout 5 https://google.com || echo "Internet blocked"')
print(result.data.stdout) # "Internet blocked"
# Create sandbox
voidrun create --name isolated-sandbox --cpu 2 --mem 2048
# Disable outbound internet
voidrun exec <sandbox-id> --command "iptables -A OUTPUT -p tcp --dport 80 -j DROP && iptables -A OUTPUT -p tcp --dport 443 -j DROP"
# Verify internet is blocked
voidrun exec <sandbox-id> --command "curl -s --connect-timeout 5 https://google.com || echo 'Internet blocked'"
# Create sandbox
curl -X POST "https://api.void-run.com/api/sandboxes" \
-H "X-API-Key: $VR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "isolated-sandbox", "cpu": 2, "mem": 2048}'
# Disable outbound internet
curl -X POST "https://api.void-run.com/api/sandboxes/<sandbox-id>/exec" \
-H "X-API-Key: $VR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"command": "iptables -A OUTPUT -p tcp --dport 80 -j DROP && iptables -A OUTPUT -p tcp --dport 443 -j DROP"}'
Enable Internet Access
Enable full internet access (default behavior):import { VoidRun } from '@voidrun/sdk';
const vr = new VoidRun({ apiKey: process.env.VR_API_KEY });
const sandbox = await vr.getSandbox('sandbox-id');
// TODO: Verify exact method - network config may be via exec or dedicated API
// Enable outbound internet
await sandbox.exec({
command: 'iptables -D OUTPUT -p tcp --dport 80 -j DROP 2>/dev/null; iptables -D OUTPUT -p tcp --dport 443 -j DROP 2>/dev/null; echo "Internet enabled"'
});
// Verify internet works
const result = await sandbox.exec({ command: 'curl -s --connect-timeout 5 https://api.ipify.org' });
console.log('Public IP:', result.data?.stdout);
from voidrun import VoidRun
import os
vr = VoidRun(api_key=os.environ.get("VR_API_KEY"))
sandbox = vr.get_sandbox("sandbox-id")
# TODO: Verify exact method - network config may be via exec or dedicated API
# Enable outbound internet
sandbox.exec('iptables -D OUTPUT -p tcp --dport 80 -j DROP 2>/dev/null; iptables -D OUTPUT -p tcp --dport 443 -j DROP 2>/dev/null; echo "Internet enabled"')
# Verify internet works
result = sandbox.exec('curl -s --connect-timeout 5 https://api.ipify.org')
print("Public IP:", result.data.stdout)
# Enable outbound internet
voidrun exec <sandbox-id> --command "iptables -D OUTPUT -p tcp --dport 80 -j DROP 2>/dev/null; iptables -D OUTPUT -p tcp --dport 443 -j DROP 2>/dev/null"
# Verify internet works
voidrun exec <sandbox-id> --command "curl -s --connect-timeout 5 https://api.ipify.org"
curl -X POST "https://api.void-run.com/api/sandboxes/<sandbox-id>/exec" \
-H "X-API-Key: $VR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"command": "iptables -D OUTPUT -p tcp --dport 80 -j DROP 2>/dev/null; iptables -D OUTPUT -p tcp --dport 443 -j DROP 2>/dev/null"}'
Allowlists
Configure allowlists to permit access only to specific domains or IPs:Domain Allowlist
import { VoidRun } from '@voidrun/sdk';
const vr = new VoidRun({ apiKey: process.env.VR_API_KEY });
const sandbox = await vr.createSandbox({ cpu: 2, mem: 2048 });
// TODO: Verify exact implementation for allowlists
// Set up allowlist for specific domains only
const allowedDomains = [
'api.github.com',
'pypi.org',
'registry.npmjs.org'
];
// Block all outbound first, then allow specific domains
await sandbox.exec({
command: `
# Block all outbound HTTP/HTTPS
iptables -A OUTPUT -p tcp --dport 80 -j DROP
iptables -A OUTPUT -p tcp --dport 443 -j DROP
# Allow specific domains (resolve and allow their IPs)
for domain in ${allowedDomains.join(' ')}; do
ip=$(dig +short $domain | head -1)
iptables -I OUTPUT -d $ip -p tcp --dport 443 -j ACCEPT
done
echo "Allowlist configured"
`
});
// Test: allowed domain works
const allowed = await sandbox.exec({ command: 'curl -s --connect-timeout 5 https://api.github.com/zen' });
console.log('GitHub API:', allowed.data?.stdout);
// Test: blocked domain fails
const blocked = await sandbox.exec({ command: 'curl -s --connect-timeout 5 https://google.com || echo "Blocked"' });
console.log('Google:', blocked.data?.stdout); // "Blocked"
from voidrun import VoidRun
import os
vr = VoidRun(api_key=os.environ.get("VR_API_KEY"))
sandbox = vr.create_sandbox(cpu=2, mem=2048)
# TODO: Verify exact implementation for allowlists
allowed_domains = [
"api.github.com",
"pypi.org",
"registry.npmjs.org"
]
# Block all outbound first, then allow specific domains
sandbox.exec(f"""
# Block all outbound HTTP/HTTPS
iptables -A OUTPUT -p tcp --dport 80 -j DROP
iptables -A OUTPUT -p tcp --dport 443 -j DROP
# Allow specific domains (resolve and allow their IPs)
for domain in {' '.join(allowed_domains)}; do
ip=$(dig +short $domain | head -1)
iptables -I OUTPUT -d $ip -p tcp --dport 443 -j ACCEPT
done
echo "Allowlist configured"
""")
# Test: allowed domain works
allowed = sandbox.exec("curl -s --connect-timeout 5 https://api.github.com/zen")
print("GitHub API:", allowed.data.stdout)
# Create sandbox
voidrun create --cpu 2 --mem 2048
# Configure allowlist (allow only api.github.com and pypi.org)
voidrun exec <sandbox-id> --command '
iptables -A OUTPUT -p tcp --dport 80 -j DROP
iptables -A OUTPUT -p tcp --dport 443 -j DROP
# Allow specific domains
for domain in api.github.com pypi.org; do
ip=$(dig +short $domain | head -1)
iptables -I OUTPUT -d $ip -p tcp --dport 443 -j ACCEPT
done
'
# Test allowed domain
voidrun exec <sandbox-id> --command "curl -s https://api.github.com/zen"
# Configure allowlist
curl -X POST "https://api.void-run.com/api/sandboxes/<sandbox-id>/exec" \
-H "X-API-Key: $VR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"command": "iptables -A OUTPUT -p tcp --dport 443 -j DROP && iptables -I OUTPUT -d $(dig +short api.github.com | head -1) -p tcp --dport 443 -j ACCEPT"}'
IP Allowlist
import { VoidRun } from '@voidrun/sdk';
const vr = new VoidRun({ apiKey: process.env.VR_API_KEY });
const sandbox = await vr.getSandbox('sandbox-id');
// TODO: Verify exact implementation
// Allow specific IP addresses only
const allowedIPs = ['192.168.1.100', '10.0.0.50'];
await sandbox.exec({
command: `
# Block all outbound first
iptables -A OUTPUT -p tcp --dport 443 -j DROP
# Allow specific IPs
for ip in ${allowedIPs.join(' ')}; do
iptables -I OUTPUT -d $ip -p tcp --dport 443 -j ACCEPT
done
`
});
from voidrun import VoidRun
import os
vr = VoidRun(api_key=os.environ.get("VR_API_KEY"))
sandbox = vr.get_sandbox("sandbox-id")
# TODO: Verify exact implementation
allowed_ips = ["192.168.1.100", "10.0.0.50"]
sandbox.exec(f"""
# Block all outbound first
iptables -A OUTPUT -p tcp --dport 443 -j DROP
# Allow specific IPs
for ip in {' '.join(allowed_ips)}; do
iptables -I OUTPUT -d $ip -p tcp --dport 443 -j ACCEPT
done
""")
# Allow specific IPs only
voidrun exec <sandbox-id> --command '
iptables -A OUTPUT -p tcp --dport 443 -j DROP
iptables -I OUTPUT -d 192.168.1.100 -p tcp --dport 443 -j ACCEPT
iptables -I OUTPUT -d 10.0.0.50 -p tcp --dport 443 -j ACCEPT
'
curl -X POST "https://api.void-run.com/api/sandboxes/<sandbox-id>/exec" \
-H "X-API-Key: $VR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"command": "iptables -A OUTPUT -p tcp --dport 443 -j DROP && iptables -I OUTPUT -d 192.168.1.100 -p tcp --dport 443 -j ACCEPT"}'
Blocklists
Configure blocklists to deny access to specific domains or IPs:import { VoidRun } from '@voidrun/sdk';
const vr = new VoidRun({ apiKey: process.env.VR_API_KEY });
const sandbox = await vr.createSandbox({ cpu: 2, mem: 2048 });
// TODO: Verify exact implementation for blocklists
// Block specific domains
const blockedDomains = [
'facebook.com',
'twitter.com',
'tiktok.com'
];
await sandbox.exec({
command: `
# Block specific domains
for domain in ${blockedDomains.join(' ')}; do
ip=$(dig +short $domain | head -1)
iptables -A OUTPUT -d $ip -j DROP
done
echo "Blocklist configured"
`
});
// Test: blocked domain fails
const blocked = await sandbox.exec({ command: 'curl -s --connect-timeout 5 https://facebook.com || echo "Blocked"' });
console.log('Facebook:', blocked.data?.stdout); // "Blocked"
// Test: other domains work
const allowed = await sandbox.exec({ command: 'curl -s --connect-timeout 5 https://google.com' });
console.log('Google works:', allowed.data?.stdout ? 'Yes' : 'No');
from voidrun import VoidRun
import os
vr = VoidRun(api_key=os.environ.get("VR_API_KEY"))
sandbox = vr.create_sandbox(cpu=2, mem=2048)
# TODO: Verify exact implementation for blocklists
blocked_domains = [
"facebook.com",
"twitter.com",
"tiktok.com"
]
sandbox.exec(f"""
# Block specific domains
for domain in {' '.join(blocked_domains)}; do
ip=$(dig +short $domain | head -1)
iptables -A OUTPUT -d $ip -j DROP
done
echo "Blocklist configured"
""")
# Test: blocked domain fails
blocked = sandbox.exec("curl -s --connect-timeout 5 https://facebook.com || echo 'Blocked'")
print("Facebook:", blocked.data.stdout) # "Blocked"
# Block specific domains
voidrun exec <sandbox-id> --command '
for domain in facebook.com twitter.com tiktok.com; do
ip=$(dig +short $domain | head -1)
iptables -A OUTPUT -d $ip -j DROP
done
'
# Test blocked domain
voidrun exec <sandbox-id> --command "curl -s --connect-timeout 5 https://facebook.com || echo 'Blocked'"
curl -X POST "https://api.void-run.com/api/sandboxes/<sandbox-id>/exec" \
-H "X-API-Key: $VR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"command": "iptables -A OUTPUT -d $(dig +short facebook.com | head -1) -j DROP"}'
Security Best Practices
Network rules are enforced at the MicroVM level using iptables. This provides kernel-level isolation and prevents bypass attempts by AI agents or malicious code.
Recommended Configurations
🔒 Maximum Security
Block all internet access. Only allow internal communication.
iptables -A OUTPUT -p tcp --dport 80 -j DROP
iptables -A OUTPUT -p tcp --dport 443 -j DROP
🎯 Selective Access
Allow only required APIs. Block everything else.
# Allow only GitHub API
iptables -A OUTPUT -p tcp --dport 443 -j DROP
iptables -I OUTPUT -d $(dig +short api.github.com | head -1) -p tcp --dport 443 -j ACCEPT
Security Checklist
1
Identify Required Endpoints
List all external APIs and services your sandbox needs to access.
2
Create Allowlist
Configure iptables to allow only those specific endpoints.
3
Block Everything Else
Set default DROP policy for all other outbound traffic.
4
Test Configuration
Verify allowed endpoints work and blocked endpoints fail.
5
Monitor Traffic
Log any blocked connection attempts for auditing.
Network rules are reset when a sandbox is terminated. For persistent security policies, configure network rules at the start of each session or use a custom image with pre-configured iptables rules.
Next Steps
Tailscale VPN
Connect sandboxes to your private network via Tailscale.
Custom Images
Create images with pre-configured network rules.

