Merge #225: Fix process info restriction
44de5064cdsecurity: don't restrict process info by default for module users (Erik Arvstedt)a36789b468test: move security tests to separate function (Erik Arvstedt)588a0b2405security: enable full systemd-status for group 'proc' (Erik Arvstedt)96ea2e671csecurity: simplify and fix dbus configuration (Erik Arvstedt)343e026030rename dbus.nix -> security.nix (Erik Arvstedt)7367446761test: rename assert_matches_exactly -> assert_full_match (Erik Arvstedt) Pull request description: ACKs for top commit: nixbitcoin: ACK44de5064cdTree-SHA512: f782cfdc81b5d6b3da968d0221bd54420791a9f5cd89cde9e62d6d04882d921b5efe9046d975133587b5c2d711c47133b3a5a2351940899a90a28bf16218a7ad
This commit is contained in:
@@ -1,55 +0,0 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
inherit (config) nix-bitcoin-services;
|
||||
dataDir = "/var/lib/dbus-hardening";
|
||||
# Mitigates a security issue that allows unprivileged users to read
|
||||
# other unprivileged user's processes' credentials from CGroup using
|
||||
# `systemctl status`.
|
||||
dbus-hardening = pkgs.writeText "dbus.conf" ''
|
||||
<?xml version="1.0" encoding="UTF-8"?> <!-- -*- XML -*- -->
|
||||
|
||||
<!DOCTYPE busconfig PUBLIC
|
||||
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
||||
|
||||
<busconfig>
|
||||
<policy user="root">
|
||||
<allow send_destination="org.freedesktop.systemd1"
|
||||
send_interface="org.freedesktop.systemd1.Manager"
|
||||
send_member="GetUnitProcesses"/>
|
||||
</policy>
|
||||
|
||||
<policy context="mandatory">
|
||||
<deny send_destination="org.freedesktop.systemd1"
|
||||
send_interface="org.freedesktop.systemd1.Manager"
|
||||
send_member="GetUnitProcesses"/>
|
||||
</policy>
|
||||
</busconfig>
|
||||
'';
|
||||
in {
|
||||
config = {
|
||||
systemd.tmpfiles.rules = [
|
||||
"d '${dataDir}/etc/dbus-1/system.d' 0770 messagebus messagebus - -"
|
||||
];
|
||||
|
||||
services.dbus.packages = [ "${dataDir}" ];
|
||||
|
||||
systemd.services.hardeneddbus = {
|
||||
description = "Install hardeneddbus";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
script = ''
|
||||
cp ${dbus-hardening} ${dataDir}/etc/dbus-1/system.d/dbus.conf
|
||||
chmod 640 ${dataDir}/etc/dbus-1/system.d/dbus.conf
|
||||
'';
|
||||
serviceConfig = nix-bitcoin-services.defaultHardening // {
|
||||
PrivateNetwork = "true";
|
||||
Type = "oneshot";
|
||||
User = "messagebus";
|
||||
ReadWritePaths = "${dataDir}";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
./lightning-loop.nix
|
||||
./secrets/secrets.nix
|
||||
./netns-isolation.nix
|
||||
./dbus.nix
|
||||
./security.nix
|
||||
./backups.nix
|
||||
];
|
||||
|
||||
|
||||
@@ -42,8 +42,7 @@ in {
|
||||
|
||||
networking.firewall.enable = true;
|
||||
|
||||
# hideProcessInformation even if hardened kernel profile is disabled
|
||||
security.hideProcessInformation = true;
|
||||
nix-bitcoin.security.hideProcessInformation = true;
|
||||
|
||||
# Tor
|
||||
services.tor = {
|
||||
@@ -227,6 +226,7 @@ in {
|
||||
isNormalUser = true;
|
||||
extraGroups = [
|
||||
"systemd-journal"
|
||||
"proc" # Enable full /proc access and systemd-status
|
||||
cfg.bitcoind.group
|
||||
]
|
||||
++ (optionals cfg.clightning.enable [ "clightning" ])
|
||||
|
||||
39
modules/security.nix
Normal file
39
modules/security.nix
Normal file
@@ -0,0 +1,39 @@
|
||||
{ config, lib, pkgs, options, ... }:
|
||||
|
||||
{
|
||||
options = {
|
||||
nix-bitcoin.security.hideProcessInformation = options.security.hideProcessInformation;
|
||||
};
|
||||
|
||||
config = lib.mkIf config.nix-bitcoin.security.hideProcessInformation {
|
||||
# Only show the current user's processes in /proc.
|
||||
# Users with group 'proc' can still access all processes.
|
||||
security.hideProcessInformation = true;
|
||||
|
||||
# This mitigates a systemd security issue leaking (sub)process
|
||||
# command lines.
|
||||
# Only allow users with group 'proc' to retrieve systemd unit information like
|
||||
# cgroup paths (i.e. (sub)process command lines) via D-Bus.
|
||||
# This D-Bus call is used by `systemctl status`.
|
||||
services.dbus.packages = lib.mkAfter [ # Apply at the end to override the default policy
|
||||
(pkgs.writeTextDir "etc/dbus-1/system.d/dbus.conf" ''
|
||||
<busconfig>
|
||||
<policy context="default">
|
||||
<deny
|
||||
send_destination="org.freedesktop.systemd1"
|
||||
send_interface="org.freedesktop.systemd1.Manager"
|
||||
send_member="GetUnitProcesses"
|
||||
/>
|
||||
</policy>
|
||||
<policy group="proc">
|
||||
<allow
|
||||
send_destination="org.freedesktop.systemd1"
|
||||
send_interface="org.freedesktop.systemd1.Manager"
|
||||
send_member="GetUnitProcesses"
|
||||
/>
|
||||
</policy>
|
||||
</busconfig>
|
||||
'')
|
||||
];
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user