Skip to main content

SandboxNetwork

Struct SandboxNetwork 

Source
#[non_exhaustive]
pub struct SandboxNetwork { pub allowed_domains: Option<Vec<String>>, pub denied_domains: Option<Vec<String>>, pub allow_managed_domains_only: Option<bool>, pub allow_unix_sockets: Option<Vec<String>>, pub allow_all_unix_sockets: Option<bool>, pub allow_local_binding: Option<bool>, pub allow_mach_lookup: Option<Vec<String>>, pub http_proxy_port: Option<u16>, pub socks_proxy_port: Option<u16>, pub tls_terminate: Option<TlsTerminate>, pub strict_allowlist: Option<bool>, pub extra: Extra, }
Expand description

sandbox.network.

Control which hosts, ports, and sockets sandboxed commands can reach. The sandbox routes outbound traffic through a proxy that enforces these lists; see Network isolation for how the proxy decides and when it prompts.

Docs: sandbox.network.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§allowed_domains: Option<Vec<String>>

Pre-allow domains for outbound traffic from sandboxed commands, so the sandbox doesn’t prompt for them. Wildcards such as *.example.com match subdomains, and an optional :port suffix limits an entry to one port; an entry without a port matches every port.

Docs: allowedDomains.

§denied_domains: Option<Vec<String>>

Block domains for outbound traffic from sandboxed commands, using the same wildcard, port, and IPv6 syntax as allowedDomains. A denied domain stays blocked even when an allowedDomains entry matches it too.

  • Values: array of strings, each a domain, wildcard pattern, or IP literal, with an optional :port suffix
  • Default: unset
  • Scope: any settings file.

Docs: deniedDomains.

§allow_managed_domains_only: Option<bool>

Lock the network allowlist to what managed settings define. Claude Code then honors only allowedDomains and WebFetch(domain:...) allow rules from managed settings, ignores domains from user, project, local, and --settings settings, and blocks a non-allowed domain automatically instead of prompting.

  • Values: Boolean
    • true: Claude Code honors only allowedDomains and WebFetch(domain:...) allow rules from managed settings and blocks a non-allowed domain instead of prompting
    • false: domains from other settings files can merge into the allowlist
  • Default: false
  • Scope: managed.

Docs: allowManagedDomainsOnly.

§allow_unix_sockets: Option<Vec<String>>

List the Unix socket paths sandboxed commands can connect to on macOS. Claude Code ignores this list on Linux and WSL2, where the seccomp filter can’t inspect socket paths; use allowAllUnixSockets there instead.

Docs: allowUnixSockets.

§allow_all_unix_sockets: Option<bool>

Let sandboxed commands connect to every Unix socket. On Linux and WSL2, the sandbox’s seccomp filter blocks socket(AF_UNIX, ...) calls, so this is the only way to permit Unix sockets there. When the filter is missing, which /sandbox reports on its Dependencies tab, the sandbox doesn’t block Unix-socket calls.

  • Values: Boolean
    • true: sandboxed commands can connect to every Unix socket. On Linux and WSL2 they can also connect to VM sockets, the AF_VSOCK address family
    • false: the sandbox blocks Unix-socket connections: on macOS except the paths in allowUnixSockets, and on Linux and WSL2 through the seccomp filter when it’s present
  • Default: false
  • Scope: any settings file, with limits on project and local settings.

Docs: allowAllUnixSockets.

§allow_local_binding: Option<bool>

Let sandboxed commands on macOS listen on network ports, for example to start a dev server, and connect to any port on localhost. A command that listens on a non-loopback address accepts connections from other machines. The key has no effect on Linux and WSL2, where each sandboxed command has its own loopback interface.

  • Values: Boolean
    • true: sandboxed commands on macOS can listen on any local address and connect to any port on localhost
    • false: sandboxed commands on macOS can’t listen on a port or connect directly to servers on localhost
  • Default: false
  • Scope: any settings file, with limits on project and local settings.

Docs: allowLocalBinding.

§allow_mach_lookup: Option<Vec<String>>

List additional XPC and Mach service names the macOS sandbox may look up. Tools that communicate over XPC, such as the iOS Simulator or Playwright, need their services listed here. Sandboxed commands can reach outside the sandbox to each service that you list, and the sandbox doesn’t confine what those services do for those commands.

  • Values: array of strings, each a service name; a single trailing * matches a prefix, and "*" alone matches every service
  • Default: unset
  • Scope: any settings file, with limits on project and local settings.

Docs: allowMachLookup.

§http_proxy_port: Option<u16>

Point the sandbox at your own HTTP proxy instead of the one Claude Code runs. Organizations do this to inspect HTTPS traffic, apply their own filtering rules, or log requests. Your proxy takes over filtering, and Claude Code stops applying its domain lists and network prompts to traffic sent there.

Docs: httpProxyPort.

§socks_proxy_port: Option<u16>

Point the sandbox at your own SOCKS5 proxy instead of the one Claude Code runs. Your proxy takes over filtering, and Claude Code stops applying its domain lists and network prompts to traffic sent there. When unset, Claude Code starts its own proxy for SOCKS traffic.

Docs: socksProxyPort.

§tls_terminate: Option<TlsTerminate>

Make the sandbox proxy terminate TLS so it can read the contents of HTTPS requests. This is experimental, and mask credential substitution requires it. Set {} to generate an ephemeral certificate authority for the session, or set caCertPath and caKeyPath to use your own.

  • Values: object with optional caCertPath and caKeyPath strings, each a file path
  • Default: unset, so the proxy doesn’t terminate or inspect TLS
  • Scope: user or managed. A repository can’t switch it on or supply a certificate authority.

Docs: tlsTerminate.

§strict_allowlist: Option<bool>

Deny sandboxed commands access to hosts outside the allowlist instead of prompting for approval. The allowlist is allowedDomains plus domains from WebFetch(domain:...) allow rules, or only the managed settings entries when allowManagedDomainsOnly is set. Locks that apply without an admin-required sandbox covers a repository’s entries.

  • Values: Boolean
    • true: Claude Code denies sandboxed commands access to hosts outside the allowlist
    • false: unless another trusted settings file sets true, Claude Code decides a host outside the allowlist by permission mode instead of denying it outright: in auto mode it checks the host against the command’s per-command allowed domains, in dontAsk mode it denies, in bypassPermissions mode and in interactive terminal plan-mode sessions where bypass is available it allows, and otherwise it asks you
  • Default: false
  • Scope: user or managed. A repository can’t turn it on or off.

Docs: strictAllowlist.

§extra: Extra

Keys Claude Code accepts here that this crate doesn’t model (newer or undocumented ones), kept as written so the document round-trips.

Trait Implementations§

Source§

impl Clone for SandboxNetwork

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SandboxNetwork

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SandboxNetwork

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for SandboxNetwork

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for SandboxNetwork

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for SandboxNetwork

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for SandboxNetwork

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.