How dohc isolates workspace apps and bounds their data access

dohc runs personal and shared web apps inside five narrow boundaries instead of giving app code workspace or OS privileges. A closed compiler bundles declared files without running app code, and published frontends run in opaque-origin sandboxed srcdoc iframes over a MessageChannel broker. Custom SQLite operations run inside per-call QuickJS Wasm instances behind a SQL authorizer, immutable approvals and dual-reach caps gate data access, and workspace secrets stay write-only outside the workspace folder.

This page describes what ships today and where each boundary stops. For full implementation references, see App compiler containment, Security boundaries, and the app backend runtime README.

Five isolation layers at a glance

LayerMechanismWhat it blocksKnown boundary limit
Build (apps/desktop, crates/dohc-compiler-owner)Closed esbuild bundle against SHA-256-pinned React 19 and @dohc/app-kit; Seatbelt on macOS, Landlock + seccomp on Linux, Job Object on WindowsArbitrary package.json scripts, node_modules, build hooks, app-provided plugins, computed imports, compiler network/file egress on macOS and LinuxWindows Job Object enforces memory and process ceilings (owner enforces 60 s wall-clock deadline) with no OS file or network isolation; macOS and Linux memory/process caps sample every 10 ms
Browser frontend (services/share-web, apps/mobile)Sandboxed srcdoc iframe with opaque origin, strict CSP, and typed MessageChannel broker (dohc/app)Same-origin access to viewer cookies or credentials, top-level navigation, nested frames, form posts, workers, camera/mic/locationFrontends can still make ordinary browser network requests with data they already received; withdrawal stops future dohc reads and writes, not an open tab's external traffic
Collection operations (packages/app-backend-runtime)Fresh quickjs-emscripten@0.32.0 Wasm instance per call (24 MiB default memory) inside a child process + SQLite authorizer + host-committed journalAccess to filesystem, network, host environment, undeclared SQL tables, transaction control, schema edits, and unsafe SQL functionsNo OS filesystem sandbox around the child process itself; confinement rests on Wasm and explicit host callbacks
Capabilities and workspace files (packages/security-contract, crates/dohc-engine-files)Immutable Owner-approved publications, four-cap Member apps, protected .env path floorUndeclared Collection reads/writes, agent self-approval of Member apps, .env leakage to shares, apps, or dohc agent toolsCollection-create form responses are ordinary shared Markdown files; private responses require a dataset with explicitly authorized reads
Secrets and outside HTTPS (packages/service-http)Write-only secrets outside the workspace folder + Owner-approved external operations in app.publish.json + safeOutboundHttpsRaw secrets entering bundles, app frames, renderer, CLI, MCP, or echoed responses; SSRF to private/loopback/non-global IPsHosted relays still need host or network egress isolation, because IP classification cannot tell whether a public-looking IP routes internally

1. Closed app build and OS containment

When dohc builds a workspace app for local launch or publishing, the desktop captures only the files declared by the app and passes their bytes to one compiler worker per build. The worker parses them with acorn and parse5 and bundles them with esbuild. It refuses package.json, tsconfig, node_modules, and computed imports; esbuild writes nothing to disk, and no app code, build hooks, or app-provided plugins run.

Every allowed import resolves either to a captured app file or to a pre-bundled module in the built-in app kit (react, react/jsx-runtime, react-dom, react-dom/client, dohc/app, dohc/ui, dohc/charts, dohc/icons, dohc/money, and dohc/csv). Staging embeds the SHA-256 of each built-in file into the compiler adapter and worker. When a build runs, both verify every loaded built-in against those embedded hashes before compiling and fold the combined digest into the compiler identity. The prefixes react, react-dom, scheduler, and dohc are reserved and cannot be remapped through packageMap.

Hostile or malformed source can still make parsing expensive (an unbounded 60 MB single-file input reached 7.2 GB on an Apple M2), and a memory-safety bug in V8 or esbuild could execute code inside the compiler worker. Each platform bounds the compiler owner process differently:

BoundWindows x64 (windowsCompilerOwner.cs)macOS Apple silicon, 13.5+ (crates/dohc-compiler-owner)Linux x64, kernel 5.13+ (crates/dohc-compiler-owner)
Wall-clock time60 s owner wall-clock deadline60 s owner deadline (per-process RLIMIT_CPU backstop of 61 CPU s multiplied by available parallelism)60 s owner deadline (per-process RLIMIT_CPU backstop of 61 CPU s multiplied by available parallelism)
Memory1 GiB committed memory ceiling on the Job Object (hard failure past limit)1 GiB summed physical footprint across tracked tree, sampled every 10 ms1 GiB summed anonymous + shared resident memory across tracked tree, sampled every 10 ms (mapped pages only)
Processes8 active processes ceiling on the Job Object (hard spawn failure past limit)8 live processes sampled every 10 ms (plus 1,024 live-process and zombie guard)8 live processes sampled every 10 ms (plus 1,024 thread and zombie guard)
TeardownKill-on-close Job Object handleStdin EOF kills tracked tree; supervisor falls back to process group killChild subreaper adopts orphans and kills tree; worker dies when owner dies
Files and networkNo OS file or network isolation; supervisor scrubs environmentDeny-by-default Seatbelt profile: no network, no Mach services, read-only compiler/OS libs, non-executable build folderLandlock (ABI 1+ required; stronger rights on newer kernels) + seccomp denying socket, signals, io_uring, clone3, x32, mount listing, inotify, tracing, and syscalls newer than Linux 6.17

Because macOS and Linux sample memory and process counts every 10 ms, they act as detection thresholds rather than hard ceilings. Measured on an Apple M2, a real compile passed 1 GiB by 24 to 43 MB, a separate allocator touching 14.4 GB/s passed 1 GiB by 33 to 67 MB, and a spawn loop reached 9 to 12 processes against a bound of 8. Both Seatbelt and Landlock leave path metadata readable so Node can start, meaning a compromised worker could check whether a path exists without listing directories or reading file contents.

Each OS sandbox also carries platform-specific escapes that require a V8 or esbuild memory-safety exploit first:

See Desktop capabilities and requirements for supported architectures and platform requirements.

2. Opaque-origin iframes and the MessageChannel broker

Published apps run inside a sandboxed srcdoc iframe hosted on a per-launch origin, with no same-origin access to viewer cookies or credentials and no top-level navigation. Server CSP headers disallow nested frames, form posts, and web workers inside the app, and the permissions policy denies camera, microphone, and location. On phones, iOS runs the app in an incognito react-native-webview process and Android uses dohc's native app-web-view refusal rules (on Android, the app shares Chromium's web renderer process with the page editor, so browser rules separate them rather than an OS process boundary).

The frontend reaches workspace data only through the MessageChannel client in dohc/app, which forwards operation names and typed inputs to the broker. The broker enforces the publication's approved operations and current caller grant on every call. Local desktop static previews run in the Electron session, so the main process attaches a per-launch secret header only to top-level window dohc-file:// requests and refuses any request without it; preview frames and workers never receive that header.

3. Per-call QuickJS Wasm and host-committed SQLite

Transactional Collections back apps with structured SQLite storage and custom JavaScript operations (see Build an app connected to a Collection). Rather than running authored JavaScript inside the desktop main process or sync relay, dohc evaluates each operation synchronously inside a fresh quickjs-emscripten@0.32.0 Wasm instance with its own fixed memory (24 MiB default; minimum 16 MiB) inside an isolated child process. The guest receives no filesystem, network, module loader, or host environment. It sees only frozen input, frozen verified caller metadata, trusted nowMs/requestId/secret, db.query, db.execute, files.attach, localDate, and refuse.

SQLite runs behind an explicit authorizer that permits only the Collection's declared tables (plus json_each and json_tree table-valued functions) and refuses transaction control, schema edits, attached databases, and file or extension functions. Memory limits inside SQLite depend on how the host runtime links SQLite:

The worker never owns commit authority. On a write, the host calls prepare inside an open transaction, rechecks caller authority, durably appends the changeset, attachments, and retry receipt to its journal, and only then calls finalize. Recovery and replication replay committed SQLite changesets without re-executing authored JavaScript.

4. Official publications, Member apps, and protected .env files

An app manifest (app.publish.json) only requests capabilities. Official Workspace Publications and share-link apps require an immutable Owner approval before they run for viewers; changing source files, dependencies, or declared capabilities changes the candidate digest and requires a new Owner review.

Member apps follow a separate path so teammates can share internal tools without blocking on the workspace Owner. When an Owner or Admin turns on "Members can share apps", a Member or Admin can publish a Personal app without waiting for Owner approval and without touching the synced workspace tree:

Across the workspace, .env, .env.*, *.env, and everything under .env/ are protected paths (except templates .env.example, .env.template, and .env.sample). The Rust engine encrypts its stored records for protected files under .dohc/engine/secret.key and excludes them from shares, app publications, search results, and dohc agent tools. Working .env files on disk and retained copies in .dohc/local stay plaintext on the owner's computer (on Windows, .dohc/local and staged or newly written protected files get user-private DACLs, while existing working .env files keep their existing DACLs).

5. Write-only workspace secrets and declared outside HTTPS

Workspace secrets used by apps and automations live outside the workspace folder so copying the directory, running file-based agents inside it, or calling dohc CLI and MCP APIs never exposes credentials. Secrets can only be added, replaced, or deleted in Desktop Settings, and saved values never return to the renderer.

Each http-header secret is pinned to 1 to 10 exact lowercase public hostnames. An app sends a host-executed request carrying a workspace secret only through a named operation in app.publish.json's external map approved by the workspace Owner in Desktop (refused via CLI, MCP, Personal apps, and Member apps). Typed app inputs fill only whole path segments (rejecting /, ., and ..), query values, or body values, never hosts or headers.

Each call first resolves and validates the destination through safeOutboundHttps: HTTPS on port 443 only, no URL credentials or IP literals, no .local, .internal, .localhost, or .home.arpa hosts, and cancellable DNS A/AAAA resolution (2 s timeout) rejecting private, loopback, link-local, carrier-grade NAT, multicast, and non-global IPs. Right before sending, the app external executor verifies caller authorization alongside the secret's http-header usage, allowed host, and (on the relay) pinned approval binding, attaches the secret, and sends the request over safeOutboundHttps with TLS verification pinned to the resolved IP and canonical hostname and redirects disabled. On its own, safeOutboundHttps defaults to a 10 s request timeout (capped at 30 s); the app external executor applies a 10 s HTTPS request timeout (separate from the preceding DNS and pre-send checks), caps responses at up to 192 KiB of uncompressed UTF-8 JSON, and refuses any response that echoes the secret in raw, JSON-escaped, URL-encoded, or decoded form.

What this design does not promise

These limits stay outside the boundaries above:

To inspect real apps built on these boundaries, browse the runnable workspace examples or read Build an app connected to a Collection.