Skip to content
FlyCockpit
WS Sandbox Proxy/ Hosts, KVM & Pools
WS Sandbox Proxy logo

Hosts, KVM & Pools

WS Sandbox ProxyRust + TypeScriptMIT
Repository

Enroll Linux KVM hosts with Incus 6.14+, configure capacity and storage budgets, and schedule sandboxes across host pools.

Platforms: Linux with KVM + Incus 6.14+ (or --runtime fake)

A host is a Linux machine you control running the wssp host run daemon. The daemon maintains one outbound WebSocket (wss://<api-origin>/ws/sandbox-host) to the control plane, drives local Incus KVM virtual machines, and enforces sandbox leases and cleanup independently even while offline. The control plane never connects directly to Incus.

Host requirements

A host missing any prerequisite may connect to the control plane, but the server will refuse to schedule sandboxes on it (UNSUPPORTED_CAPABILITY).

1. Linux with KVM and Incus 6.14+

  • Linux (x86_64 or aarch64) with /dev/kvm usable by Incus. Sandboxes are always Incus virtual-machine instances (wssp-sbx-<sandboxId>), never containers.
  • Incus 6.14 or newer with the network_acl API extension. Releases older than 6.14 cannot reliably enforce per-sandbox bridge anti-spoofing (CVE-2025-52890), so the daemon advertises egressEnforcement: false and refuses creates.
  • Incus CLI 7.4+ is recommended when using very large domain allowlists (over ~96 KiB / ~1,400 resolved DNS records); older incus CLIs pass network updates inline on the command line and hit argument-size caps. Restart wssp host run after upgrading the Incus CLI.

On Ubuntu 24.04, the distro archive ships Incus 6.0.0, which is too old. Install the Zabbly stable repository instead:

sudo mkdir -p /etc/apt/keyrings
sudo curl -fsSL --max-time 120 https://pkgs.zabbly.com/key.asc -o /etc/apt/keyrings/zabbly.asc
sudo sh -c 'cat > /etc/apt/sources.list.d/zabbly-incus-stable.sources <<EOF
Enabled: yes
Types: deb
URIs: https://pkgs.zabbly.com/incus/stable
Suites: $(. /etc/os-release && echo ${VERSION_CODENAME})
Components: main
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/zabbly.asc
EOF'
sudo apt-get update && sudo apt-get install incus

2. Kernel bridge netfilter and conntrack

Sandbox NICs enable security.ipv6_filtering, which requires br_netfilter with net.bridge.bridge-nf-call-ip6tables=1. wssp host run --runtime incus refuses to start until both are active:

sudo modprobe br_netfilter
echo br_netfilter | sudo tee /etc/modules-load.d/wssp-br_netfilter.conf
sudo sysctl -w net.bridge.bridge-nf-call-ip6tables=1
echo net.bridge.bridge-nf-call-ip6tables=1 | sudo tee /etc/sysctl.d/90-wssp-bridge-nf.conf

Install the conntrack package (conntrack on Debian/Ubuntu, conntrack-tools on Fedora/RHEL). Without it, the egress guard quarantines the host with conntrack_unavailable.

3. Incus user, project, and shared lock directory

  • The unprivileged user running wssp host run must have Incus admin access (typically membership in the incus-admin group).
  • By default, the daemon auto-provisions a dedicated wssp Incus project (features.profiles=false, features.images=false) so VMs stay isolated while sharing the default project’s profiles and image aliases. Override with --incus-project or WSSP_INCUS_PROJECT.
  • The default profile must contain only a root disk and one eth0 NIC with no extra config keys; anything else fails preflight.
  • Provision the shared Incus lock directory once as root, granting group access to the daemon user’s group:
sudo install -d -m 2770 -o root -g <daemon-users-group> /var/lib/wssp/incus-daemon-locks

4. One daemon per Incus server

Only one wssp daemon may drive a given Incus server so bridge names (wsn-<id>) and cached image fingerprints never collide. The daemon maintains a numbered profile lease (wssp-daemon-lease-<n>-<id>) in the default project renewed every 15 seconds (60-second TTL) and refuses to start if another live daemon holds it.

[!NOTE] Release binaries for Linux link musl statically and resolve users via /etc/passwd rather than glibc NSS modules (LDAP/SSSD). Ensure the daemon’s local user and group entries exist in /etc/passwd and /etc/group.

Installing and enrolling a host

Install the wssp binary matching your server’s exact version as the unprivileged daemon user:

curl --proto '=https' --tlsv1.2 -fsSL --max-time 120 https://wssp.example.com/install.sh | sh

The installer verifies the release archive against sha256.sum and installs ~/.local/bin/wssp.

wssp host enroll --slug desk-01 --server https://wssp.example.com

wssp host enroll prints a verification URL and user code without opening a browser or reading stdin. Open the link in a browser signed in to your dashboard (verified email and 2FA required) and approve it. Approving a new slug creates the host and stores a long-lived wssp_device_… credential outside config.toml under ~/.local/share/wssp/device-auth.json (mode 0600, directory 0700).

Dashboard host token (alternative)

Mint a wssp_host_… token on Settings → Host credentials for an existing host, export it in an environment variable matching ^WSSP_[A-Z0-9_]{1,64}$, and bind the variable name (the secret itself is never saved to config):

export WSSP_HOST_TOKEN=wssp_host_...
wssp host enroll --token-env WSSP_HOST_TOKEN
wssp host run --server https://wssp.example.com --host-id <host-id>

Private CA trust

When your server uses an internal certificate authority, pass --ca-file <path> (or set WSSP_CA_FILE per run). Certificates are added to the default webpki roots; chain, expiry, and hostname verification remain strictly enforced with no insecure bypass.

wssp host enroll --slug desk-01 --server https://wssp.internal --ca-file /etc/wssp/root-ca.pem
wssp host config set-ca-file /etc/wssp/root-ca.pem

On Unix, the CA file and its immediate parent directory must be owned by your user or root and must not be group- or world-writable (0644 or 0600).

Install the egress guard and run the daemon

Install the root-owned wssp-guard service once (add --configure-ufw or --configure-firewalld if the host runs a default-drop firewall):

sudo "$(command -v wssp)" host guard install --daemon-user "$USER"
wssp host run

For production hosts, run wssp host run as a systemd user service (wssp-host.service) with Restart=always and LimitCORE=0 (especially if the host runs CLI-login sandboxes).

[!IMPORTANT] Always connect hosts using the exact canonical origin configured in the server’s BETTER_AUTH_URL (including scheme and non-default port). Connecting via an alias such as 127.0.0.1 when BETTER_AUTH_URL uses localhost fails the journal-key binding check and refuses environment-bearing operations.

Outbound relay and durable receipts

wssp host run speaks relay protocol 1.0 (ws-sandbox-proxy.relay.v1) over wss://<origin>/ws/sandbox-host and never follows HTTP redirects with credentials.

  • Durable receipt journal: Private receipts and lease checkpoints are stored under WSSP_DATA_DIR/relay/<host-id SHA-256> (mode 0700/0600 with file and directory fsync, protected by an exclusive directory lock). Never delete this directory to “retry” operations—losing local receipts leaves previously dispatched work in UNKNOWN_OUTCOME.
  • Memory-only journal HMAC key: On connect, the server installs a derived journal HMAC key held only in daemon RAM. After a reconnect, receipts replay one at a time, followed by a paginated sandbox.inventory census of managed instances and leases.
  • Reconnection & backoff: Once a session has been established, dropped connections reconnect automatically (fast 1 s retries for 60 s while carrying active work, then exponential backoff up to 30 s). Credential revocation (4003 close) exits with code 4 and does not reconnect, while continuing to enforce already-accepted local leases.
  • Targeted UNKNOWN attestation: For allocations stuck in UNKNOWN_OUTCOME, the server performs an in-session targeted check against the host’s journal and Incus state. If the host proves the VM was never created, the server releases capacity and settles the operation as FAILED (host_effect_not_issued).

Capacity, storage pools, and drain

Automatic detection and TOML overrides

A bare wssp host run inspects Incus /1.0/resources to derive default commitments:

  • RAM budget: Total host RAM minus max(2048 MiB, 25%), aligned down to 256 MiB. Each live VM is charged memoryMiB + 256 MiB host overhead.
  • Aggregate vCPU budget: host_threads * 2.
  • Per-VM CPU cap: min(32, host_threads).
  • Root disk commitment: diskGiB + 1 GiB (default root disk 32 GiB), retained across STOPPED and UNKNOWN states until proven deleted.

Inspect effective values and sources without touching Incus:

wssp host config show --json

To override budgets or expose explicit Incus storage pools (up to 16), edit ~/.config/wssp/config.toml (wssp host config path) and restart the daemon:

sandbox_memory_mib = 95232
sandbox_vcpu_budget = 64
max_sandbox_cpu_count = 32

[[storage_pools]]
name = "default"
capacity_gib = 96
draining = false

[[storage_pools]]
name = "nvme-sandboxes"
capacity_gib = 64
draining = false

--sandbox-memory-mib, --sandbox-vcpu-budget, and --max-sandbox-cpu-count flags also override TOML per run; storage pool lists are TOML-only. Shrinking a budget never resizes or evicts existing VMs.

Drain and undrain

Drain prevents new sandbox creates, cold starts, and template captures on a host while allowing existing running sandboxes to finish:

wssp host drain --json
wssp host drain --offload   # also triggers background offload of stopped disks to S3
wssp host undrain --json

drained: true means zero live reservations (including pending and uncertain holds). Stopped disks or unfinished operations can still block host deletion until cleared.

Host pools and placement scheduling

Pools group enrolled hosts for automatic placement. A host may belong to multiple pools, including pools owned by other users.

Placement algorithm

When creating a sandbox with poolId, the scheduler evaluates only enabled, online, non-draining, guard-healthy members visible to the calling key that jointly fit CPU, charged RAM, vCPU, root disk, per-VM caps, and storage pool health:

  1. Image availability: Hosts that already have the exact verified template revision cached rank ahead of hosts that must fetch it.
  2. Own-host tier: When the pool’s Prefer own hosts setting is enabled (default), the requester’s own hosts rank in a higher tier than contributed foreign hosts (a sort tier, never a hard filter).
  3. Lowest dominant share: Within a tier, the host with the lowest post-placement dominant share—max(ramShare, vcpuShare, storageShare)—wins. Ties break by lower RAM share, then host ID.
  4. Storage pool selection: Within the chosen host, healthy non-draining storage pools rank by free committed GiB descending.

Pool capacity can be inspected ahead of time via GET /v1/pools/{id}/capacity (or wssp.pools.capacity()), which returns aggregate free resources, fits count, largest feasible per-dimension values, lease limits, and queue depth.

Waiting for capacity (FIFO queue)

Pool creates may pass waitForCapacityMs (1000–2073600000 ms, or "unlimited" if permitted by policy) to wait in the pool’s FIFO queue instead of immediately returning 409 sandbox.pool_full.

  • The sandbox enters WAITING_FOR_CAPACITY with no host, disk, or lease consumed; its lease starts only when placed (or at READY).
  • Smaller requests behind the queue head can bypass it up to 8 times on hosts the head could use; after 8 bypasses, those hosts are reserved exclusively for the head (sandbox.pool_full with reason: "reserved" for non-waiting creates).
  • Direct (sandboxHostId) creates never queue.

Sharing pools and foreign-host policy

Pool owners can invite other users with independent Use and Contribute permissions, optional RAM/vCPU/disk share caps, and a disconnect grace promise (0–30 days, default 3 days) protecting stopped disks if access is lost.

Because templates remain per-account and foreign sandboxes run on the contributor’s network and hardware, each host owner controls four local opt-in settings:

Host config key CLI command Default
accept_foreign_images Edit config.toml and restart false
accept_foreign_builds wssp host config set-accept-foreign-builds on false
allow_open_egress_for_others wssp host config set-open-egress-for-others on false
allow_guest_sudo_for_others wssp host config set-allow-guest-sudo-for-others on true

[!WARNING] Trust the node owner. The daemon user on an Incus host can inspect every VM on that machine, including other users’ shared-pool sandboxes. Disabling host terminals or restricting API keys does not isolate a guest from the physical machine’s local Incus administrator.

Fake runtime testing flags

For local development and integration testing without KVM or Incus, run wssp host run --runtime fake (or WSSP_RUNTIME=fake). The fake runtime advertises 4096 MiB RAM, 4 host threads, and 8 total vCPU.

Environment variable Purpose
WSSP_RUNTIME=fake Select the in-process fake runtime (launches no VMs)
WSSP_FAKE_ENFORCE_EGRESS=1 Advertise egress enforcement so creates succeed on local stacks (no real firewalling)
WSSP_FAKE_FAIL_CREATE_FILE=<path> Cause all new creates to fail while <path> exists on disk

Both WSSP_FAKE_* flags are rejected at startup if --runtime incus is used.