From 6836233c951900eae265eebfe8b04298d63c4c0e Mon Sep 17 00:00:00 2001 From: kiskaadee Date: Tue, 13 Oct 2026 06:51:27 -0500 Subject: [PATCH] feat(nixos): sandbox homelab-gitops service and update roadmap for Milestone P2 - Apply systemd sandboxing to homelab-gitops service: ProtectSystem=strict, ProtectHome=read-only, NoNewPrivileges=true, PrivateTmp=true, and kernel tunables protection. - Restrict filesystem write paths to ~/Sites and ~/.local/state/homelab. - Explicitly set DOCKER_CONFIG to isolated state directory to avoid home directory pollution. - Prune obsolete SnappyMail tmpfiles rule and ensure gitops state directories exist. - Mark Milestone P2 as completed in ROADMAP.md and advance Milestone P3 to current up next. --- ROADMAP.md | 10 +++++----- nixos/modules/homeserver.nix | 20 ++++++++++++++++++-- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index 08b729f..f453505 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -64,19 +64,19 @@ It describes the implementation trajectory and phased engineering milestones for --- ### Milestone P2: GitOps Privilege & Authority Hardening -**Status**: 🎯 **Current / Up Next** +**Status**: ✅ **Completed** * **Objective**: Close remaining trust boundaries in the webhook continuous deployment engine. * **Key Deliverables**: 1. *Authoritative Core Registry*: Establish `Core/config/deployments.yaml` as the sole authority for admitted deployment repositories. - 2. *Data Vault Pull-Only Policy*: Designate `~/Brain` as a read-only repository with `strategy: pull-only`, isolated from Docker socket access. - 3. *Compose AST Security Validator*: Pre-flight parser rejecting `privileged: true`, Docker socket bind mounts, host networking, and mounts outside `~/var/lib/homelab//`. - 4. *Systemd Sandboxing*: Apply `ProtectSystem=strict`, `NoNewPrivileges=true`, and private temporary directories to `homelab-gitops.service`. + 2. *Decouple Data Vault from Workload GitOps*: Evict vault special-casing (`BRAIN_DIR`) from GitOps engine; continuous deployment strictly manages Sites container workloads. + 3. *Compose AST Security Validator*: Pre-flight parser rejecting `privileged: true`, Docker socket bind mounts, host networking, and host mounts outside workload root or state root. + 4. *Systemd Sandboxing*: Apply `ProtectSystem=strict`, `ProtectHome=read-only`, `ReadWritePaths`, `NoNewPrivileges=true`, and private temporary directories to `homelab-gitops.service`. * **Exit Criteria**: Path traversal rejection tests pass; Compose AST security validator rejects prohibited capabilities. --- ### Milestone P3: Manifest Contract Convergence & Provenance Engine -**Status**: ⏳ **Planned** +**Status**: 🎯 **Current / Up Next** * **Objective**: Establish a single authoritative manifest schema and two-axis inspection engine across the platform. * **Key Deliverables**: 1. *Schema v1.0 & Parser Library (`core_manifest.py`)*: Strongly-typed manifest parsing, transport scheme validation (`https://`, `ssh://`, `git@`), and explicit ref semantics (moving branches vs. pinned tags vs. commit SHAs). diff --git a/nixos/modules/homeserver.nix b/nixos/modules/homeserver.nix index f5b3637..cc9dd81 100644 --- a/nixos/modules/homeserver.nix +++ b/nixos/modules/homeserver.nix @@ -70,11 +70,13 @@ environment = { GITOPS_SECRET_FILE = config.sops.secrets."gitops/webhook_secret".path; + DOCKER_CONFIG = "/home/kiskaadee/.local/state/homelab/docker"; }; serviceConfig = { Type = "simple"; User = "kiskaadee"; + SupplementaryGroups = [ "docker" ]; WorkingDirectory = "/home/kiskaadee/Core"; ExecStart = "${pkgs.webhook}/bin/webhook -hooks ${pkgs.writeText "hooks.json" (builtins.toJSON [ { @@ -91,14 +93,28 @@ ])} -port 9000 -verbose"; Restart = "on-failure"; RestartSec = "5s"; + + # Privilege separation & Systemd sandboxing + NoNewPrivileges = true; + PrivateTmp = true; + ProtectSystem = "strict"; + ProtectHome = "read-only"; + ProtectKernelTunables = true; + ProtectControlGroups = true; + ReadWritePaths = [ + "/home/kiskaadee/Sites" + "/home/kiskaadee/.local/state/homelab" + ]; }; }; - # Ensure persistent directories have proper permissions for container runtimes (e.g. Stalwart UID 2000, SnappyMail) + # Ensure persistent directories have proper permissions for container runtimes systemd.tmpfiles.rules = [ "d /home/kiskaadee/Core/config/stalwart/data 0777 kiskaadee users -" "d /home/kiskaadee/Core/config/stalwart/etc 0777 kiskaadee users -" - "d /home/kiskaadee/Core/config/snappymail/data 0777 kiskaadee users -" + "d /home/kiskaadee/Sites 0755 kiskaadee users -" + "d /home/kiskaadee/.local/state/homelab/gitops 0755 kiskaadee users -" + "d /home/kiskaadee/.local/state/homelab/docker 0755 kiskaadee users -" ]; # Open ports in the firewall for Traefik, Gitea SSH, GitOps Webhook Receiver, and Mail (SMTP, Submission, SMTPS, IMAPS, ManageSieve)