git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/home-assistant: allow netlink sockets and /proc/net inspection

Since v2021.5.0 home-assistant uses the ifaddr library in the zeroconf component to enumerate network interfaces via netlink. Since discovery is all over the place lets allow AF_NETLINK unconditionally. It also relies on pyroute2 now, which additionally tries to access files in /proc/net, so we relax ProtectProc a bit by default as well. This leaves us with these options unsecured: ✗ PrivateNetwork= Service has access to the host's network 0.5 ✗ RestrictAddressFamilies=~AF_(INET|INET6) Service may allocate Internet sockets 0.3 ✗ DeviceAllow= Service has a device ACL with some special devices 0.1 ✗ IPAddressDeny= Service does not define an IP address allow list 0.2 ✗ PrivateDevices= Service potentially has access to hardware devices 0.2 ✗ PrivateUsers= Service has access to other users 0.2 ✗ SystemCallFilter=~@resources System call allow list defined for service, and @resources is included (e.g. ioprio_set is allowed) 0.2 ✗ RestrictAddressFamilies=~AF_NETLINK Service may allocate netlink sockets 0.1 ✗ RootDirectory=/RootImage= Service runs within the host's root directory 0.1 ✗ SupplementaryGroups= Service runs with supplementary groups 0.1 ✗ RestrictAddressFamilies=~AF_UNIX Service may allocate local sockets 0.1 ✗ ProcSubset= Service has full access to non-process /proc files (/proc subset=) 0.1 → Overall exposure level for home-assistant.service: 1.6 OK 🙂

commit24adc01e2ed8377a82a45957b4ba280e169c185a authorMartin Weinelt <hexa@darmstadt.ccc.de> dateThu 6 May 2021, 16:44 (6 years ago) parent3bab9a1
1 file changed+3−2
nixos/modules/services/misc/home-assistant.nix+3−2
nixos/modules/services/misc/home-assistant.nix+3−2
@@ -298,7 +298,7 @@ in {
298298 ProtectKernelModules = true;
299299 ProtectKernelTunables = true;
300300 ProtectProc = "invisible";
301− ProcSubset = "pid";
301+ ProcSubset = "all";
302302 ProtectSystem = "strict";
303303 RemoveIPC = true;
304304 ReadWritePaths = let
@@ -308,9 +308,10 @@ in {
308308 allowPaths = if isList value then value else singleton value;
309309 in [ "${cfg.configDir}" ] ++ allowPaths;
310310 RestrictAddressFamilies = [
311− "AF_UNIX"
312311 "AF_INET"
313312 "AF_INET6"
313+ "AF_NETLINK"
314+ "AF_UNIX"
314315 ] ++ optionals (useComponent "bluetooth_tracker" || useComponent "bluetooth_le_tracker") [
315316 "AF_BLUETOOTH"
316317 ];