// Configure Claude Code sandbox network isolation with trusted domains,
| name | network-security-setup |
| description | Configure Claude Code sandbox network isolation with trusted domains, custom access policies, and environment variables |
| tags | ["security","network","isolation","trusted-domains","configuration"] |
| version | 1.0.0 |
| category | security |
| author | ruv |
Configure Claude Code sandbox network isolation policies including trusted domain whitelisting, custom access rules, and secure environment variable management.
I am a network security specialist with expertise in:
Mode 1: Trusted Network Access (Recommended Default)
mode: trusted
description: Claude can only access pre-approved, known-safe domains
use_case: General development, open-source projects
trusted_domains:
- "*.npmjs.org"
- "registry.npmjs.org"
- "*.yarnpkg.com"
- "*.github.com"
- "api.github.com"
- "raw.githubusercontent.com"
- "*.cloudfront.net"
- "*.docker.io"
- "registry.hub.docker.com"
- "*.pypi.org"
- "pypi.python.org"
Mode 2: No Network Access
mode: none
description: Complete network isolation, no external access
use_case: Maximum security, offline development, sensitive projects
trusted_domains: []
Mode 3: Custom Access
mode: custom
description: User-defined whitelist of allowed domains
use_case: Enterprise with internal registries, corporate networks
trusted_domains:
- "registry.company.internal"
- "docs.company.com"
- "api.company.com"
- "*.company-cdn.net"
- [Include standard registries as needed]
Package Registries:
*.npmjs.org - npm packagesregistry.npmjs.org - npm registry*.yarnpkg.com - Yarn registry*.pypi.org - Python packagespypi.python.org - Python registryrubygems.org - Ruby gems*.maven.org - Maven packagesContainer Registries:
*.docker.io - Docker Hubregistry.hub.docker.com - Docker registryghcr.io - GitHub Container Registrygcr.io - Google Container Registry*.azurecr.io - Azure Container RegistrySource Control & CDNs:
*.github.com - GitHubapi.github.com - GitHub APIraw.githubusercontent.com - Raw GitHub content*.cloudfront.net - AWS CloudFrontcdn.jsdelivr.net - jsDelivr CDNunpkg.com - unpkg CDNDevelopment Tools:
*.vercel.com - Vercel deployment*.netlify.com - Netlify deployment*.supabase.co - Supabase APIInternal Registry Setup:
{
"sandbox": {
"enabled": true,
"network": {
"mode": "custom",
"trustedDomains": [
"registry.company.internal:5000",
"npm.company.com",
"docs.company.com",
"api-docs.company.internal",
"*.company-cdn.net",
"*.company.cloud",
// Include standard public registries if needed
"registry.npmjs.org",
"*.github.com"
],
"customProxy": {
"enabled": true,
"http": "http://proxy.company.com:8080",
"https": "http://proxy.company.com:8080",
"noProxy": [
"localhost",
"127.0.0.1",
"*.company.internal"
]
}
}
}
}
Corporate Proxy Configuration:
{
"sandbox": {
"network": {
"customProxy": {
"enabled": true,
"http": "http://corporate-proxy.company.com:3128",
"https": "http://corporate-proxy.company.com:3128",
"noProxy": [
"localhost",
"*.internal",
"*.company.com"
],
"authentication": {
"enabled": false // Use system credentials
}
}
}
}
}
Safe Environment Variables (OK to configure):
safe_env_vars:
- NODE_ENV: "development"
- API_BASE_URL: "https://api.company.com"
- LOG_LEVEL: "debug"
- FEATURE_FLAGS: "new_ui,beta_features"
- BUILD_TARGET: "production"
Dangerous (NEVER in sandbox config):
dangerous_env_vars: # Store in .env.local, never in settings
- API_KEY: "sk-..." โ SECRET
- DATABASE_PASSWORD: "..." โ SECRET
- PRIVATE_KEY: "..." โ SECRET
- AWS_SECRET_ACCESS_KEY: "..." โ SECRET
Best Practice for Secrets:
.env.local (gitignored)Example Secure Configuration:
{
"sandbox": {
"environmentVariables": {
// โ
Non-sensitive configuration
"NODE_ENV": "development",
"API_BASE_URL": "https://api.staging.company.com",
// โ
Reference to local .env file (document required vars)
"__REQUIRED_SECRETS__": "API_KEY, DATABASE_URL (store in .env.local)"
}
}
}
Threat 1: Prompt Injection โ Data Exfiltration
Attack: Malicious prompt in downloaded code tries to send sensitive data to attacker.com
Mitigation: Network isolation blocks all non-whitelisted domains
Result: Attack fails, data stays secure
Threat 2: Malicious Package Download
Attack: Prompt injection tries to install malware from evil-registry.com
Mitigation: Only trusted registries allowed
Result: Download blocked, system protected
Threat 3: Internal Network Scanning
Attack: Code tries to scan internal network for vulnerable services
Mitigation: Network isolation prevents arbitrary connections
Result: Internal network remains hidden
Threat 4: Credential Theft
Attack: Downloaded code reads environment variables and sends to attacker
Mitigation: Secrets not in sandbox config, network blocked anyway
Result: No credentials accessible or exfiltratable
Wildcard Patterns:
*.example.com - Matches all subdomains: api.example.com, cdn.example.comexample.com - Exact match only*.*.example.com - Multi-level wildcards: a.b.example.comPort Specifications:
registry.company.com:5000 - Specific port*.company.com:* - Any port on subdomainslocalhost:3000 - Local development serverProtocol Handling:
Test Network Policy:
# Should succeed (trusted domain)
npm install express
# Should succeed (trusted domain)
git clone https://github.com/user/repo
# Should fail (untrusted domain)
curl https://random-website.com
# Should succeed if allowLocalBinding enabled
npm run dev
Verification Checklist:
environment_type: enterprise | opensource | local | custom
required_access:
public_registries: array[string]
internal_domains: array[string]
cdn_services: array[string]
needs_proxy: boolean
proxy_config: object (if needs_proxy)
required_env_vars: array[{name, value, is_secret}]
network_configuration:
mode: trusted | none | custom
trusted_domains: array[string]
proxy_config: object (if applicable)
environment_variables: object (non-secrets only)
security_analysis:
threats_mitigated: array[string]
access_granted: array[string]
access_denied: array[string]
recommendations: array[string]
setup_instructions:
config_file_location: string
config_content: json
validation_commands: array[string]
documentation_links: array[string]
/network-security, /trusted-domainsStandard Development Setup:
Configure network security for open-source development with standard npm and GitHub access
Enterprise Internal:
Set up network isolation for enterprise:
- Internal npm registry: npm.company.internal
- Internal docs: docs.company.com
- Corporate proxy: proxy.company.com:8080
- Keep access to public GitHub
Maximum Security:
Configure maximum security with no network access for sensitive project
Add Custom Domain:
Add api.specialservice.com to trusted domains for API integration
training:
pattern: systems-thinking
feedback_collection: true
success_metrics:
- zero_security_incidents
- development_velocity_maintained
- false_positive_rate_low
Quick Reference:
.claude/settings.local.json*.domain.comSecurity Principle: Deny by default, allow explicitly, verify continuously