Auth Planes, Egress & Host Security
Understand WS Sandbox Proxy's four isolated authentication planes, root-owned nftables egress guard, guest boundaries, opt-in host access (ADR-006), and signed webhooks.
WS Sandbox Proxy enforces strict credential isolation across four authentication planes, guards every sandbox’s outbound network through a root-owned nftables service, keeps guest VMs free of control-plane credentials, and gates host-level agent actions behind explicit node-local opt-in.
Four isolated authentication planes
Every resource (host, template, sandbox, operation, webhook, CLI login) belongs to a single user account. Credentials from one plane are always refused on every other plane:
| Plane | Caller | Endpoints | Credential |
|---|---|---|---|
| Browser | People in the web dashboard | /rpc, /api/dashboard/…, browser terminal WS |
Better Auth cookie session, CSRF (x-csrf-token: orpc), required-2FA policy |
| SDK | Programs & wssp user CLI |
/v1/… (including /v1/sandboxes/{id}/connect) |
Authorization: Bearer wssp_sdk_… (SdkKeyKind.API) |
| MCP | AI coding agents | /mcp |
Authorization: Bearer wssp_agent_… or OAuth 2.1 access token (OAUTH_GRANT) |
| Host | wssp host run node daemons |
/ws/sandbox-host (outbound WSS) |
wssp_host_… (dashboard token) or wssp_device_… (device enrollment) |
Enforced separation matrix
| Presented credential | /rpc |
/v1 |
/mcp |
/ws/sandbox-host |
Browser terminal |
|---|---|---|---|---|---|
| Cookie session | Accepted | Ignored (401) | Ignored (401) | Refused | Accepted with one-use ticket |
wssp_sdk_… |
No session | Accepted | Refused (401) | Refused | Refused (CREDENTIAL_PLANE) |
wssp_agent_… |
No session | Refused (401) | Accepted | Refused | Refused (CREDENTIAL_PLANE) |
| OAuth access token | No session | Refused (401) | Accepted (live grant) | Refused | Refused (CREDENTIAL_PLANE) |
wssp_host_… / wssp_device_… |
No session | Refused (401) | Refused (401) | Accepted | Refused (CREDENTIAL_PLANE) |
Key security invariants across planes:
- No principal cache: Every
/v1and/mcprequest re-verifies the credential’s HMAC, expiry, revocation, scopes, resource allowlists, and owner 2FA/ban status live. - No credentials in URLs: Query-string credentials are rejected (
BAD_REQUEST) even alongside a validAuthorizationheader. - Metadata-only admin: Admin routes (
/{lang}/admin) return404for non-admins. Admin observability shows only metadata (account names, sandbox names, host/template labels)—never commands, output, files, terminals, or secrets. - Creator scoping (
ownSandboxesOnly): Restricts sandbox, guest command, guest file, and operation access to sandboxes created by that credential. Defaults tofalseon SDK keys andtrueon agent tokens and OAuth grants;ALLOWLISTkeys are always creator-restricted. - Password reset revocation: Resetting a password signs out all sessions and revokes all SDK keys, CLI logins, agent tokens, OAuth grants, and host/device credentials atomically. Rotating
BETTER_AUTH_SECRETalso invalidates all sessions and product credentials.
Root-owned nftables egress guard
Every enrolled host runs wssp-guard.service—the only WS Sandbox Proxy component that runs as root. Install it once per host:
sudo wssp host guard install --daemon-user <user>
wssp host guard status --json
How wssp-guard protects the host and LAN
- Drop-only table (
inet wssp_guard): Always blocks RFC 1918 private ranges, loopback (127.0.0.0/8), link-local and cloud metadata (169.254.0.0/16,100.100.100.200, Azure wireserver), CGNAT/tailnet (100.64.0.0/10), documentation/multicast/reserved ranges, every address of the host itself, routed internal prefixes, other sandboxes, and the operator/deployment blocklists. - Privilege separation: The guard reads only root-owned files (
/etc/wssp/guard.toml,/etc/wssp/egress-blocklist). Over its Unix socket (verified withSO_PEERCRED), the unprivileged daemon may only push the deployment-wideSANDBOX_EGRESS_BLOCKLIST(unioned with the root file)—it can never remove a root block entry. - Dead-man switch: The guard renews its rules continuously. If
wssp-guardcrashes or hangs, forwarding for sandbox bridges stops automatically within 30 seconds. The daemon treats a health lease older than 15 seconds as unhealthy and stops admitting new sandboxes (UNSUPPORTED_CAPABILITY,reason: "egress_guard_unavailable"). - Quarantine & bridge fencing: If the guard detects an unsupported packet path (nftables flowtables/offload, competing
ip/inetbase chains at or before guard priority,netdevchains, XDP programs,ingress/clsactqdiscs on bridges/uplinks, or non-Incusbridgetables), missingconntrack, or an unconfirmed conntrack flush, it immediately cuts forwarding, flushes conntrack, and takes everywsn-*bridge link down until healthy again. - Operator blocklist: Add IPv4 CIDRs or domain names to
/etc/wssp/egress-blocklist(up to 4,096 CIDRs and 2,048 domains). CIDR additions apply live to running sandboxes and terminate matching flows; domain entries apply to newly created sandboxes (best-effort via bridge DNS—use CIDRs for hard guarantees).
Network egress modes
Each sandbox gets its own IPv4-only Incus bridge and network ACL with MAC/IPv4/IPv6 filtering and port isolation. The egress mode is immutable once placed and re-applied on every cold boot or offload restore:
| Mode | Reachable destinations |
|---|---|
open (default) |
Public IPv4 internet minus all always-blocked ranges and outbound SMTP (tcp/25, configurable via wssp host config set-egress-block-smtp off) |
allowlist |
Only the listed exact domains (up to 128) and IPv4 cidrs (up to 128); empty allowlist denies all outbound traffic |
Allowlist mechanics and caveats
- Host-resolved IPv4 leases: Domain grants are resolved on the host to public IPv4 addresses and installed as 300-second ACL grants, refreshed every ~150 seconds. Failed lookups never extend expired leases (fail closed).
- Bridge resolver: Answers only allowlisted names with TTL 0 (returning
NODATAfor AAAA/other record types andREFUSED/NXDOMAINfor unlisted names). Direct external DNS is blocked in allowlist mode. - DNS rebinding protection: If any resolved IPv4 address for a granted domain falls in a protected/private range, the entire domain is refused at create or immediately withdrawn on refresh.
- Shared CDN IPs: Domain grants permit traffic by destination IP, not HTTP
Hostheader or TLS SNI. Any other site sharing a granted CDN IP is reachable. For strict hostname isolation, route through an egress proxy behind a CIDR grant. - Foreign hosts:
allow_open_egress_for_othersdefaults tofalseon every host. Anopenrequest landing on a non-consenting foreign host downgrades toallowlistusing any fallback grants provided (egressModeReason: "node_policy").
[!NOTE] Qualification note: Live open-egress smoke testing on real Incus/KVM hosts verified public internet reachability, SMTP rejection, and drops to host LAN, overlay (
100.64.0.0/10), gateway, and bridge addresses. Full multi-tenant lateral and allowlist qualification (docs/operations/host-isolation-qualification.md) remains an operator checklist item for production deployments.
Guest isolation boundaries
- KVM hardware virtualization: Every sandbox runs its own Linux kernel in an Incus KVM VM with zero host mounts, proxy devices, or control-plane credentials.
- Root inside the guest (
guestSudo): Enabled by default (guestSudo: true), granting the guest user passwordlesssudoinside the VM while commands, files, and terminals still execute as the non-root guest user. PassingguestSudo: falseremoves sudo and rejects images that already grant root (guest_root_granted). guestRootaccounting: When a sandbox hasguestSudo: trueor runs an image built with root steps / captured with guest root,sandbox.guestRootistrue. Because guest root can alter guest-side helpers, command completions are guest-attested andUNKNOWN_OUTCOMEcommands only clear once the host observes the VM stop or restart. Host-side network ACLs andwssp-guardremain strictly outside guest control.
Opt-in host commands and files (ADR-006)
Programs (/v1) and agents (/mcp) can optionally run commands and edit text files directly on nodes owned by the credential’s user using the hosts:execute and hosts:files scopes.
[!WARNING] Critical security caveat: Host commands and host file tools run as the node daemon user, which is an Incus admin. An agent with host access can reach every sandbox on that node—including other users’ shared-pool sandboxes—read the daemon’s own credential, and modify its config.
ownSandboxesOnlydoes not limit host commands or host file tools. Enable only for agents you trust with that Linux account.
Node-local opt-in and emergency dashboard veto
Both allow_agent_host_commands (governing host commands and host file tools) and allow_host_terminal (governing owner browser host shells) start off and can never be enabled remotely from the dashboard or API.
Enable them in a separate local login TTY on the node (not from a dashboard host terminal or the daemon’s cgroup):
wssp host config set-agent-host-commands on
wssp host config set-host-command-max-time 600 # 1–86400 s
wssp host config set-host-file-roots /srv/projects /home/operator/work
wssp host config set-host-terminal on
- Raising settings prompts you to type
oninteractively (no--yesflag). - File tools require explicit canonical
host_file_roots(up to 32 directories, never/,/proc,/sys,/dev, or daemon state/config paths; 256 KiB payload limit, ETag concurrency control). - Emergency stop: Clicking Turn off on Settings → Hosts → Details → Agent access sets a durable server-side veto that the node cannot undo by reconnecting or editing config, immediately cancelling in-flight host commands and file work. Lifting the veto (Allow again) requires a live owner browser session while the node reports the setting off. Note that processes spawned outside the daemon’s process tree (cron jobs,
systemd-run --userunits) survive lowering and should be audited if you stop trusting an agent. - Output masking & audit: The daemon masks known secrets (active CLI-login values, host/device credentials,
wssp_*tokens, PEM private keys) before returning command output or file reads, and refuses writing⟦redactedmarkers back. Audit records store credential, node, program basename, and a subject HMAC for 90 days—never raw command text, file contents, or output.
Queued host commands (human-in-the-loop)
Even when allow_agent_host_commands is off, a credential with hosts:execute on an owned host can queue a command (POST /v1/hosts/{id}/queued-commands or MCP host_command_queue) with a reason and 1–168 hour expiry (default 24 h, max 50 pending per user). Nothing executes automatically. The node owner reviews the command in Settings → Hosts → Details → Queued commands and either Dismisses it or clicks Run, which prepares a shell-quoted wrapper (sudo -k before and after, cleared SUDO_ASKPASS/BASH_ENV/ENV) in the owner’s host terminal—pressing Enter remains the human’s decision.
Signed webhooks
Webhooks notify your HTTPS receiver on sandbox, operation, and CLI-login transitions (DATA_ENCRYPTION_KEY must be set on both server and worker).
Events
- Sandbox:
sandbox.ready,sandbox.stopped,sandbox.create_failed,sandbox.destroyed,sandbox.offloaded - Operations:
operation.completed(filtered by operation kind; defaults to lifecycle kinds +RUN_COMMAND, or"all") - CLI logins:
credential.capture_failed,credential.capture_lost,credential.recovery_required,credential.needs_login - Manual:
webhook.test
Verification (Standard Webhooks)
Deliveries carry webhook-id, webhook-timestamp, and webhook-signature (v1,<base64 HMAC-SHA256> over <webhook-id>.<webhook-timestamp>.<rawBody> using the base64-decoded whsec_ secret). Always verify raw request bytes, enforce a ±300 s timestamp window, and deduplicate by webhook-id for at least 24 hours (deliveries are at-least-once and unordered).
import { verifyWebhook } from "@wssp/sdk/webhooks";
const event = verifyWebhook({
body: rawBodyBytes,
headers: req.headers,
secret: process.env.WSSP_WEBHOOK_SECRET!, // or [newSecret, oldSecret] during rotation
});
Delivery reliability and SSRF defense
- Retries: 11 attempts over 24 hours (immediate, then ~30 s, 2 m, 5 m, 15 m, 30 m, 1 h, 2 h, 4 h, 6 h, 8 h ±20%), 10 s timeout per attempt, max 2 concurrent attempts per endpoint, no redirects.
- Auto-disable: Endpoints failing continuously for 72 hours and 20 consecutive attempts are disabled and the owner is emailed.
- SSRF protection: HTTPS only (ports
443or1024–65535). Every resolved IP is verified public unicast on every attempt and pinned for the connection; loopback, RFC 1918, CGNAT, cloud metadata (169.254.169.254,fd00:ec2::254,100.100.100.200,168.63.129.16), and IPv4-embedded/NAT64 IPv6 addresses are refused (destination_blocked). Operators can opt into private receivers for admins viaWEBHOOK_ALLOWED_PRIVATE_CIDRS/WEBHOOK_ALLOWED_PRIVATE_HOSTS.