mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-08-27 05:44:00 +02:00
* security: make firewall secure-by-default, disable explicitly on servers
Flip the base firewall default to ON so new hosts are protected by default. Servers keep the firewall off (trusted internal LAN, WAN protected at the router) via explicit overrides in modules/nixos/server/{server,server-aarch64}.nix. Behavior-preserving for all 18 current hosts; adds a security-firewall eval test guarding the per-host state.
* test: fix security-firewall eval test to scalar per-host values
* security: enable AppArmor (complain) on all Linux hosts
* security: bind aquamarine metrics exporters to loopback
* security: restrict k3s kubeconfig file mode to 600
* security: disable SSH X11 forwarding on servers, keep on desktops
* security: add conservative systemd hardening to aquamarine services
* docs(apparmor): correct FHS-alias comment (nixpkgs has no broad FHS layer)
nixpkgs only creates /run/current-system, /usr/bin/env and /bin/sh; it does not
provide a broad FHS->store alias tree, so FHS-oriented abstractions are incomplete
on NixOS. They are safe only because the profiles run in complain mode.
* fix(aquamarine): scrape same-host exporters over loopback
The v2ray/postgres/sftpgo exporters were bound to 127.0.0.1 but VictoriaMetrics
scraped them via the host's routable IP, so those scrapes refused connections.
Point the three same-host scrape targets at 127.0.0.1 (VM runs on the same host).
node-exporter keeps the host IP since it binds 0.0.0.0.
* Revert "security: add conservative systemd hardening to aquamarine services"
This reverts commit f9cf99dadb.
57 lines
1.9 KiB
Nix
57 lines
1.9 KiB
Nix
{
|
|
config,
|
|
pkgs,
|
|
...
|
|
}:
|
|
{
|
|
# AppArmor: activate the LSM + load policies. Roll out in complain mode first
|
|
# (log violations, never block) so nothing can break; promote profiles to
|
|
# "enforce" individually once stable.
|
|
services.dbus.apparmor = "enabled";
|
|
|
|
security.apparmor = {
|
|
enable = true;
|
|
|
|
# Do not SIGTERM running unconfined-but-confinable processes yet.
|
|
# Safe to flip to true later now that no global default-deny profile is active.
|
|
killUnconfinedConfinables = false;
|
|
|
|
# Packages contributing to AppArmor's include path (abstractions).
|
|
# NOTE: these abstractions are FHS-oriented and reference FHS paths. nixpkgs does NOT
|
|
# provide a broad FHS->store alias layer (only /run/current-system, /usr/bin/env and
|
|
# /bin/sh are created), so some referenced paths do not resolve on NixOS and the
|
|
# resulting profiles are incomplete. They are safe only because they run in complain
|
|
# mode (log-only, no blocking); see hardening/README.md.
|
|
packages = [ pkgs.apparmor-profiles ];
|
|
|
|
policies = {
|
|
# Global default-deny scaffold. DANGEROUS to enable: `/**` matches every binary and
|
|
# the empty block allows nothing. Keep disabled until per-app profiles exist.
|
|
"default_deny" = {
|
|
state = "disable";
|
|
profile = "profile default_deny /** { }";
|
|
};
|
|
|
|
# Confine sudo; complain mode so a missing rule logs instead of blocking.
|
|
"sudo" = {
|
|
state = "complain";
|
|
profile = ''
|
|
abi <abi/4.0>,
|
|
include <tunables/global>
|
|
|
|
profile ${pkgs.sudo}/bin/sudo {
|
|
include <abstractions/base>
|
|
file /** rwlkUx,
|
|
}
|
|
'';
|
|
};
|
|
|
|
# nix runs unconfined (no restriction); inert, kept disabled.
|
|
"nix" = {
|
|
state = "disable";
|
|
profile = "profile ${config.nix.package}/bin/nix { unconfined, }";
|
|
};
|
|
};
|
|
};
|
|
}
|