Skip to content

linux: NixOS/Linux port — sudoers boundary, Nix module, VM test - #7

Merged
djbclark merged 10 commits into
sudo-mainfrom
linux-port
Oct 29, 2026
Merged

djbclark merged 10 commits into
sudo-mainfrom
linux-port

Conversation

@djbclark

@djbclark djbclark commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Ports sudo-secretspec to Linux/NixOS with the same privilege boundary the macOS install enforces: an unprivileged service user owns the vault, and a narrowly-granted sudo broker is the only path to read, add or restore secrets. No Linux Homebrew, no Touch ID — anything that relies on launchd is documented and refused (see "Non-goals").

What's in this PR

  • Per-platform paths & identity (platform.rs, config.rs): Linux vault dir /var/lib/<svc>/sudo-secretspec, CLIENT_PATH under /run/current-system/sw, SERVICE_IDENTITY_ALLOWS_HYPHEN, and linux_identity_valid refuses ALL/root/empty/#uid/newline-injected names.
  • Sudoers via IFD (install.rs, main.rs PrintSudoers): the Nix module calls print-sudoers at build time (pkgs.runCommand) with OPERATOR/SERVICE_USER passed through, and feeds security.sudo.extraConfig the generated text. Invalid identities make the IFD build fail (exit(2)).
  • Broker store-path baking (broker.rs): the broker is a store-path libexec/ copy; SUDO_SECRETSPEC_BROKER_PATH is baked via builtins.placeholder "out" (no /run symlink). The source-restore verb refuses --all/--force before opening the database (M2).
  • Nix flake + module (flake.nix, nix/module.nix, nix/package.nix): flake input nixpkgs.follows the consumer's; the module derives sudoers, asserts valid identities, and denylists nixos/systemd/private and a group denylist under /var/lib.
  • VM test (nix/test.nix, testers.nixosTest): proves the grant set is exactly the 11 __broker verbs (NOPASSWD) and that source-restore --all --force, source-destroy --all, and doctor are password-gated; negatives assert "a password is required" on the same broker path, so neither direction is vacuous.
  • Docs (CHANGELOG.md, docs/design/dann-deployment-threat-model.md): records the deployment threat model and the Linux build status.

CI

  • Run 40847093887: all three jobs green (linux fmt/clippy/build/test, macos companion crate, nix — which built and ran the NixOS VM test on this head).
  • Run 40845952147: nix green at 9ba54fda (the fmt drift dc597ab5 later fixed is visible there).

Adversary review

Reviewed read-only by adversary at head dc597ab5. Blocking findings from the prior BLOCK (H1 VM test, M1 identity validation, M3 changelog) are fixed and proven green; M2 and L1 are fixed with green unit tests. Residual N1–N6 are all LOW (doc-wording and coverage items); N1 and N2 flag two incorrect statements in security prose that I'll fix in an immediate follow-up, not in this merge.

Non-goals / documented refusals

  • No Linux Homebrew, no Touch ID: Linux install goes through the Nix module only; install/uninstall/rollback/doctor refuse on non-macOS via platform::lifecycle_refusal (doctor/drift is a macOS-only concern).

Note

High Risk
Changes the privilege boundary on a new OS: sudoers generation, compile-time broker paths, and broker authorization gates are security-critical; mistakes could widen NOPASSWD or weaken restore controls.

Overview
Ports sudo-secretspec to Linux/NixOS while keeping macOS behavior unchanged. Trusted paths (sudo, broker, config, vault parent, sudoers layout) move into a new platform module, with compile-time overrides for the Nix package (SUDO_SECRETSPEC_*). install / uninstall / rollback / doctor refuse on Linux and point operators at services.sudo-secretspec.

Adds a Nix flake (packages, nixosModules.default, Linux VM checks) that builds the CLI with a separate libexec/ broker copy (immutable store path, no /run symlink), generates sudoers via hidden print-sudoers + IFD in the module, and asserts vault/operator/service identity constraints.

Sudoers policy is refactored into shared BROKER_VERBS / operator_grant_lines, plus linux_sudoers_text (no Touch ID / doctor grants, NixOS secure_path) with linux_identity_valid so bad operator/service names fail at generation time. Config validation tightens vault paths (reject . / ..), root as service identity, and Linux hyphenated service names.

Broker hardening (M2): plain source-restore rejects --all and --force (exit 2) so NOPASSWD --* globs cannot unattended whole-vault restore; tests switch mass restore to source-restore-force.

Documents the dann deployment threat model (root-equivalent operator, sops vs vault split) and updates CHANGELOG / devenv (CLI builds on Linux; crate tests still macOS-shaped).

Reviewed by Cursor Bugbot for commit dc597ab. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor

cursor Bot commented Oct 29, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: c71c0114-12ba-4a75-9348-63791a8cdf00)

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T09:50:32.850271Z dc597ab PR opened
🔒 Security Review ✅ Completed 2026-10-29T09:53:42.408223Z dc597ab PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@djbclark
djbclark merged commit 3b29adf into sudo-main Oct 29, 2026
20 of 22 checks passed
@linear-code

linear-code Bot commented Oct 29, 2026

Copy link
Copy Markdown

VIB-161

@djbclark
djbclark deleted the linux-port branch October 29, 2026 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant