feat(broker): let a confined worker start programs from /nix/store

Merged
KI
24d ago
+194-9

Problem

RFC 0008's open question: is the confined worker's default path list right? It allowed read, list, and execute beneath /usr, /lib, /lib64, /bin, and /sbin, plus a few single files, and had only been measured on CI's Ubuntu. This is the sixth item of M10 in the roadmap: run tests/broker_confined.rs on Debian, Fedora, Arch, Alpine (musl), and NixOS, on the runner's kernel.

Root cause

On Nix and NixOS, every program, its dynamic loader, and its libraries live in /nix/store, and /bin/sh links there. That directory was in no default rule, so exec of any program failed with EACCES and a confined worker could not start at all. The other four systems keep their loader and libraries beneath the default directories.

Change

  • A distros job in ci.yml, with one container per system, each pinned by digest:

    SystemImageToolchain
    Debian 13debian:13-slimDebian's rustc 1.85.1
    Fedora 45fedora:45Fedora's rust 1.99.1
    Archarchlinux:base-20261108.0.623074Arch's rust, current when the job runs (1.99.1 here)
    Alpine 3.24alpine:3.24.4Alpine's rust 1.96.1, which links against musl dynamically
    Nixnixos/nix:2.35.6nixpkgs nixos-26.05 at ac588ef (rustc 1.95.0)
    • .github/distros/setup.sh runs as root and installs the system's own toolchain. The tests then link the way its programs do: against its libc and through its loader. A rustup toolchain would hide that. Its musl target links statically, and on Nix it would use /lib64.
    • .github/distros/test.sh runs as the runner's user. It prints the loader and libraries the test executable and /bin/sh need, then runs cargo test --locked --test broker_confined with no --direct.
    • The workflows job shellchecks both scripts.
  • /nix/store is a default runtime directory for a confined worker, with read, list, and execute, and is skipped where it does not exist. A grant that overlaps it is now refused, as one that overlaps /usr is. The maintainer chose this over documenting --direct /nix/store:rlx.

Safety and compatibility

  • The worker can now read everything in /nix/store. The store holds build outputs, which every local user can already read, and opens there are not audited, as for /usr. A secret someone put in the store was already world-readable.
  • A grant inside /nix/store that gives READ or LIST now fails before the worker starts, where the store exists. The worker could read it directly.
  • Where /nix/store does not exist, nothing changes.

Verification

CI on 112acfe, before the change, with no --direct:

SystemDynamic loader/bin/shbroker_confined
Debian 13/lib64/ld-linux-x86-64.so.2dash47 passed, 2 ignored
Fedora 45/lib64/ld-linux-x86-64.so.2bash47 passed, 2 ignored
Arch/lib64/ld-linux-x86-64.so.2bash47 passed, 2 ignored
Alpine 3.24 (musl)/lib/ld-musl-x86_64.so.1busybox47 passed, 2 ignored
Nix/nix/store/…-glibc-2.42-103/lib/ld-linux-x86-64.so.2bash in /nix/store18 failed with "starting … failed: Permission denied", 29 passed

CI on 5eb744b, with /nix/store added: all five passed 47, with 2 ignored, and all 19 checks passed. The 2 ignored tests need a kernel without Landlock or below ABI v3, which the kernels job boots.

After merging main (#78, #84), all 20 checks passed on 74feb18, all five distros included.

The first run failed on Nix before any test, because test.sh used sed, which the image lacks; the toolchain now includes it.

Locally, on macOS 26.2 with Rust 1.99.1:

  • cargo fmt --all --check, cargo clippy --all-targets --locked -- -D warnings, and cargo clippy --locked --target x86_64-unknown-linux-gnu -p fsgate --all-targets -- -D warnings (a type-check, not a run): clean.
  • cargo test --locked: 121 passed.
  • actionlint 1.7.12 (with shellcheck 0.11.0), zizmor 1.32.0 offline, and shellcheck on both scripts: no findings.

Not verified:

  • A full NixOS system. The nixos/nix image has NixOS's store layout but not its /run/current-system or its services.
  • Guix, whose /gnu/store has the same shape and is not added.
  • arm64 containers, and kernels other than the runner's 7.0.
  • Programs that need more than a loader and libraries to start, such as locale or timezone data under /usr/share or /etc. The tests start the test executable and /bin/sh.
  • A pinned Arch toolchain. Arch packages are rolling, so the job installs whatever is current.
  • Docker's own confinement. Docker's default seccomp and AppArmor profiles stayed on and allowed Landlock, but the job does not test running without them.

Documentation and release

  • RFC 0008 lists /nix/store, answers its open question with the table above, and records the decision.
  • The README's confinement paragraph and status, the threat model's row for runtime paths, and the roadmap list it too. The roadmap ticks M10's sixth item.
  • CHANGELOG.md has an Unreleased entry under Changed.