NetworkPolicy
Used by NetworkBuilder.policy() · returned by NetworkPolicy factories
Ordered rule list with per-direction defaults. First-match-wins is evaluated independently for egress and ingress.NetworkPolicy.builder()
Example
Example
NetworkPolicyBuilder. Equivalent to new NetworkPolicyBuilder(). String inputs (.ip(), .cidr(), .domain(), .domainSuffix()) are stored raw and parsed at build(), so the chain stays clean and the first parse or validation failure surfaces there.
Returns
NetworkPolicy.none()
exec and fs still work since they use the host-guest channel, not the network.
NetworkPolicy.allowAll()
NetworkPolicy.fromProfiles()
"public", "private", and "host" profiles. Duplicate profiles are ignored, rules use canonical order, and every non-empty profile set receives one narrow gateway DNS rule. An empty set permits no egress and adds no DNS; ingress defaults to allow.
Example
Example
Rule
Used by NetworkPolicy.rules · built via Rule factories
A single ordered policy rule.Rule.allowEgress()
Example
Example
egress. Empty protocols and ports mean “any”.
Parameters
destinationDestinationRule.denyEgress()
egress.
Parameters
destinationDestinationRule.allowIngress()
ingress.
Parameters
destinationDestinationRule.denyIngress()
ingress.
Parameters
destinationDestinationRule.allowAny()
any (matches in either direction).
Parameters
destinationDestinationRule.denyAny()
any (matches in either direction).
Parameters
destinationDestinationRule.allowDns()
Example
Example
Destination.group("host") tcp/853 allow rule if needed (and pair with TLS interception).
Rule.denyDns()
Destination
Used by Rule.destination · built via Destination factories
Destination filter. An internally-tagged union; use theDestination factory for constructors.
Destination.any()
Destination.cidr()
Parameters
cidrstring“10.0.0.0/8”.Destination.domain()
Parameters
domainstringDestination.domainSuffix()
Parameters
suffixstringDestination.group()
Parameters
groupDestinationGroupPortRange
Used by Rule.ports · built via PortRange factories
Inclusive port range. Always interpreted as the guest-side port.PortRange.single()
start and end are set to the same value.
Parameters
portnumberPortRange.range()
Parameters
startnumberendnumberNetworkBuilder
Passed to the callback you giveSandboxBuilder.network(...). Every setter returns the same builder. The runtime serializes the accumulated config when the sandbox is created.
network.policy()
Example
Example
NetworkPolicy literal or factory result, or a NetworkPolicyBuilder (routed through the native bridge so lazy parse/validation errors surface at this call site).
Parameters
policyNetworkPolicynetwork.port()
127.0.0.1.
Parameters
hostnumberguestnumbernetwork.portBind()
0.0.0.0.
Parameters
bindstringhostnumberguestnumbernetwork.portUdp()
127.0.0.1.
Parameters
hostnumberguestnumbernetwork.portUdpBind()
Parameters
bindstringhostnumberguestnumbernetwork.dns()
Example
Example
DnsBuilder.
Parameters
configureDnsBuildernetwork.tls()
TlsBuilder.
Parameters
configureTlsBuildernetwork.trustHostCAs()
false. Opt in for corporate MITM proxies (Cloudflare Warp Zero Trust, Zscaler, Netskope, etc.) whose gateway CA is installed on the host but unknown to the guest’s stock Mozilla bundle.
Parameters
enabledbooleannetwork.maxConnections()
Parameters
maxnumbernetwork.rateLimiter()
Example
Example
network.ipv4Pool()
/30 guest subnets. Defaults to 172.16.0.0/12.
Parameters
poolstringnetwork.ipv6Pool()
/64 guest prefixes. Defaults to fd42:6d73:62::/48.
Parameters
poolstringnetwork.interface()
Example
Example
InterfaceOverridesBuilder exposes .mac(), .mtu(), .ipv4(), and .ipv6().
Parameters
configureInterfaceOverridesBuildernetwork.enabled()
false, no network interface is created.
Parameters
enabledbooleannetwork.onSecretViolation()
Example
Example
ViolationActionBuilder.
Parameters
configureViolationActionBuildernetwork.secret()
SecretBuilder.
Parameters
configureSecretBuildernetwork.secretEnv()
Parameters
envVarstring= or NUL).valuestringplaceholderstringallowedHoststringnetwork.secretEnvSimple()
Example
Example
$MSB_<envVar>, so it is the terse counterpart to secretEnv() when you do not need a custom placeholder. The full secret API also lives on the secrets page.
Parameters
envVarstring= or NUL).valuestringallowedHoststringnetwork.build()
NetworkConfig. The native bridge returns snake_case serde output, which the wrapper remaps to camelCase keys before handing back a plain JS object. Inside SandboxBuilder.network(...) the runtime calls this for you; call it directly only when you want to inspect or persist the resolved config.
Returns
NetworkPolicyBuilder
Fluent builder forNetworkPolicy.
policy.defaultDeny()
defaultEgress and defaultIngress to "deny".
policy.defaultAllow()
defaultEgress and defaultIngress to "allow".
policy.defaultEgress()
Parameters
action”allow” | “deny”policy.defaultIngress()
Parameters
action”allow” | “deny”policy.egress()
rule() with direction pre-set to egress.
Parameters
configureRuleBuilderpolicy.ingress()
rule() with direction pre-set to ingress.
Parameters
configureRuleBuilderpolicy.any()
rule() with direction pre-set to any. Rules committed inside apply in both directions.
Parameters
configureRuleBuilderpolicy.rule()
.egress(), .ingress(), or .any() before any rule-adder.
Parameters
configureRuleBuilderpolicy.build()
NetworkPolicy. Lazily parses every recorded .ip() / .cidr() / .domain() / .domainSuffix() input, validates direction-set and ICMP-egress-only invariants, and emits a host-side warning for each shadowed rule pair.
Returns
RuleBuilder
Builder for one policy-rule batch.rule.egress()
egress for subsequent rule-adders.
rule.ingress()
ingress for subsequent rule-adders.
rule.any()
any for subsequent rule-adders. Rules committed after this apply in both directions.
Protocol setters
Protocols accumulate as a set; duplicates dedupe.rule.tcp()
tcp to the protocols set.
rule.udp()
udp to the protocols set.
rule.icmpv4()
icmpv4 to the protocols set. Egress-only; an ICMP rule on an ingress or any direction fails build.
rule.icmpv6()
icmpv6 to the protocols set. Egress-only; same rules as icmpv4().
Port setters
Ports accumulate as a set; duplicates dedupe. Always guest-side (egress destination port / ingress listening port).rule.port()
Parameters
portnumber0..=65535.rule.portRange()
lo > hi records an error surfaced at build() time.
Parameters
lonumberhinumberrule.ports()
port() once per element.
Parameters
portsnumber[]Group rule-adders
Each adder commits one rule using the current state and the named destination group.rule.allowPublic()
public group (complement of named categories: every IP not in any other group).
rule.denyPublic()
public group.
rule.allowPrivate()
private group (RFC1918 + ULA + CGN).
rule.denyPrivate()
private group.
rule.allowLoopback()
loopback group (127.0.0.0/8, ::1). The guest’s own loopback, not the host. To reach a service on the host’s localhost, use allowHost() instead. See the loopback-vs-host watch-out.
rule.denyLoopback()
loopback group.
rule.allowLinkLocal()
link-local group (169.254.0.0/16, fe80::/10). Excludes the metadata IP 169.254.169.254.
rule.denyLinkLocal()
link-local group.
rule.allowMeta()
metadata group (169.254.169.254). Dangerous on cloud hosts (exposes IAM credentials).
rule.denyMeta()
metadata group.
rule.allowMulticast()
multicast group (224.0.0.0/4, ff00::/8).
rule.denyMulticast()
multicast group.
rule.allowHost()
host group: per-sandbox gateway IPs that back host.microsandbox.internal. This is the right shortcut for “let the sandbox reach my host’s localhost”, not allowLoopback().
rule.denyHost()
host group.
Composite rule-adders
rule.allowLocal()
loopback + link-local + host. Each uses the callback’s current state. metadata is intentionally not included; opt in via allowMeta() separately.
rule.denyLocal()
loopback + link-local + host. metadata is intentionally not included.
Domain rule-adders
Singular forms add one rule; plural forms add one rule per element.rule.allowDomain()
Destination::Domain allow rule.
Parameters
namestringrule.denyDomain()
Destination::Domain deny rule.
Parameters
namestringrule.allowDomains()
Destination::Domain allow rule per name.
Parameters
namesstring[]rule.denyDomains()
Destination::Domain deny rule per name.
Parameters
namesstring[]rule.allowDomainSuffix()
Destination::DomainSuffix allow rule. Matches the apex and any subdomain.
Parameters
suffixstringrule.denyDomainSuffix()
Destination::DomainSuffix deny rule. Matches the apex and any subdomain.
Parameters
suffixstringrule.allowDomainSuffixes()
Destination::DomainSuffix allow rule per suffix.
Parameters
suffixesstring[]rule.denyDomainSuffixes()
Destination::DomainSuffix deny rule per suffix.
Parameters
suffixesstring[]Explicit-destination rule-adders
.allow() / .deny() open a RuleDestinationBuilder callback. Exactly one destination call commits the rule.
rule.allow()
allow.
Parameters
configureRuleDestinationBuilderrule.deny()
deny.
Parameters
configureRuleDestinationBuilderRuleDestinationBuilder
Returned byRuleBuilder.allow(d => ...) / .deny(d => ...). Exactly one destination call commits the rule; dropping without a destination call silently does nothing.
destination.ip()
Destination::Cidr of the IP as /32 or /128.
Parameters
ipstringdestination.cidr()
Destination::Cidr.
Parameters
cidrstringdestination.domain()
Destination::Domain.
Parameters
domainstringdestination.domainSuffix()
Destination::DomainSuffix.
Parameters
suffixstringdestination.group()
Destination::Group. group is a DestinationGroup string.
Parameters
groupDestinationGroupdestination.any()
Destination::Any.
DnsBuilder
Builder for DNS interception settings. Used inNetworkBuilder.dns(d => ...). Owns rebind protection, nameserver pinning, and the per-query timeout.
dns.rebindProtection()
Parameters
enabledbooleandns.nameservers()
Parameters
serversstring[]IP, IP:PORT, HOST, or HOST:PORT.dns.queryTimeoutMs()
Parameters
msnumberTlsBuilder
Builder for TLS interception settings. Used inNetworkBuilder.tls(t => ...).
tls.bypass()
"*.internal.corp"). Use for domains with certificate pinning.
Parameters
patternstringtls.verifyUpstream()
true. Set to false only for self-signed servers.
Parameters
verifybooleantls.verifyUpstreamFor()
pattern. Pattern syntax matches bypass(): exact hosts and *.suffix wildcards are supported. Setting verify to false is the proxy-side equivalent of curl -k for matching hosts; TLS interception still runs.
tls.interceptedPorts()
[443].
Parameters
portsnumber[]tls.blockQuic()
Parameters
blockbooleantls.interceptCaCert()
Parameters
pathstringtls.interceptCaKey()
Parameters
pathstringtls.upstreamCaCert()
Parameters
pathstringtls.upstreamCaCertFor()
pattern. Pattern syntax matches bypass(): exact hosts and *.suffix wildcards are supported.
ViolationActionBuilder
Configures the action taken when a secret would be sent to a disallowed host. Used inNetworkBuilder.onSecretViolation(v => ...). Passthrough host calls accumulate; when passthrough hosts are configured, non-matching hosts use the default secret-violation action.
violation.block()
violation.blockAndLog()
violation.blockAndTerminate()
violation.passthroughHost()
Parameters
hoststringviolation.passthroughHostPattern()
Parameters
patternstringviolation.passthroughAllHosts()
iUnderstand flag must be true to acknowledge the broad scope.
Parameters
iUnderstandbooleantrue to opt in.NetworkRateLimiterBuilder
Groups local rate limits by traffic direction. Supplied toNetworkBuilder.rateLimiter().
.egress()
.ingress()
RateLimiterBuilder
Builder for one direction’s rate limiter, supplied toNetworkRateLimiterBuilder.egress() or ingress(). A limiter caps bandwidth (bytes) and packet rate (frames) independently; leaving a bucket unset leaves that dimension unlimited. Buckets start full plus their one-time burst and refill continuously. Every setter returns this.
Validation runs at NetworkBuilder.build(): a limiter with neither bucket, a zero bucket size or refill interval, or a burst without its bucket throws. Bucket values must be non-negative integers.
.bandwidth()
sizeBytes bytes per refillTimeMs milliseconds.
Parameters
sizeBytesnumberrefillTimeMsnumber.bandwidthBurst()
bandwidth().
.ops()
count frames per refillTimeMs milliseconds.
.opsBurst()
ops().
InterfaceOverridesBuilder
Used by NetworkBuilder.interface()
Builder for per-sandbox network interface overrides.interface.mac()
interface.mtu()
interface.ipv4()
interface.ipv6()
Types
NetworkConfig
Returned by NetworkBuilder.build()
Built network configuration produced byNetworkBuilder.build(). Keys are camelCased from the Rust serde output.
NetworkProfile
Composable high-level access category accepted byNetworkPolicy.fromProfiles().
Action
Used by Rule.action · NetworkPolicy defaults
Action taken on a matching rule (or the per-direction default).Direction
Used by Rule.direction
Direction the rule applies to.DestinationGroup
Used by Destination.group() · RuleDestinationBuilder.group()
Predefined address group keyword. The runtime constantDestinationGroups lists all values.
Protocol
Used by Rule.protocols
Transport protocol filter. EmptyRule.protocols means “any protocol”.
PublishedPort
Used by NetworkConfig.ports
A published port mapping from the guest to the host.DnsConfig
Used by NetworkConfig.dns
DNS interception configuration.TlsConfig
Used by NetworkConfig.tls
TLS interception configuration.ScopedUpstreamCaCert
ScopedVerifyUpstream
NetworkRateLimiterConfig
Used by NetworkConfig.rateLimiter
RateLimiterConfig
Held by NetworkRateLimiterConfig
TokenBucketConfig
Held by RateLimiterConfig
One token bucket of a rate limiter: starts full, refills continuously atsize tokens per refillTimeMs, and the one-time burst never refills.