Skip to main content

Documentation Index

Fetch the complete documentation index at: https://superradcompanyinc-mintlify-changelog-1777648095.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

See Networking for conceptual overview and TLS Interception for TLS proxy details. Network configuration is attached to a sandbox via SandboxBuilder.network(n => ...). Inside the callback you get a NetworkBuilder which exposes DNS, TLS, secret, and policy configuration.
import { Sandbox, NetworkPolicy } from "microsandbox";

await using sb = await Sandbox.builder("filtered")
  .image("alpine")
  .network((n) => n
    .policy(NetworkPolicy.publicOnly())
    .denyDomainSuffixes(".evil.com")
    .tls((t) => t.bypass("*.googleapis.com")),
  )
  .create();
For port publishing, use SandboxBuilder.port(host, guest) / portUdp(host, guest) (or the equivalent methods on NetworkBuilder).

NetworkPolicy

Static factory for creating preset policies. Each helper returns a plain NetworkPolicy value that can be passed to NetworkBuilder.policy(...).
import { NetworkPolicy, Rule, Destination } from "microsandbox";

// Custom policy
const custom = {
  defaultEgress: "deny",
  defaultIngress: "allow",
  rules: [
    Rule.allowEgress(Destination.domain("api.openai.com")),
    Rule.denyEgress(Destination.group("metadata")),
  ],
};

NetworkPolicy.allowAll()

static allowAll(): NetworkPolicy
Unrestricted network access, including to private addresses and the host machine.

NetworkPolicy.none()

static none(): NetworkPolicy
Deny all traffic. The guest is fully offline. exec and fs still work since they use the host-guest channel, not the network.

NetworkPolicy.publicOnly()

static publicOnly(): NetworkPolicy
Block private address ranges and cloud metadata endpoints. Allow everything else. This is the default policy.

NetworkPolicy.nonLocal()

static nonLocal(): NetworkPolicy
Allow egress to public + private (LAN) destinations; ingress allowed by default.

Rules and destinations

Rule

Factory for individual policy rules. Each method returns a single Rule value.
MethodDirectionAction
Rule.allowEgress(dest)egressallow
Rule.denyEgress(dest)egressdeny
Rule.allowIngress(dest)ingressallow
Rule.denyIngress(dest)ingressdeny
Rule.allowAny(dest)anyallow
Rule.denyAny(dest)anydeny

Destination

Factory for rule destinations.
MethodDescription
Destination.any()Match any destination
Destination.cidr(cidr)Match an IP range, e.g. "10.0.0.0/8"
Destination.domain(domain)Exact domain match
Destination.domainSuffix(suffix)Match the apex and every subdomain
Destination.group(group)Match a DestinationGroup

PortRange

MethodDescription
PortRange.single(port)Single port ({ start, end } set to the same value)
PortRange.range(start, end)Inclusive port range

NetworkBuilder

Returned to the callback you pass to SandboxBuilder.network(...). Every setter returns the same builder.
MethodDescription
enabled(b)Enable or disable networking.
port(host, guest)Publish a TCP port.
portUdp(host, guest)Publish a UDP port.
policy(NetworkPolicy)Set the policy. Use a NetworkPolicy factory or a literal.
denyDomains(...names)Deny egress to these exact domains. Each entry adds a deny Domain("...") policy rule that fires at DNS resolution (REFUSED), TLS first-flight (SNI), and TCP egress (cache fallback). Prepended onto the policy.
denyDomainSuffixes(...suffixes)Deny egress to all subdomains of these suffixes. Same enforcement layers.
dns(d => ...)Configure DNS — see DnsBuilder.
tls(t => ...)Configure TLS — see TlsBuilder.
secret(s => ...)Add a secret — see SecretBuilder.
secretEnv(envVar, value, placeholder, allowedHost)Four-arg explicit-placeholder shorthand.
onSecretViolation(action)Action on disallowed secret use — see ViolationAction.
maxConnections(n)Maximum concurrent connections.
trustHostCAs(enabled)Ship the host’s trusted root CAs into the guest at boot. Opt-in.
build()Internal — produce a NetworkConfig.

DnsBuilder

MethodDescription
nameservers(servers)Override upstream nameservers (IP, IP:PORT, HOST, or HOST:PORT).
rebindProtection(enabled)Toggle DNS rebinding protection.
queryTimeoutMs(ms)Per-query timeout.
build()Internal — produce a DnsConfig.

TlsBuilder

MethodDescription
bypass(pattern)Skip interception for hosts matching this glob (e.g. "*.internal.corp").
verifyUpstream(verify)Verify upstream server certificates. Default true.
interceptedPorts(ports)TCP ports to intercept. Default [443].
blockQuic(block)Block QUIC on intercepted ports, forcing TCP/TLS fallback.
upstreamCaCert(path)Add a PEM file with extra root CAs the proxy should trust.
interceptCaCert(path)PEM file used as the intercepting CA’s certificate.
interceptCaKey(path)PEM file used as the intercepting CA’s private key.
build()Internal — produce a TlsConfig.

Types

NetworkConfig

Built network configuration produced by NetworkBuilder.build().
FieldTypeDescription
enabledbooleanMaster enable flag
portsreadonly PublishedPort[]Port publishings
policyNetworkPolicy | nullActive policy
dnsDnsConfig | nullDNS interception
tlsTlsConfig | nullTLS interception
secretsreadonly SecretEntry[]Secret entries
secretViolationViolationAction | nullAction on disallowed secret use
maxConnectionsnumber | nullMaximum concurrent connections
trustHostCAsbooleanShip host CAs into the guest

NetworkPolicy

interface NetworkPolicy {
  readonly defaultEgress: Action;
  readonly defaultIngress: Action;
  readonly rules: readonly Rule[];
}

Rule

interface Rule {
  readonly direction: Direction;
  readonly destination: Destination;
  readonly protocols: readonly Protocol[]; // empty = any
  readonly ports: readonly PortRange[];    // empty = any
  readonly action: Action;
}

Destination

type Destination =
  | { kind: "any" }
  | { kind: "cidr"; cidr: string }
  | { kind: "domain"; domain: string }
  | { kind: "domainSuffix"; suffix: string }
  | { kind: "group"; group: DestinationGroup };

Action

type Action = "allow" | "deny";

Direction

type Direction = "egress" | "ingress" | "any";

Protocol

type Protocol = "tcp" | "udp" | "icmpv4" | "icmpv6";

DestinationGroup

type DestinationGroup =
  | "public"
  | "loopback"
  | "private"
  | "link-local"
  | "metadata"
  | "multicast"
  | "host";
ValueDescription
'public'Public internet (everything not in another group)
'loopback'Guest’s own 127.0.0.0/8 / ::1
'private'RFC1918 LAN ranges
'link-local'169.254.0.0/16 / fe80::/10
'metadata'Cloud metadata endpoints (169.254.169.254, fd00:ec2::254)
'multicast'Multicast addresses
'host'The host machine, reached via host.microsandbox.internal

PortRange

interface PortRange {
  readonly start: number;
  readonly end: number;
}

DnsConfig

FieldTypeDescription
nameserversreadonly string[]Upstream nameservers
rebindProtectionboolean | nullDNS rebinding protection toggle
queryTimeoutMsnumber | nullPer-query timeout

TlsConfig

FieldTypeDescription
bypassreadonly string[]Bypass globs (e.g. "*.googleapis.com")
verifyUpstreamboolean | nullVerify upstream certs
interceptedPortsreadonly number[]Intercepted TCP ports
blockQuicboolean | nullBlock QUIC on intercepted ports
upstreamCaCertPathsreadonly string[]Extra trust roots for upstream verification
interceptCaCertPathstring | nullCustom intercept CA cert (PEM)
interceptCaKeyPathstring | nullCustom intercept CA key (PEM)

PublishedPort

interface PublishedPort {
  readonly hostPort: number;
  readonly guestPort: number;
  readonly protocol: "tcp" | "udp";
}