mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #1927] firejail --list is empty, but firemon shows firejail processes #1288
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#1288
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 @chiraag-nataraj on GitHub (May 5, 2018).
Original GitHub issue: https://github.com/netblue30/firejail/issues/1927
This is really weird, and is probably a product (in some way) of
hidepid=2./procwithhidepid=2(my exact mount options arenosuid,nodev,noexec,hidepid=2,gid=107)firejail:firejail firefoxfirejailis in fact running:sudo pidof firejailfiremonwill show the relevant processes:sudo firemonfirejail --list,sudo firejail --list,firejail --tree, andsudo firejail --treeall show nothing.This seems to happen both with the current release version (0.9.52) and the current development version (0.9.53).
@SkewedZeppelin commented on GitHub (May 5, 2018):
So
firejail --listshould outputError: /proc is mounted hidepid, you would need to be root to run this command, but isn't?sudo firecfg --listshould work, but isn't?@chiraag-nataraj commented on GitHub (May 5, 2018):
So I expect
firejail --listto be blank or give me an error, but I expectsudo firejail --listto give me the proper list.firemonworks as expected (gives me the error as regular user and outputs the processes as root).@chiraag-nataraj commented on GitHub (May 5, 2018):
Currently investigating. Running
firejail --debug --listseems to list the proper command to call (/usr/local/bin/firemon --list), but I'm not getting output from that command.@chiraag-nataraj commented on GitHub (May 5, 2018):
For some reason,
firemonseems to act differently when called throughfirejail. Even iffiremondoesn't have root permissions (which it needs withhidepid), it will try to enumerate everything when called throughfirejail, but not when called directly.[edit]
I think I found an issue. When
firemonis called throughfirejail, it thinks it has root privileges (i.e.getuid()returns 0) regardless of the calling user's UID. Whenfiremonis invoked directly,getuid()returns the proper value. But I don't think this explains whysudo firejail --listdoesn't work...going to continue digging. The issue seems to be with thepid_read()function, which seems to behave differently when calledfiremonis called throughfirejail(the PIDs which should have level 1 have level 0). Huh, the PID list itself seems to be different. This is really weird.@Vincent43 commented on GitHub (May 5, 2018):
Does executing
firejail --listas root (without sudo) has same effect?@chiraag-nataraj commented on GitHub (May 5, 2018):
Yes. The PID list returned by
pid_readis the same whether I runfirejail --listas root orsudo firejail --listfrom my regular user. And it is definitely different from the actual PID list (which is return when I runfiremon --listas root or through sudo). You can try it yourself by insertingprintf("%i\n",pid)betweenpid_t pid = strtol(entry->d_name, &end, 10);andpid %= max_pids;insrc/lib/pid.c.@Vincent43 commented on GitHub (May 5, 2018):
I guess firejail is always dropping some privileges or manipulating something as it always run as root regardless of sudo or not. It doesn't have to be a bad thing actually.
@chiraag-nataraj commented on GitHub (May 5, 2018):
I suspect that is what is going on, since this seems to be a PID namespace of some sort. If so, we should deprecate
firejail --listand just usefiremon --list(probably same with--tree?).@chiraag-nataraj commented on GitHub (May 5, 2018):
But it's also weird that this is only happening with
hidepidenabled...@Vincent43 commented on GitHub (May 5, 2018):
Without hidepid every user has the same view of processes (unless contained with firejail) so:
firemon,sudo firemon,firejail --treehave same effect.@chiraag-nataraj commented on GitHub (May 5, 2018):
Found it. The culprit was dropping capabilities before calling
firemon.@Vincent43 commented on GitHub (May 5, 2018):
I think the solution is to use
firemondirectly then.@chiraag-nataraj commented on GitHub (May 5, 2018):
Cool 👍 Maybe we should provide a warning if
hidepidis enabled and--listor--treeis used?@Vincent43 commented on GitHub (May 5, 2018):
It's interesting that when hidepid is enabled and user is in whitelisted group the behavior is quite the opposite:
@chiraag-nataraj commented on GitHub (May 6, 2018):
Yeah, exactly. That's why I didn't see this bug/feature(?) until I removed my user from the whitelisted group.
@Vincent43 commented on GitHub (May 6, 2018):
What I presented above is also incorrect as firemon should check if user is in trusted group. When running through firejail, firemon thinks it's root and ignores hidepid.
So, as for now if hidepid is used and user is in trusted group they should use
firejail --listorsudo firemon --list(but usingsudomisses the point of being in trusted group), and when user isn't in trusted group they should usesudo firemon --list.Adding proper checks to firemon would be valuable.
@netblue30 commented on GitHub (May 9, 2018):
Very cool bug!
I had to build a special capabilities filter for running under hidepid:
1576791f29This is probably a second bug, thanks!