diff --git a/nix/modules/hive-c0re.nix b/nix/modules/hive-c0re.nix index 233cec1e..c2c1452e 100644 --- a/nix/modules/hive-c0re.nix +++ b/nix/modules/hive-c0re.nix @@ -1094,6 +1094,22 @@ in RuntimeDirectoryPreserve = "yes"; StateDirectory = "hyperhive"; StateDirectoryMode = "0750"; + # Sandboxing. hive-c0re is unprivileged (runs as hive-core, never + # setuid), makes HTTP requests to forge/matrix/Anthropic (keeps INET), + # and delegates all privileged ops to hive-priv via a Unix socket. + # These directives deny the subset of kernel capabilities it + # provably doesn't need without restricting its network or + # filesystem access (ProtectSystem / RestrictAddressFamilies are + # deferred to a follow-up with a watched deploy — see #1845). + NoNewPrivileges = true; # already runs as unprivileged user + PrivateTmp = true; # hive-c0re and its nix subprocesses use tmpfiles under StateDirectory, not /tmp + ProtectHome = true; # HOME = /var/lib/hyperhive (StateDirectory); no /home/* access needed + ProtectKernelTunables = true; # no sysctl writes + ProtectKernelLogs = true; # reads logs via systemd-journal group, not /dev/kmsg + ProtectControlGroups = true; # cgroup writes go through hive-priv, not c0re directly + RestrictNamespaces = true; # namespace creation goes through hive-priv + LockPersonality = true; # no personality changes needed + RestrictRealtime = true; # no real-time scheduling }; };