# The app as an operating system — the full specification The detailed version of [The app as an operating system](./app-os.md), for auditors and security reviewers: each realm of a Witbitz app and what it holds and never holds, the protocol between the vault and the app, the Kernel and Atlas, storage and notifications on the device, the network limit per realm, and every known limit. > See also: [verifying the client](./client-architecture.md) (how anyone checks that the code in each realm is the > published code). --- ## The principle A Witbitz app is a static page, but inside the browser it is built the way an operating system is: separate realms, each holding one kind of thing, with walls the **browser** enforces — different origins, separate worker heaps — rather than the app's good behaviour. A bug or a malicious script in the part that draws the screen cannot reach the keys, because they are not in its realm. The principle is **least authority by information class**: keys, the room graph, and what is on screen live apart, so a compromise of one exposes only its own class. ## The realms {#realms} | Realm | Like, in an OS | Holds | Never holds | |---|---|---|---| | **The vault** — its own origin, the top frame | the trusted shell and login | the account, the room keys, sign-in, recovery, the device lock | what the app draws | | **The Kernel** — a Web Worker | the kernel | every room key in use, and all the cryptography: opening, sealing, signing | the screen | | **The app** — a separate origin, framed by the vault | a user process | what it renders | the account or the room keys at rest | | **The service worker** | the package manager | the app's builds: which release runs, downloaded whole before a switch (in the hosted app the vault keeps the code itself, by hash) | room content | **Why origins, not discipline.** One origin can intend to keep its keys away from its drawing code, but nothing enforces it — any script on that origin can read its storage. Putting the vault on its own origin makes the boundary the browser's same-origin policy: the app frame cannot read the vault's storage, and the vault cannot be framed by anyone. ## Easier to audit {#audit} The structure also shrinks what a reviewer has to read closely. In an ordinary web app any of its code can read the keys, so an audit has to cover all of it, on every release. In the hosted app only the vault and the Kernel touch keys — the trusted core, kept small and changed rarely. The app frame, which is most of the code and changes most often, is checked for what it shows, not for what it could leak: the browser does not let it reach a key. It is the same reason an operating system's kernel gets audited instead of every program: the guarantees rest on the small part. And because every file in every realm is pinned and logged ([verifying the client](./client-architecture.md)), the audit applies to exactly the code that runs. ## The vault {#the-vault} The vault is the top frame. It holds the account and its room keys, runs every ceremony that touches them — sign-in, recovery, the device lock — and frames the app with **no key in the URL and none in the app's storage**. The two talk over a small `postMessage` protocol, pinned to each other's exact origin in both directions. The app asks for what it needs — open this room, run this turn — and the vault answers; it never hands over the account. The vault also keeps what the app frame cannot: on iPhone the system drops a framed page's storage on every relaunch, so everything the app stores goes to the vault — the frame's local storage is a working copy refreshed from the vault and written through to it, and its database calls go to the vault's. The vault keeps the app's code as well, by hash; the app's loader checks each file against the signed release before it runs it, so the vault is a store, not trusted ([verifying the client](./client-architecture.md)). ## The Kernel {#the-kernel} The Kernel is a Web Worker — a separate JavaScript heap with no access to the page's objects — that holds the keys in use and does all the room cryptography. The app sends it **requests**, not keys: poll this room, send this turn, read this state, seal this record. The Kernel opens what comes back, signs what goes out, and makes the request itself. In the hosted app the Kernel runs **inside the vault's origin**: the app frame requests ordinary room cryptography through a channel to it. The attested chat-cache key is a separate in-memory exception described under storage. In the regular app, which has no vault, the Kernel runs in the app's own origin. The Kernel hands a key out only where the action is about the key, and in the hosted app not to the frame: sharing a room — its link, an invite by email or `@username`, handing it to your cloud device — is built and done by the vault itself, so the link never reaches the app frame. ## Atlas — the room graph {#atlas} The account's own records — which rooms you are in, their names, which private assistant belongs to which Space — are the room **graph**. They are stored in sealed account rooms whose entries also carry each room's key. **Atlas** keeps those apart. When the account's index is read, the Kernel takes the keys out and the app receives a **keyless** graph; when the app writes the index, the Kernel puts the keys back. The app can list your rooms — it is the file browser, and may see the directory listing — but it never holds the keys that open them. ## The account The vault is where the account lives: the master secret every account key comes from, the sealed room list, and the recovery code that, with a check of the account's email, brings the account back on a new device. How an account is made, synced across devices, backed up and recovered — and what Witbitz can and cannot see of it: [accounts and recovery](./accounts.md). ## Storage on the device {#storage} Each realm's storage can be **sealed on the device**: with device protection on, every key and every cached message is ciphertext at rest under a key the device's passkey derives, opened into memory only after an unlock and dropped at the next lock. Off by default on a phone; on a computer it is the first step of setting up ("Secure this computer"), and the Witbitz apps for the Mac and Linux keep that key in the system's keychain or keyring. See [privacy tiers](./privacy-tiers.md). **Notifications** get their own one-way key, derived from the room key, so the service worker can show a short preview without holding the room key itself. **Attested chat caches** use an additional AES-GCM seal bound to the room id (`attestedCache.js`). Its 32-byte `ck` comes from that kind's attested backup; the usable key is held in the app frame's memory, not persisted in cleartext. This cache key is distinct from the account and room keys. Reading the cache also requires the room key to be ready. The ordinary attested backup is restored first; confidential attested rooms are merged as their separate backup arrives. On a bare launch, an unavailable last-room key no longer blocks the initial list. Explicit links and room taps retain their key checks. A fresh launch therefore still needs backup restoration before it can open these cached messages. ## Network {#network} Each realm reaches the network only under its own **Content Security Policy**: the app frame, the vault and the Kernel can each reach only the hosts their published policy lists. There is no single gateway; the limit is per realm, enforced by the browser. ## Build your own The SDK's **vault mode** gives your app the same structure with your own vault: you host the vault and the page, Witbitz hosts neither, and secrets stay in the vault's screens — [vault mode in the SDK](./sdk-keys.md#vault-mode). ## Limits {#limits} - **A worker is a separate heap, not separate memory.** The Kernel's wall is as strong as what crosses it: no shared memory, no key returned except for the actions above. - **The app sees your room list.** Names and structure are visible to the app frame; only the keys are confined. A separate Atlas worker that would hide the graph from the app too is designed, not built. - **Frames that say they are older.** The vault still hands room keys to a hosted frame that says it is from a release older than the keyless ones, which cannot work without them — and a frame that only claims to be old is given them too. A frame of a current release asks for none. - **The regular app has no vault.** Its Kernel and screen share one origin, and the page itself also holds room keys. The hosted app is the one where the screen of a current release holds no key. - **The regular app's service worker** can still fall back to a room key on the device to show a notification; the hosted app's never holds one. ## Read next - [The app as an operating system](./app-os.md) (the short version) · [Verifying the client](./client-architecture.md) · [Vault mode in the SDK](./sdk-keys.md#vault-mode) · [Privacy tiers](./privacy-tiers.md) · [Trust model](./trust-model.md)