scrotwmos

scrotwmos security

This is the security record of scrotwmos as the code is today. It says what each part protects, how, with which keys, and where the code is. It ends with what is not protected.

Code locations are a path and a function name. A path alone means a whole file, a build rule or a kernel config fragment.

The feature list is in features.md. The appliance is described in appliance-os.md.

1. Threat model and trust boundaries

1.1 What scrotwmos defends against

1.2 What scrotwmos does not defend against

1.3 Trust boundaries

Boundary Trusted side Untrusted side Mechanism
Disk at rest the running box a disk off the box dm-crypt, sealed blobs, keys.wrap
Boot image the release key the ESP Ed25519 signature, AEAD seal
Monitor and compositor root monitor (PID 1) compositor as _swm fork before any parsing, request table
dom0 and a container dom0 kernel and monitor the container’s programs namespaces, capability drop, seccomp, cgroups
dom0 and a VM dom0 and the VMM sandbox the guest KVM, VMM seccomp, empty root, IOMMU
Session and session dom0 each session separate uids, compositors, clipboards, networks
Session and network the net VM router each session port nftables, layer 2 switch, VLAN tags
dom0 and the NICs dom0 NIC hardware and the network net VM owns the NICs by VFIO
dom0 and USB dom0 devices plugged in later USB authorization off, device stamps
Box and backup place the box NAS, SMB or USB place ciphertext copies, sealed manifests

The trusted computing base on the appliance is: the firmware, the loader swmstub.efi, the dom0 kernel, and the root monitor in swm-wl. The compositor is trusted with the screen and the keyboard, but not with root.

2. Asset table

Asset Protection Algorithm and parameters Key origin Code
World master (32 bytes) wrapped in a keys.wrap slot bcrypt_pbkdf(username, password, 16-byte salt, 16 rounds) to a 32-byte KEK; XSalsa20-Poly1305; container id as associated data getentropy at install lib/libkeys/keys.c keys_slot_kek(), keys_unwrap(); lib/libkeys/keys_admin.c keys_slot_add()
World master, byol TPM path wrapped under a TPM-sealed KEK XSalsa20-Poly1305; TPM 2.0 keyedhash, PolicyPCR over PCRs 4, 7, 8 (SHA-256) getentropy at preboot tpm on lib/libkeys/keys_admin.c keys_slot_add_tpm(); installer/tpm.c tpm_seal()
dom0 boot image sealed and signed XSalsa20-Poly1305 under a per-blob key; Ed25519 over SHA-512 of the header; header holds SHA-512 of the image master; release key lib/libkeys/keys.c keys_blob_open(), keys_image_accept()
World config sealed XSalsa20-Poly1305 under a per-blob key master lib/libkeys/keys.c keys_config_parse()
swmdata disk key (64 bytes) sealed on the ESP per world XSalsa20-Poly1305; the disk uses AES-XTS-512 getentropy at install; one key for all worlds installer/provision.c luks_make(); lib/libsession/monitor_keys.c monitor_keys_take_disk_key()
Root, VM disk, kernel store images derived key, never stored SHA-512(master, label, image name) to 64 bytes; AES-XTS-512 master lib/libkeys/keys.c keys_data_key()
Home image key (64 bytes) sealed on the ESP and in the place header XSalsa20-Poly1305; AES-XTS-512 on the image getentropy at install lib/libsession/monitor_keys.c monitor_keys_home_key()
Share image key sealed in the store XSalsa20-Poly1305; AES-XTS-512 getentropy at install lib/libsession/monitor_keys.c monitor_keys_share()
Swap key (64 bytes) never stored: in the monitor’s memory until the swap is mapped, then wiped plain dm-crypt AES-XTS-512 getentropy each boot lib/libsession/privsep.c monitor_swap_map()
Machine firmware archive sealed on the ESP XSalsa20-Poly1305 under a key from the disk key and the archive digest; digest pinned in the world config disk key lib/libkeys/keys.c keys_firmware_master()
ESP twin none of its own: a copy of the ESP as the ESP’s files as the ESP’s installer/appliance.c appliance_esp_close()
Boot handoff channel only plaintext in memory; wiped after use loader bin/swmstub/unlock.c handoff_offer(); lib/libsession/monitor_keys.c monitor_keys_ingest()
Screen-unlock verifier slow hash bcrypt_pbkdf(password, salt from the master, 16 rounds) to 32 bytes; constant-time compare computed by the loader lib/libkeys/keys.c keys_screen_hash(), keys_screen_verify()
Backup place header password slot plus sealed part one keys.wrap slot, empty username, 64 rounds; XSalsa20-Poly1305 random place master lib/libkeys/keys_place.c keys_place_header(), keys_place_open()
Backup copies already ciphertext the home image’s XTS sectors home key lib/libsession/mon_place.c copy()
Copy manifests and pins sealed, chunk hashes XSalsa20-Poly1305; SHA-512 per 1 to 16 MiB chunk place manifest key lib/libkeys/keys_place.c keys_manifest_build(), keys_pins_seal()
Recovery phrase key (16 bytes) derived, never stored; shown as 12 words SHA-512(master, label) cut to 16 bytes; a 4-bit checksum, the first four bits of the key’s SHA-256 (BIP-39’s) master lib/libkeys/keys.c keys_phrase_key(); lib/libkeys/keys_phrase.c keys_phrase_words(), keys_phrase_parse(), keys_phrase_canon()
World file sealed on the place, two copies XSalsa20-Poly1305: the master under a key from the home key and under the phrase key; the body under the master master, home key lib/libkeys/keys_place.c keys_world_seal(), keys_world_open(); lib/libsession/monitor_keys.c monitor_keys_world_seal()
World record (place, SMB credentials, Wi-Fi, settings) sealed in the store XSalsa20-Poly1305 master lib/libsession/monitor_keys.c monitor_keys_rec_write()
GPU and NIC records sealed in the store XSalsa20-Poly1305 master lib/libsession/monitor_keys.c monitor_keys_gpu_rec(), monitor_keys_nic_rec()
Wi-Fi WPA2 key derived PBKDF2-HMAC-SHA1, 4096 rounds, SSID salt passphrase in the world record lib/libkeys/keys_place.c keys_wifi_pmk()
Installer kernel signed Ed25519, same format as the dom0 image installer key bin/swmstub/swminstall.c efi_main()
VM kernels signed index plus digests signify (Ed25519) over the index; SHA-256 per blob kernel key lib/libsession/kernel_blob.c kernel_blob_resolve()
byol root LUKS2 argon2id, 5 s iteration time; AES-XTS-512; a second keyslot for the disk key at PBKDF2 1000 user passphrase; random disk key installer/plan.c plan_steps(); installer/preboot.c preboot_make()
byol root header copy off the box, on the owner’s media; no password keyslot the LUKS2 header with the disk key’s PBKDF2 keyslot alone random disk key installer/swmtool.8 (preboot passwd); installer/preboot.c disk_key()
byol swap plain dm-crypt AES-XTS-512, a new random key each boot /dev/urandom installer/plan.c plan_steps()

3. Encryption

3.1 Primitives

3.2 Key hierarchy (appliance)

username + password --bcrypt_pbkdf--> KEK --AEAD--> master (one per world)
master --SHA-512 labels--> blob names, blob keys, image keys,
                           time-travel names, screen salt,
                           recovery phrase key
master --sealed ESP blobs--> disk key, home key, world config, boot image
master --sealed store blobs--> share key, world record,
                               GPU and NIC records
disk key --> swmdata (layer 1); firmware blob key
getentropy, each boot --> swap key (never stored)
home key or phrase key --world file on the place--> master

A world is a master. An A/B world has two keys.wrap slots on one master: two usernames, two boot images, two configs, one root and one home. The rescue and decoy worlds are ordinary password slots.

Deniability is plausible, not cryptographic. All password slots look the same. The file name of each blob is a hash under its master, so no file names a world. But the number of live slots is visible, and swmdata and every image carry a visible LUKS2 header. lib/libkeys/keys.h (header comment).

Decided:

3.3 keys.wrap

3.4 Boot blobs and the world config

3.5 Boot handoff and keys in dom0

3.6 Disk layers

The appliance disk is GPT: the ESP (the loader, keys.wrap, and the sealed blobs, all that the firmware must read in clear), an optional swap, swmdata, and, last, the ESP’s twin.

Decided: two layers of dm-crypt. swmdata is layer 1, for offline opacity, and every world opens it. Each session’s root, home, and disk are layer-2 images on swmdata, under keys only its world’s master gives, so a decoy that opens the disk cannot open another world’s images. fscrypt was rejected: it shows the directory tree, counts, sizes, and times to a booted decoy, and it serves containers only. Image names are random and never reused, because a name derives its image’s key.

All dm-crypt mappings in dom0 are made by ioctl on loop and device-mapper devices. dom0 has no cryptsetup. Key-bearing ioctls carry DM_SECURE_DATA_FLAG, and the key’s hex form is wiped after use. lib/libsession/dmcrypt.c dmcrypt_open(), dm_load().

Layer What Cipher Key Lifetime Code
swmdata the data partition LUKS2 format, opened as raw aes-xts-plain64, 512-bit key, 4096-byte sectors, data at 16 MiB disk key, random, one for all worlds life of the box installer/provision.c luks_make(); lib/libsession/privsep.c monitor_disks_open()
root image a world’s root file system aes-xts-plain64, 512-bit keys_data_key(master, label) life of the image lib/libsession/privsep.c monitor_image_setup()
VM disk, kernel store a VM’s disk, the world’s VM kernels aes-xts-plain64, 512-bit keys_data_key(master, label) life of the image lib/libsession/monitor_keys.c monitor_keys_session_key(), monitor_keys_kernels()
home image a world’s or session’s home aes-xts-plain64, 512-bit random home key, sealed life of the world lib/libsession/monitor_keys.c monitor_keys_home_key()
share image a world’s share aes-xts-plain64, 512-bit random share key, sealed in the store life of the world lib/libsession/privsep.c monitor_share_blob()
swap the swap partition plain dm-crypt aes-xts-plain64, 512-bit random, made by the monitor each boot and never stored; every world alike, rescue and the decoy too one boot lib/libsession/privsep.c monitor_swap_map(); lib/libsession/swap_part.c swap_hdr_make()

3.7 Lock screen

3.8 Backup places

3.9 Other secrets

3.10 byol

4. Signatures

4.1 Signed objects

Object Signer key Algorithm Signed by (build) Verified by (code) On failure
dom0.signed (dom0 kernel image) release Ed25519 over SHA-512 of a 120-byte header; header holds arch, version, date, handoff version, key number and the image’s SHA-512 make release, swmtool release sign -r loader: bin/swmstub/swmstub.c efi_main() via keys_image_accept(); installer: installer/provision.c provision_image_bad(); update: installer/upgrade.c upgrade_boot() loader prints an error and halts; swmtool refuses
swmstub.signed (the loader) release same, handoff 0 make release installer/upgrade.c upgrade_stub_bad() update refuses the new loader
installer.signed (installer kernel) installer same, handoff 0 make release, swmtool release sign -i bin/swmstub/swminstall.c efi_main() the media loader halts
VM kernel index kernel signify (Ed25519) over the index; each line names a flavor, version, SHA-256 and file make kernel lib/libsession/kernel_blob.c kernel_blob_resolve(); installer/kernels.c index_read(), cmd_kernel_verify() the VM does not start; install lays no blob
Void packages Void’s repository keys RSA (xbps) upstream xbps xbps refuses

4.2 How a check works

4.3 Key custody and test keys

5. TPM and measured boot

The appliance measures its boot; the TPM holds no key. The installer refuses tpm for a dom0 install. installer/answer.c answer_parse(). The TPM seals only the optional TOTP codes.

On byol:

6. Isolation

6.1 Privilege separation in dom0

Operation What root does Checks in the monitor
CREATE starts a container or VM magic, version, a 64 KiB string table, exact counts; the uid is forced to the session uid; seccomp is forced on; GPU use is forced by session kind; the rescue session only as the sealed config says; image, home, uid and share must match the sealed config; root paths only under the store; no trunk or gfx launch; uid rules (handle_create(), helper_validate(), session_pin_ok(), session_uid_ok())
DESTROY stops a session name grammar, a capped timeout
SCREEN_VERIFY checks the lock password throttle; the answer is match or deny only
TMSET, TMSTATUS, TM_LIST points on or off, delete, mount, unmount, take one now, consolidate, look, make a place shape checks; mount and look refused for VM images (tt_set())
SETTINGS writes the world’s input settings record checks
WIFI saved networks, add, forget, choose record checks; at most 3 keys per scan cycle
GPUAPPROVE, GPUREVOKE, GPU_ROMS records or removes a ROM approval the card must be at the address, with matching ids, held for a ROM reason
NIC_MEASURE measures a NIC in a scratch VM address and state checks
DEVICE USB take, check, scan, accept, kept only inside a time window (6.6)
SLEEP suspend to RAM none
status and log reads fixed records none

6.2 Container tier

Path: lib/libsession/privsep.c handle_create(), then lib/libsession/session.c session_launch(), child_setup(), setup_rootfs(), setup_rootfs_inner(), child_exec().

6.3 VM tier

6.4 Network filtering

6.5 IOMMU and VFIO

6.6 USB and input

6.7 Clipboard

There is no path for clipboard data between sessions. Each session’s compositor has its own selection. The bus carries only a sync flag. dom0 has no data-control protocol, and refuses selection changes while locked. bin/swm-wl/wl_clip.c, bin/swm-wl/wl_clip.h.

6.8 GPU

6.9 dom0 attack surface

Input Parsed by Privilege Checks
Session bus messages compositor _swm, dom0 filter exact length per type, direction, field bounds; shared memory must be sealed against shrink
dma-buf frames compositor _swm import checks
Wayland socket compositor _swm, directory 0700 only _swm and root reach it; dom0 runs no clients
Seat socket monitor root compositor pid only; path and device class checks
Monitor channels monitor root 6.1
Kernel uevents monitor root relayed only inside windows
DHCP packets DHCP engine own uid, sandbox 6.4
Net VM records compositor, then monitor _swm, root fixed records; time judged
Backup VM wire monitor children root magic, length cap, exact size per command
Place headers and manifests monitor children root; the copy child is under seccomp exact sizes, rounds pinned, AEAD
Point file systems dom0 kernel root child only container homes, which dom0’s kernel wrote; VM homes are never mounted in dom0
Guest virtio, FUSE, PCI swm-vmm session uid, sandbox 6.3
GPU command streams vmm-gfx own uid, filter 6.8
ESP keymap compositor _swm none (section 7)
Sealed config PID 1 before the fork root AEAD under the master

6.10 No daemons in dom0

6.11 Time travel processes

Step Process uid Confinement
Point (reflink clone) monitor child root descriptors closed
Copy to a place monitor child root no-new-privs and a filter with no open, no exec, no executable mappings
Backup VM swm-vmm backup uid the VMM sandbox (6.3)
swm-tt in ttvm guest PID 1 guest root the place mounted nosuid, nodev, noexec
Anchor, rewrap, open, look, list monitor children root look and list read as the session’s uid

6.12 Installer

6.13 byol VMs (swmtool vm)

byol only: dom0 has no qemu. These VMs are not sessions. They have no workspace, no swm-vmm sandbox and no signed kernel.

6.14 byol containers (swmtool ct)

byol only. A container’s root is uid 0 of its own user namespace, over a range of ids no account has; the design and its limits are in doc/design-byol-containers.md.

7. Known limitations

These are not protected by the code today.

Boot and keys

Disk and data

Isolation

Network

USB and input