mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #4603] Feature Request: Logind conditional #2718
Labels
No labels
LTS merge
LTS merge
bug
bug
converted-to-discussion
doc-todo
documentation
duplicate
enhancement
file-transfer
firecfg
firejail-in-firejail
firetools
graphics
help wanted
information_old
installation
invalid
modif
moved
needinfo
networking
notabug
notourbug
old-version
overlayfs
packaging
profile-request
pull-request
question
question_old
removal
runtime-permissions
sandbox-ipc
security
stale
wiki
wiki
wontfix
wordpress
workaround
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/firejail#2718
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @crocket on GitHub (Oct 13, 2021).
Original GitHub issue: https://github.com/netblue30/firejail/issues/4603
Is your feature request related to a problem? Please describe.
(e)udev attaches uaccess tag to devices.
systemd-logind and elogind grant logged-in users rights to devices with uaccess tag.
With logind,
norootandnogroupsdon't break device access.Without logind,
norootornogroupsmay break device access.Some linux distributions like Void Linux and Gentoo Linux allow users to replace logind with other seat managers like seatd.
Describe the solution you'd like
To support all linux distributions and all seat managers without any manual user configuration, a logind conditional like
?SEAT-ACLis desirable. Then,can be replaced with
@rusty-snake commented on GitHub (Oct 13, 2021):
Would require maintaining that they are always behind a condition. I would prefer a more implicit solution.
Previous discussions: #4600, #4531, #4602
Related issues: #3711, #841, #3303, #2042
@crocket commented on GitHub (Oct 13, 2021):
noroot-if-seat-acl and nogroups-if-seat-acl?
Or, noroot and nogroups kick in only if seat-acl is present.
@smitsohu commented on GitHub (Oct 13, 2021):
Quoting @crocket from #4600
To me this sounds more useful than a conditional alone. And once facilities are in place, they could also be exposed in
firejail.config, so that users, and maybe distributions, find it easier to adapt firejail to their setup.Edit to clarify: I was referring to something like #2042
@topimiettinen commented on GitHub (Oct 14, 2021):
@smitsohu Let's say fine-grained group control means something like
groups.drop sudo(black/denylist) andgroups.keep audio(white/allowlist). The case for local admin is clear, maybe also for distros, but how could we use them in upstream profiles? Maybe just commented out as examples?@smitsohu commented on GitHub (Oct 14, 2021):
@topimiettinen Right. This kind of fine grained control (
groups.drop) won't be very helpful for upstream profiles. I was thinking from the perspective of an administrator, but a more dynamic solution would be clearly better.@kmk3 commented on GitHub (Oct 15, 2021):
@topimiettinen commented on Oct 14:
@smitsohu commented on Oct 14:
Considering
groups.keepbeing more desirable than?SET_FACL, that there isa working implementation of the former and assuming that the audio group (if
any) is called "audio" on basically every distro that has firejail (would have
to check this one):
If a program requires audio output (e.g.: mpv), would there be any downside in
replacing
nogroupswith e.g.:groups.keep audioin its profile?On distros that default to systemd/pulseaudio, are new users added to an audio
group by default? If not, I think that @topimiettinen's multi-seat
concern would not apply, as the user would have to be deliberately added to
such a group. As in, I think that this responsibility would fall on the user
rather than on firejail (though we could document it of course).
Also, if there are more things needed to unblock (e.g.: specific device files)
other than the group, maybe there could be an include like the following:
allow-audio.inc:
That is, adding
include allow-audio.incto relevant profiles rather thanreplacing
nogroupswithgroups.keep audioon them.Overriding the above (in e.g.: allow-audio.local) would also permit allowing
only specific devices rather than every audio device, which would be even more
granular than just
groups.keep. Example:Note: There is currently no
write-only, but having something like the abovelooks like it could also effectively fix the following issue:
And if someone would like to avoid allowing any groups at all, then something
like
ignore include allow-audio.inc(orignore ignore nogroups) could beadded to globals.local.
@crocket commented on GitHub (Oct 15, 2021):
It doesn't make much sense to put
ignore nogroupsin allow-audio.inc if allow-audio.inc is included in main profiles.You should just remove
nogroups.Adding more stuff to counteract existing stuff is counterproductive. We should remove lines instead.
If we keep adding stuff without eliminating lines, we may end up with something like
ignore ignore ignore nogroups@rusty-snake commented on GitHub (Oct 15, 2021):
ignore nogroupsis enough.What about
nogroups <all|auto|none>?nogroups all(and aliasnogroupsfor backward compatibility) will drop all supplementary groups. (andnorootwill not change groups #3303)nogroups nonewill keep all groups (maybe we don't need this as it is the same as not usingnogroupsand just complicates things)nogroups autowill autodetect which groups it should keep (whitelisting) in case other group names are used, we can provide mappings in firejail.config@crocket commented on GitHub (Oct 15, 2021):
I think I like
nogroups (all)andnogroups auto. I also wantnorootto not touch groups.@topimiettinen commented on GitHub (Oct 15, 2021):
The users would gain access to this GID, which they didn't have before. Then they could make setgid binaries to keep the rights after Firejail exits.
I don't think so. At least my user isn't a member in any audio or cdrom groups.
Nice idea, though I don't think giving access is necessary for logind distros. In my setup, pulseaudio is started from
systemd --userand it has access to/dev/snd/directory, but the DE programs (for example Firefox) inherit the/devtree fromdisplay-manager.service, which has no access to/dev/snd/at all (PrivateDevices=yesbut thenBindReadOnlyPaths=for some devices, excluding/dev/snd). Still, sound works fine in the DE programs because they connect to pulseaudio instead of touching the devices directly. Firejailed pulseaudio would need the access of course.@topimiettinen commented on GitHub (Oct 15, 2021):
This could work well if also coupled with the logind check, so users on distros with logind would not get extra permissions but others would get at least some groups automatically when needed.
I think your
autoconcept is interesting more generally. Now there's a lot of heuristics going on in Firejail (to improve user friendliness) but it may be impossible to override them. But we could start introducing sort ofauto(heuristics on) andmanualmodes (everything has to be specified explicitly, like bubblewrap) for each setting with heuristics now.@crocket commented on GitHub (Oct 15, 2021):
Are you personally using firejail in public multi-seat computers? Isn't
seccompgoing to disable setting setgid bit?In single-user computers, your scenario doesn't make sense.
@topimiettinen commented on GitHub (Oct 15, 2021):
Firejail doesn't have a feature similar to systemd's
RestrictSUIDSGID=yes.The 'user' in the scenario could be also an attacker, who temporarily gains limited access using for example browser vulnerabilities or indirectly via an organization's shared network file system. We don't know well in advance what makes sense for all future attack scenarios and every little bit of extra security can help weaken the attacker's capabilities. There's no global switch 'security=on' which could block all possible attacks. Instead there are yet unknown weaknesses of various sizes which may lead to vulnerabilities and exploits, and attempts to make attackers' lives more difficult to counter the possibility of weaknesses.
@crocket commented on GitHub (Oct 15, 2021):
For
nogroups autoto eliminate all supplementary groups on logind systems and keep relevant groups on other systems makes sense because it improves convenience without reducing security.Convenience matters because
@kmk3 commented on GitHub (Oct 23, 2021):
@rusty-snake commented on Oct 15:
I really like the mapping of the "no" options to groups; it seems like an
obvious thing to do. Luckily, it looks like it wouldn't be hard to do
(refactoring to making it work without ACLs is another story though); see the
following related PR:
So, considering the following extra groups from @rusty-snake's code:
Thoughts on adding them to the hardcoded "allowed groups" lists and dropping
them based on the
nooptions?@topimiettinen commented on Oct 15:
After looking at the code, I think that combining the above ideas would be
a straightforward way to do it:
nosound,novideo, etcnogroupsAnd it wouldn't really require any new command or option.
So how about we do the following:
nosound, always drop audio group and block sound devices in /devnovideo, always drop video group and block video devices in /dev("always" above means "regardless of
norootandnogroups/(e)logind")nogroupsand (e)logind is running, drop all non-hardcoded groupsnogroupsand (e)logind is not running, keep the audio and video groups(if not already dropped) and the hardcoded groups and drop all other groups
Currently, the audio/video groups are only dropped if
norootis used(AFAICT).
@crocket Can you think of any other group that could be needed? Maybe the lp
group when using the new
noprinterscommand?Note: From what I've seen, using a variable like e.g.:
have_seat_aclswhererequired might not be something trivial to do, since
nogroupsis used inmultiple places and since in some of them it currently means just "drop all
groups" in some places. But I haven't looked too much into it.
Maybe there could be a
drop_groups(const char* groupnames[])function (toonly drop certain groups and keep the rest) besides the
clean_supplementary_groupsone (which drops all but certain hardcodedgroups)?
Misc: I had written some more comments, but since I wrote some code related to
the above (on #4632 and on a WIP branch), I'd like to get it out of the way
first.
@crocket commented on GitHub (Oct 24, 2021):
New options to consider with regard to
nogroups:noprintersExisting options to consider with regard to
nogroups:--no3d--nodvd--noinput--nosound--notv--nou2f--novideoOther considerations:
norootshould not drop groups?@kmk3 commented on GitHub (Oct 26, 2021):
@crocket commented on Oct 24:
Which groups would
notvandnou2fmap to?I think it's intended to drop only the groups that are related to non-system
users. That is, all groups with a gid between
GID_MINandGID_MAX, asdefined on login.defs(5).
From my testing, the option appears to be working correctly (at least by
itself):
The following commands output the same amount of groups inside and outside of
firejail (so no system group appears to be dropped):
@crocket commented on GitHub (Oct 26, 2021):
nou2fblocks/dev/hidraw0which belongs torootgroup.notvblocks/dev/dvbwhich doesn't exist on my system. So, I don't know which group it belongs to.Man page doesn't say anything about that.
@rusty-snake commented on GitHub (Oct 26, 2021):
FTR: It blocks
/dev/hidraw[0-9]and/dev/usbefbf74e124/src/firejail/fs_dev.c (L81-L91)@crocket commented on GitHub (Jan 2, 2022):
Can this be considered fixed now?
@kmk3 commented on GitHub (Jan 3, 2022):
@crocket commented on Jan 2:
Yes; thanks for the reminder.