!DBFhtjpqmJNENpLDOv:nixos.org

NixOS systemd

607 Members
NixOS ❤️ systemd166 Servers

Load older messages


SenderMessageTime
31 May 2021
@jfroche:matrix.orgjfroche joined the room.18:35:26
1 Jun 2021
@0x4a6f:matrix.org[0x4A6F] changed their display name from 0x4A6F to [0x4A6F].06:36:29
@sgo:matrix.orgstigo left the room.13:14:47
3 Jun 2021
@andi:kack.itandi-I know I talked about it a few times on IRC but I finally sat down and implemented an experiment to provide opt-in hardening for services: https://github.com/andir/nixpkgs/commit/4d9c0cfdab5d681ff0372bf8b5a2ac6e650c9b8c17:22:39
@andi:kack.itandi-Merging of lists with default values is really bad.. If you want to opt-in to one feature but don't want to repeat the entire exclude list (which is the default value) it becomes repetitive again.18:12:12
@aaron:fosslib.netaaron andi-: in my opinion this is significantly better than what has been proposed in the past 19:43:54
@aaron:fosslib.netaaron ❤️ andi- 19:44:03
@aaron:fosslib.netaaroni just quickly looked at it... i'll read it when i have more time, but i like this approach more19:44:55
@andi:kack.itandi-We still have a problem of exlcluding a single mitigation in one of the larger lists but I'll keep iterating20:06:20
@Las:matrix.orgLas

andi-:

This commit introduces a new
systemd.services.<service-name>.defaultHarddefaultHardening option
that allows specifiying a profile level that should be applied.

20:39:28
@Las:matrix.orgLasI assume this is a typo?20:39:35
@andi:kack.itandi-the long option name? If so, yes.21:25:30
4 Jun 2021
@antifuchs:asf.computerantifuchsoh, this is pretty neat!00:29:37
@roosemberth:orbstheorem.chRoos andi-: That looks awesome. 00:32:46
@roosemberth:orbstheorem.chRoosWhat's the policy on changing those hardening options?00:33:01
@roosemberth:orbstheorem.chRoosAlso, is there a eta-reduction I don't understand or is the unitConfig argument unused? :/00:35:41
@andi:kack.itandi-

Roos: There is no policy yet but I'd love to define one as part of this work. One of the rules I'd stick to is that we only ever add new profiles instead of modifying the old ones. At least as long as there are users of the "old" one in Nixpkgs. Those changes (to "old" profiles) need changelog entries so downstream users can adjust their custom units.

The unitConfig attribute isn't used (yet). I've been thinking about making them "clever" by doing "the right thing" depending on other attributes in the unit but haven't gotten around to actually figure out how that looks like. The main issue here being that they can quickly become "unpredictable" if they do too much.

Another avenue that I was looking at yesterday was selecting a list of profiles for each unit. Something like [ base-v1 network-service-v1 ] where the first one applies some generic hardening (DynamicUser, PrivateTmp, DevicePolicy, rough capability enforcement) and the 2nd one defines policies related to the network service. One example would be allowing AF_INET{,6} and/or AF_UNIX (which arguable every? service could have).

The main problem in composing those is that generally we can only get more restrictive as removing an element from the list of restrictions isn't currently possible. We also have to somehow merge multiple mkDefault statements if we go that route. Currently that should throw an eval error (conflicting statements).

Thus I think selecting from multiple profiles isn't great. At least not a first. We might as well "embed" the base-v1 definitions into the network-service-v1 definition.

As one of the last exercises I tried to run the Nginx service with the v1 profile from the linked commit but couldn't figure out which of the restrictions was responsible for the startup failure... We need proper tooling around this as otherwise it will become rather hard for the uninvolved hacker to adopt this in their units. If they can't debug this the entire exercise isn't worth it.

05:37:24
@roosemberth:orbstheorem.chRoos

I'd stick to is that we only ever add new profiles instead of modifying the old ones. At least as long as there are users of the "old" one in Nixpkgs.

+1

07:33:12
@roosemberth:orbstheorem.chRoos

I've been thinking about making them "clever" by doing "the right thing" depending on other attributes in the unit but haven't gotten around to actually figure out how that looks like.

I'd stick to simplicity and provide a fixed set of restrictions which can be overriden by the service config itself (e.g. A user can always services.foo = {defaultHardening = "v1"; ProtectHostname = false; }

07:33:14
@roosemberth:orbstheorem.chRoosI'm not so sure on the value of having profile partitions, I think you'll probably hit 90% of the user-cases with a simple "v1" profile, and a great part of the remainder with overrides.07:34:47
@roosemberth:orbstheorem.chRoos I think mkDefault could be replaced with a different type. 07:36:49
@roosemberth:orbstheorem.chRoosI haven't tried to run it myself, what kind of tooling would help you to better debug?07:38:26
@andi:kack.itandi-I was thinking about running them on strace but then again I think strace requires ptrace which isn't allowed in the profile :D08:02:14
@andi:kack.itandi- (so perhaps a v1-debug profile or something would be useful) 08:02:34
@emilazy:matrix.orgemily

re

I've been thinking about making them "clever" by doing "the right thing" depending on other attributes in the unit but haven't gotten around to actually figure out how that looks like.

my personal preference would be to lean on the restrictive side and have explicit toggles for permitting broad categories of thing

14:03:05
@emilazy:matrix.orgemily(but that might not gel too well with making units easy to adapt)14:03:15
@emilazy:matrix.orgemilyif you think about things "like Nix", the correct service model would be an object-capability one where no resources are available to the process unless explicitly passed in; getting all the way there isn't practical on Linux but I feel like the closer we get to that ideal the better things will gel and the more hardening we'll get out of it14:04:22
@andi:kack.itandi-Yeah. That is kind my end-goal with this but it is hard to move the linux (& systemd) way of doing that in that direction. We also have a log of overlap between capabilities and requirements and it would have to be very very fine grained if this were an object capability system. Not sure I'd like to maintain a system that is as complex (or complexer) as the systemd settings we have now. I could definitely like to have broad categories. What are those? Local service (AF_UNIX, DynamicUser, StateDirectory), Networked Service (AF_INET{6,}, PrivateNetwork=false)?16:16:17
5 Jun 2021
@hexa:lossy.networkhexathere was an approach to multi-level opt-in hardening by das_j iirc00:11:17
@hexa:lossy.networkhexa * there was an approach to multi-level opt-in hardening by dasj iirc00:11:46

Show newer messages


Back to Room ListRoom Version: 6