The security model

A privileged process runs only code the distribution has signed, cannot make code at run time, and is held to what its program declares. One kernel security module enforces it.

Who it applies to

The rules concern privileged processes only: any process with a user id of 0, or with any capability, in the initial user namespace. Ordinary users are not affected; ordinary Unix permissions already confine them.

Seals

Every packaged file that is not configuration is sealed when it is installed:

  • fs-verity makes its contents immutable and gives the kernel a digest of them;
  • an extended attribute, security.joe, carries a signature over that digest together with the operations the package declares for the file.

The public half of the signing key is compiled into joe’s kernel. A sealed file can be replaced or deleted, never modified in place. dave install-system seals files as it installs them; an image made by other means seals itself on its first start (dave-seal.service).

The three rules

  1. Sealed code only. The program, every library it maps, every kernel module it loads and every script it runs must be sealed. bash and Python ask the module before they read a script file. Commands typed at a prompt and -c strings are not files, and are allowed.
  2. No code made at run time. No anonymous executable memory, no writable executable mappings, no making modified memory executable. A just-in-time compiler cannot work under these rules, so none can run as root. A debugger cannot write another process’s executable pages either: ptrace, process-vm and /proc/PID/mem writes are covered as well as mmap and mprotect.
  3. Declared operations. A recipe states what its privileged programs do: which capabilities they use, whether they use the network, where they write and what they run. The declaration is part of what is signed, and the module refuses the rest.

Declarations

A declaration in a recipe’s package.zon names programs and what they may do:

.operations = .{
    .{
        .programs = .{ "usr/bin/mount", "usr/bin/umount" },
        .allow = .{ "mount", "cap:sys_admin", "write:/etc/mtab" },
    },
},

The words a declaration may use:

Word Allows
all everything
net the network
mount mounting file systems
module loading kernel modules
ptrace tracing other processes
bpf BPF
root-ipc signals and SysV IPC between root processes
cap:NAME, cap:* one capability, such as cap:sys_admin, or any
write:PATH, write:* writing under an absolute path, or anywhere
exec:PATH, exec:* running a program, or any
none nothing: an explicit empty declaration

A program no declaration covers is sealed undeclared. Run by a caller that holds all, it receives all; otherwise it is reported, and refused when the module enforces. Global root stays confined when it creates a user namespace. A process whose only global privilege is its capability set cannot create one, because replacing that set would discard its confinement.

What is declared today

The programs where privilege starts declare all: systemd’s PID 1 and the executor that starts every service, root’s bash, the programs that start another user’s shell (doas, su, pkexec, ksu), root’s sftp-server, dave, mount, and the programs the kernel itself starts (modprobe, systemd-coredump, request-key).

Every other service and set-uid program the desktop runs with privilege declares its own operations, taken from the capabilities its upstream unit bounds it to and from what it was seen to do in log mode: the systemd daemons (journald, logind, udevd and the helpers its rules run, userdbd, nsresourced, networkd, resolved, timesyncd, hostnamed, localed, timedated), D-Bus, NetworkManager and wpa_supplicant, ModemManager, accounts-daemon and shadow’s account tools, udisks and the file system tools it runs, upower, gdm and its session worker, bluetoothd, geoclue, avahi, cups, sshd, agetty and login, and the set-uid tools (passwd and its kin, newuidmap, ping, fusermount3, unix_chkpwd, the polkit agent’s helper). NetworkManager, for one, may use the network, load modules and write /etc and its state, and nothing else.

true and false declare none. Everything else is undeclared, so it acts with the authority of the shell or service that runs it. The desktop, a fresh installation and its first boot are tested enforcing, and those tests fail on anything refused. The services of the rest of the repository are not declared yet.

dave repo audit lists the undeclared programs in a repository, and any seal that is invalid or missing.

Logging and enforcing

The module logs what it would refuse unless the kernel is started with joe=enforce on its command line. The installer offers that as a choice, Enforce the security module, which is off unless you tick it (dave install-system --enforce). Writing 1 to /sys/kernel/security/joe/enforce switches a running system to enforcing; nothing switches it back. The live medium always runs in log mode, because nothing on it is sealed.

One consequence worth knowing: a root shell does not read /etc/profile or ~/.bashrc, because files you can edit are not sealed.

What it does not cover yet

Kernel modules are checked by the module but not by the kernel’s own signature enforcement. There is no kernel lockdown and no Secure Boot, so root can still replace the kernel or its command line. There is no way yet to sign software built on the machine, and interpreters other than bash and Python (awk, sed, perl) do not ask before running a script.

The details are in the source, which is commented for readers: joe.c for the module and seal.zig for the seals.