Skip to content
patattzelPublic

About

Multi-user personal Linux playgrounds for Cloudron, powered by unkernel

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Kernbox

Kernbox

Multi-user personal Linux playgrounds for Cloudron, powered by unkernel.

Boot isolated Alpine Linux, Debian 13, or BusyBox sandboxes in under a second — with Cloudron SSO login, multi-core SMP, AES-256-GCM encrypted secrets, persistent server-side storage in /app/data, instant instance switching, and automatic Cloudron backups.


Screenshots & Video Showcases

Multi-Instance Linux Playground, Live Terminal & /work Files

Kernbox Workspace with 2-vCPU Alpine Linux terminal, sidebar instance switcher, and /work Files drawer

Termius-Style Mobile PWA & Encrypted Secret Vault

Kernbox Mobile PWA with Termius-style extra-keys bar
Installable Mobile PWA (iOS & Android)
Kernbox Encrypted Secret Vault modal
AES-256-GCM Secret Vault (Write-Only, Global & Instance Overrides)

Use Cases

  • Personal Dev & Ops Sandbox on Cloudron: Standard Cloudron containers run unprivileged with a read-only root filesystem. Kernbox gives you full root / sudo, apk add / apt-get install, and real Linux 7.x kernel semantics inside a safe, unprivileged Cloudron app.
  • Self-Hosted Code Sandbox for AI Agents & Automations (REST API + MCP): Mint scoped Personal Access Tokens (kbx_...) and connect Claude, Antigravity, Cursor, n8n, or iOS Shortcuts via the built-in Streamable HTTP MCP server (/mcp) or POST /api/instances/:id/exec to spin up isolated Linux sandboxes on demand.
  • Always-On Background Services & Isolated CI Runners: Enable Keep running (∞), Auto-start after restart (↻), and a Startup Command (e.g. sh /work/boot.sh or a Gitea :host Actions runner) running inside a dedicated ⚡ Startup tab with live 128 KiB scrollback.
  • Multi-Distro Experimentation & Portable Snapshots: Keep separate persistent instances side-by-side (alpine-lab, debian-tools, scratch-box), clone or reset OS overlays while preserving /work, or export/import entire environments as compact sparse .kernbox.tar.gz archives (excluding secrets).
  • Web App Prototyping with Private Preview & Public Share Links: Spin up a Python, Node.js, or Go dev server on 127.0.0.1:<port> inside your VM, preview it privately over vsock (/preview/<id>/<port>/), or publish a revocable, time-limited public URL (/share/<token>/) isolated in a strict CSP: sandbox.
  • Persistent Cloud Shell & Mobile PWA: Install Kernbox as a Termius-style PWA on iOS & Android or reconnect from desktop with 128 KiB server-side scrollback replay and zero shared state between Cloudron users.

Key Features

  • Hybrid Compute (☁️ Server + 💻 Browser-VM): Choose per instance to run on your Cloudron server (always-on, MCP, REST /exec, public shares, NetBird) or offload 100% of CPU & RAM locally to the user's browser via unkernel/web (OPFS/IndexedDB persistence, HTTP Range distro streaming from Cloudron, SSRF-safe Wisp WebSocket bridge, and bidirectional /work sync).
  • Native Graphical Linux Desktop (🖥️ Desktop via /dev/fb0): Enable a native framebuffer display (800×600, 1024×640, 1280×720) and 1:1 mouse/keyboard input per instance — rendering at 60 FPS directly from local SharedArrayBuffer in Browser-VMs or streaming compressed deflate-raw deltas over WebSocket (WS /ws/instances/:id/display) from Server-VMs, with a built-in 1-click Alpine/Debian Xorg + Openbox installer.
  • Cloudron SSO & Strict Multi-User Isolation: Uses Cloudron's native oidc addon (OpenID Connect with PKCE + RS256 JWKS verification). Every user has their own isolated directory under /app/data/users/<user>/instances/.
  • REST API, /exec, OpenAPI 3.1 & Built-in MCP Server (/mcp):
    • Scoped Personal Access Tokens (kbx_... with read, exec, or full scopes, stored SHA-256 hashed in /app/data/tokens.json, unable to read/modify secrets or mint new tokens).
    • Synchronous POST /api/instances/:id/exec with shell, cwd, autoStart, configurable timeoutMs, and output truncation caps.
    • Built-in JSON-RPC 2.0 Streamable HTTP MCP server at POST /mcp exposing 10 scope-filtered sandbox tools, plus OpenAPI 3.1 spec at GET /api/openapi.json.
    • Address instances by either their copyable full ID (devbox-1a2b3c4d, shown directly in the sidebar & Settings) or their unique box name (devbox) across REST API, /preview, and MCP.
  • Always-On, Auto-Boot & Startup Commands: Per-instance Keep running (exempt from idle auto-stop), Auto-start after Cloudron/app restart, and an optional Startup Command (with 1-click /work/boot.sh and Gitea Runner presets) executed in /work inside a dedicated ⚡ Startup tab.
  • Sparse Instance Export & Chunked Import (.kernbox.tar.gz): Stream any instance (manifest.json, sparse-encoded kwdata.img OS overlay, and /work, intentionally excluding secrets & Tailscale credentials) as a compact .kernbox.tar.gz archive and re-import it via 4 MiB chunked uploads (Cloudflare 100 MB proxy-safe) with Zip-Slip and symlink escape protection.
  • Private Port Preview & Public Share Links (/share/<token>/): Preview guest loopback HTTP ports privately over vsock or publish revocable, optionally expiring public links with strict CSP: sandbox (no allow-same-origin), X-Robots-Tag: noindex, cookie stripping, and Cloudflare-friendly offline pages.
  • Multi-Core SMP & Wasm JIT Performance: Runs each VM in its own SharedArrayBuffer-backed worker thread with 1–4 SMP vCPUs, runtime aarch64-to-Wasm JIT compilation, TCP_NODELAY zero-latency WebSockets, and Node.js V8 compile cache.
  • AES-256-GCM Encrypted Secret Vault: Per-user encrypted secrets (HKDF-SHA256 derived keys + authenticated GCM with user/scope/name AAD). Write-only UI with global secrets, per-instance overrides, and bulk .env paste import. Injected RAM-only as $ENV_VAR in shells and live read-only files at /run/kernbox/secrets/<NAME> — never stored in kwdata.img, cloned, or exported.
  • Server-Side Persistent Storage & Backups:
    • OS Overlay (kwdata.img): Sparse 4 GiB ext4 disk per instance — installed packages and dotfiles survive restarts and are included in Cloudron backups.
    • Live /work Workspace: Mounted at /work over 9p directly onto /app/data/.../work, backed up as ordinary files by Cloudron.
  • Termius-Style Mobile PWA: Installable Progressive Web App (manifest.webmanifest + Service Worker + iOS/Android icons) with a sticky extra-keys bar (⚡ Snippets, Paste, Copy, ESC, TAB, sticky CTRL/ALT, ^C, arrow keys, shell symbols), iOS keyboard-aware visualViewport sizing, swipeable slide-over instance drawer, and native bottom-sheet menus.
  • ARMv8.3 Binary Compatibility Helper (kernbox-compat): Built-in guest command that patches ARMv8.3-A FEAT_LRCPC (ldapr/ldaprb/ldaprh) instructions in third-party aarch64 ELF binaries to semantically equivalent ARMv8.0-A (ldar/ldarb/ldarh) instructions in-place with constant ~2 MiB streaming memory.
  • Private Inter-VM Mesh (<name>.kernbox.local): Zero-config internal TCP networking strictly between a user's own running VMs over vsock (e.g. curl http://api.kernbox.local:8080 or redis.internal:6379) — isolated per Cloudron user with no host port exposure.
  • Per-Instance Tailscale / Headscale & NetBird Mesh VPN: Connect individual VMs directly to Tailscale, Headscale, or NetBird (Cloud or self-hosted) via interactive browser SSO login or AES-256-GCM encrypted auth/setup keys (tailscale.enc.json / netbird.enc.json, never exported or cloned), with persistent encrypted node identities, SSRF-checked custom control/management URLs, live Exit Node switching (Tailscale), and Force Relay over HTTPS/WebSocket (NetBird).
  • SSRF-Safe Outbound Networking (TCP + UDP): In-process authenticated Wisp v1 relay forwarding TCP and UDP while blocking loopback, RFC1918, link-local/metadata, NAT64, IPv6 ULA, and Cloudron-internal IP ranges by default.

Architecture

Browser / Mobile PWA (xterm.js + /work Files + Secret Vault + API/MCP UI)
   OR AI Agents / n8n / curl (Authorization: Bearer kbx_... -> REST API & /mcp)
        │  HTTPS + WebSocket (Cloudron OIDC Cookie or Scoped Bearer Token)
        ▼
Kernbox Node.js >= 24 Server (unprivileged cloudron:cloudron)
  ├── AuthService         → Cloudron OIDC (PKCE + RS256 JWKS) + Scoped API Tokens
  ├── SecretVault         → AES-256-GCM + HKDF-SHA256 per-user vault
  ├── Tailscale & NetBird → AES-256-GCM encrypted credentials/identities (tailscale.enc.json / netbird.enc.json)
  ├── PublicShareStore    → Revocable /share/<token>/ vsock HTTP proxies (CSP sandbox)
  ├── Archive Engine      → Streaming sparse .kernbox.tar.gz export + 4 MiB chunked import
  ├── MCP & OpenAPI       → Streamable HTTP JSON-RPC 2.0 (/mcp) + /api/openapi.json
  ├── VmManager           → 1 SMP WorkerKernel thread per running VM + auto-boot + Tailscale VPN
  │     ├── Base distro   → Read-only /app/code/distros/alpine.erofs (shared)
  │     ├── OS overlay    → /app/data/users/<uid>/instances/<id>/kwdata.img
  │     ├── 9p /work      → /app/data/users/<uid>/instances/<id>/work/
  │     ├── 9p secrets    → RAM-only read-only MemoryFs at /run/kernbox/secrets
  │     ├── Host commands → kernbox-compat (ARMv8.3 LDAPR -> ARMv8.0 LDAR)
  │     └── PTY & Exec    → Startup tab + shell tabs (128 KiB scrollback) + /exec
  └── SafeWispServer      → Authenticated Wisp relay: SSRF-safe internet + per-user *.kernbox.local mesh

Installing on Cloudron

Prerequisites

  • A Cloudron server (v10.0+ required for Community App CloudronVersions.json installs)
  • For CLI installs/builds: the Cloudron CLI (npm install -g cloudron) logged into your Cloudron instance

Quick Install via Cloudron Community App URL (Recommended)

In your Cloudron Dashboard (App Store → Custom / Community App) or via the Cloudron CLI, use the CloudronVersions.json URL:

https://raw.githubusercontent.com/patattzel/kernbox/main/CloudronVersions.json

Or via Cloudron CLI:

cloudron install --versions-url https://raw.githubusercontent.com/patattzel/kernbox/main/CloudronVersions.json --location kernbox.yourdomain.com

Or directly from the pre-built GHCR image:

cloudron install --image ghcr.io/patattzel/kernbox:latest --location kernbox.yourdomain.com

Build & Install from Source

git clone https://github.com/patattzel/kernbox.git
cd kernbox

# Build and push your own Cloudron app image (pre-bundles Alpine Linux)
cloudron build --set-repository ghcr.io/<your-user>/kernbox

# Install onto your Cloudron server (automatically wires OIDC SSO + /app/data)
cloudron install --location kernbox.yourdomain.com

Optional: Pre-bundle Debian too By default, the Docker build pre-bundles Alpine (~4 MB) into /app/code/distros so Alpine boots instantly offline, while Debian (~78 MB) downloads on first use into /app/data/cache/distros. To bake both into the image:

docker build --build-arg PREFETCH_DISTROS="alpine debian" -t ghcr.io/<your-user>/kernbox:0.13.0 .

Configuration on Cloudron

On first boot, start.sh creates /app/data/env.sh. Edit it via the Cloudron File Manager and restart the app to adjust quotas or defaults:

Variable Default Description
MAX_INSTANCES_PER_USER 12 Maximum stored instances per user
MAX_RUNNING_PER_USER 3 Maximum concurrently running VMs per user
MIN_MEMORY_MIB 128 Minimum selectable guest RAM (MiB)
DEFAULT_MEMORY_MIB 512 Default guest RAM for new instances (MiB)
MAX_MEMORY_MIB 2048 Maximum selectable guest RAM (MiB)
DEFAULT_CPUS 2 Default SMP vCPU count for new instances
MAX_CPUS_PER_INSTANCE 4 Maximum selectable SMP vCPUs per instance (up to host CPU count)
IDLE_TIMEOUT_MINUTES 30 Default idle auto-stop timeout in minutes (0 disables globally; also overrideable per instance via Keep running)
MAX_UPLOAD_MB 50 Maximum /work file upload size (MiB)
MAX_IMPORT_MB 500 Maximum .kernbox.tar.gz instance archive import size (MiB)
MAX_SNAPSHOTS_PER_INSTANCE 8 Maximum saved live RAM+disk snapshots (checkpoints) per instance
ALLOW_PRIVATE_NETWORK false Allow guests to connect to RFC1918/loopback IPs (keep false on multi-user servers!)
SECRETS_MASTER_KEY (auto) Optional 64-char hex master key for AES-256-GCM Secret Vault (defaults to /app/data/.secrets-master-key)

REST API & MCP Server (AI Agents, n8n, iOS Shortcuts)

  1. Open 🔌 API / MCP in the sidebar footer (or ⋯ → API Tokens & MCP on mobile) and generate a scoped Personal Access Token (kbx_...):
    • read — list/inspect instances, list VM snapshots, read /work files, export .kernbox.tar.gz archives
    • exec — start/stop instances, capture/restore/delete VM snapshots, run POST /api/instances/:id/exec, upload/delete /work files, create/revoke public share links
    • full — full instance lifecycle (create, update, clone, reset, import, delete)
  2. Run commands over HTTP using either the instance's full ID (devbox-1a2b3c4d) or its unique name (devbox), with optional autoStart: true:
    curl -s -X POST "https://kernbox.yourdomain.com/api/instances/devbox/exec" \
      -H "Authorization: Bearer kbx_YOUR_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{"command":"uname -a && nproc","shell":true,"cwd":"/work","autoStart":true}'
  3. Connect any MCP client (Antigravity, Claude, Cursor, n8n) directly to https://kernbox.yourdomain.com/mcp:
    {
      "mcpServers": {
        "kernbox": {
          "url": "https://kernbox.yourdomain.com/mcp",
          "headers": {
            "Authorization": "Bearer kbx_YOUR_TOKEN"
          }
        }
      }
    }
  4. Full machine-readable API spec is served at GET /api/openapi.json.

Private Inter-VM Mesh, Tailscale / Headscale & NetBird VPN

Internal VM-to-VM Networking (<name>.kernbox.local)

Every running instance with networking enabled can connect directly over TCP to your other running instances — strictly isolated to your own Cloudron account, with zero port forwarding or configuration:

# From your "frontend" VM, call an API or database running on your "backend" VM:
curl http://backend.kernbox.local:8080/health
nc -zv redis.internal 6379

Both <name>.kernbox.local (slugified box name or full instance ID) and <name>.internal are supported; copy the exact hostname from Settings → Private Mesh DNS.

Per-Instance Tailscale / Headscale Mesh VPN

Open Settings → 🌐 Tailscale / Headscale Mesh VPN on any instance to join it directly to your tailnet (powered by unkernel's pure-JS Tailscale engine over WebSocket + DERP — no UDP or privileged container required):

  • Interactive Login: Enable Tailscale, start the VM, and click the TS Login ↗ chip in the top bar (or Sign in to Tailscale ↗ in Settings).
  • Pre-Auth Key (Headless / Always-On): Paste a reusable or one-off Tailscale/Headscale auth key — stored write-only and encrypted with AES-256-GCM in tailscale.enc.json (excluded from clones and .kernbox.tar.gz exports).
  • Headscale & Exit Nodes: Configure a custom https:// Control URL (SSRF-validated), toggle Accept routes / Ephemeral, switch Exit Nodes live without restarting the VM, or reset the node identity at any time.

Per-Instance NetBird Mesh VPN (Cloud & Self-Hosted)

Open Settings → 🐦 NetBird Mesh VPN on any instance to connect it to NetBird Cloud or your self-hosted NetBird management server over unkernel's built-in /dev/net/tun kernel interface:

  • Zero Bloat & Verified Binary: On first use, Kernbox downloads and caches the official static netbird Linux ARM64 binary once into /app/data/cache/bin/ (pinned SHA-256 verified) and mounts it read-only into VMs — taking zero space inside kwdata.img and making netbird status available directly in your shell.
  • Interactive SSO Login or Encrypted Setup Key: Leave Setup Key blank for 1-click NB Login ↗ browser SSO login, or paste a Setup Key (encrypted AES-256-GCM in netbird.enc.json and passed via NB_SETUP_KEY, never CLI argv). Peer identity & WireGuard keys live RAM-only in /var/lib/netbird and persist encrypted at rest (never exported or cloned).
  • Self-Hosted & Cloudron-Friendly: Supports custom https:// Management URLs (SSRF-validated), Force Relay over HTTPS/WebSocket (on by default), Disable DNS, Block inbound, and Reset Node Identity.

Using the Encrypted Secret Vault

  1. Open 🔑 Secrets in the sidebar footer for global secrets (shared across all your instances) or ⋯ → Secrets in the top bar for instance-specific secrets/overrides.
  2. Add keys individually or expand Bulk import from .env snippet to paste multiple KEY=VALUE lines at once.
  3. Inside any shell in your playground:
    echo "$OPENAI_API_KEY"                  # injected into new shell environments
    cat /run/kernbox/secrets/OPENAI_API_KEY # live read-only RAM-only file (updates within ~1s)

Running Third-Party ARMv8.3+ Binaries (kernbox-compat)

unkernel's kwemu CPU emulator targets baseline ARMv8.0-A (plus FP, AdvSIMD, AES, PMULL, SHA, CRC32, and LSE atomics). Standard Alpine (apk) and Debian (apt) packages work out of the box, while some prebuilt third-party binaries compiled with ARMv8.3-A FEAT_LRCPC (ldapr) instructions (for example Google's Antigravity CLI agy) can trigger Illegal instruction (SIGILL).

Every Kernbox VM includes the built-in kernbox-compat command to rewrite LDAPR → LDAR safely in-place:

# Example: install & run Antigravity CLI on Alpine (use >= 1024 MiB RAM for extracting the 238 MB binary)
curl -fsSL https://antigravity.google/cli/install.sh | bash
kernbox-compat ~/.local/bin/agy && ~/.local/bin/agy install
agy --version

Local Development (Without Cloudron)

Requirements: Node.js >= 24 (for V8 WebAssembly JSPI support).

npm install
npm run prefetch-distros   # optional: caches Alpine locally into ./distros-cache
npm run build
npm start

Open http://localhost:3000. When CLOUDRON_OIDC_ISSUER is not set, Kernbox enables Local Dev Mode so you can sign in as different usernames (alice, bob, developer) to test multi-user isolation immediately.

npm run typecheck
npm run build
npm test

Security Model

  • Read-Only Root Filesystem: All runtime writes go strictly to DATA_DIR (/app/data) and /tmp.
  • Non-Root Container Process: start.sh drops privileges via gosu cloudron:cloudron before launching Node.js.
  • Per-User Isolation, Scoped Tokens & Encrypted Credentials: Every API route, file operation, secret vault entry, inter-VM mesh route (*.kernbox.local), port preview, MCP call, and WebSocket upgrade enforces authentication and strict per-user scoping with symlink-aware path traversal checks. API tokens are stored SHA-256 hashed and cannot read/modify secrets or mint new tokens; secrets, Tailscale credentials (tailscale.enc.json), and NetBird credentials/state (netbird.enc.json) are AES-256-GCM encrypted and excluded from clones and .kernbox.tar.gz exports.
  • CSWSH, CSRF & Preview/Share Sandbox Protection: Strict Origin validation on cookie-authenticated mutating HTTP requests and WebSocket upgrades; guest /preview/:id/:port/* and public /share/:token/* responses run in a Content-Security-Policy: sandbox opaque origin (without allow-same-origin) with cookies stripped.
  • SSRF Protection: Guest networking uses an internal loopback Wisp v1 relay (TCP + UDP) protected by a per-process 256-bit secret token, numerically blocking IPv4 & IPv6 private, loopback, metadata (169.254.169.254), NAT64, 6to4, and Cloudron-internal IP ranges before opening sockets — and applies the same SSRF checks to custom Tailscale/Headscale controlURL and NetBird managementURL endpoints.
  • Clean Shutdowns: Stopping an instance or receiving SIGTERM (e.g. before a Cloudron backup) calls vm.sync() followed by guest poweroff so ext4 overlays flush cleanly.

License

MIT — see LICENSE. Powered by unkernel (MIT AND GPL-2.0-only).

About

Multi-user personal Linux playgrounds for Cloudron, powered by unkernel

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages