How does one audit when the user performs an action that normally requires elevated privileges?
Right now I'm allowing my users to shutdown/reboot systems, using the Gnome menu item(s) and/or power button on the login screen.
I would like to audit this specific event but I don't know how to do it. Just auditing the execution of /sbin/shutdown doesn't give me sufficient information in order to determine that the reboot was a result of a user clicking the gnome GUI item. I don't even see a message that indicates the uid of the user in connection with the shutdown event.
Here's an excerpt of the audit.log for when a normal user performs a reboot:
37 type=SYSCALL msg=audit(1446729410.820:6348): arch=c000003e syscall=59 success=yes exit=0 a0=7e2700 a1=7e0bf0 a2=7e0780 a3=7f fce02dad00 items=2 ppid=8633 pid=8634 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses =4294967295 comm="shutdown" exe="/sbin/shutdown" subj=system_u:system_r:shutdown_t:s0-s0:c0.c1023 key="power" 38 type=EXECVE msg=audit(1446729410.820:6348): argc=3 a0="/sbin/shutdown" a1="-r" a2="now" 39 type=CWD msg=audit(1446729410.820:6348): cwd="/" 40 type=PATH msg=audit(1446729410.820:6348): item=0 name="/sbin/shutdown" inode=501 dev=fd:00 mode=0100755 ouid=0 ogid=0 rdev=0 0:00 obj=system_u:object_r:shutdown_exec_t:s0 nametype=NORMAL 41 type=PATH msg=audit(1446729410.820:6348): item=1 name=(null) inode=1649 dev=fd:00 mode=0100755 ouid=0 ogid=0 rdev=00:00 obj= system_u:object_r:ld_so_t:s0 nametype=NORMAL 42 type=SYSCALL msg=audit(1446729410.861:6349): arch=c000003e syscall=2 success=yes exit=5 a0=7fc8c1147db3 a1=80002 a2=7fc8c114 7db3 a3=fffffffffffffdcf items=1 ppid=8633 pid=8634 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="shutdown" exe="/sbin/shutdown" subj=system_u:system_r:shutdown_t:s0-s0:c0.c1023 key="session " 43 type=CWD msg=audit(1446729410.861:6349): cwd="/" 44 type=PATH msg=audit(1446729410.861:6349): item=0 name="/var/run/utmp" inode=262150 dev=fd:03 mode=0100664 ouid=0 ogid=22 rde v=00:00 obj=system_u:object_r:initrc_var_run_t:s0 nametype=NORMAL
Unless I'm missing it, I don't see anything that indicates the action originated from a gnome GUI item. I think this falls under AC-6.
Below is a link to my current audit.rules (based on an older security baseline, not the current scap-security-guide)
Hello,
On Thursday, November 05, 2015 11:24:08 AM Robert Jacobson wrote:
How does one audit when the user performs an action that normally requires elevated privileges?
TL;DR: you can't. See below for the whole story.
Right now I'm allowing my users to shutdown/reboot systems, using the Gnome menu item(s) and/or power button on the login screen.
The login screen would not have a auid associated with it, so this would normally be forbidden.
I would like to audit this specific event but I don't know how to do it. Just auditing the execution of /sbin/shutdown doesn't give me sufficient information in order to determine that the reboot was a result of a user clicking the gnome GUI item. I don't even see a message that indicates the uid of the user in connection with the shutdown event.
This is a known issue. Its history goes way back. The crux of the issue is that the desktop does not go through common criteria and thus has no plumbing for auditing. What plumbing you might ask? The issue is dbus.
The desktop uses a different execution model than the console which is fork execve. The desktop uses dbus and activation to start helpers. This means that if you place a watch on something that gets set by a privileged helper on the backend of dbus, you get an auid of -1 because dbus is a daemon.
So, why doesn't dbus just set the auid on the backend? Its related to the two generals problem: https://en.wikipedia.org/wiki/Two_Generals%27_Problem
With that in mind, we het the following:
1) We need a way for closely related processes to transfer some credentials, not permissions. 2) We cannot weaken the non-repudiation qualities already established. 3) It cannot allow "token kidnapping" style attacks. (Windows impersonation had design/implementation flaws that allowed privilege escalation. Read about this if its unfamiliar.)
This implies 1) Both processes know about each other and agree to the transfer. To avoid #1 and #3, we cannot force credentials on a process or allow theft of credentials. 2) The kernel is the only entity that can do the transfer based on #2. If we open a hole so that user space can arbitrarily specify values of the credentials, we fail on #2 and find a new way for #3.
I raised this issue with the desktop programming team as long ago as 2010. And mentioned that because of the above analysis, we need dbus to be in the kernel and we need the ability to have dbus activated processes to impersonate the gui application.
Back in 2012 as we started on the work for what would become RHEL7, we had a renewed effort to convince the desktop team to go through common criteria. I think some work started in earnest on AF_DBUS.
This is the origin and reason why the kernel dbus module is being created.
-Steve
Thanks for taking the time to write such an informative response.
Is there a roadmap for the kernel dbus module?
On Friday, November 06, 2015 01:09:24 PM Robert Jacobson wrote:
Thanks for taking the time to write such an informative response.
Np. I just wanted everyone to know the reason behind why you can't. Its not for a lack of desire, but more a central conflict in the paradigm behind each group (fork/execve vs dbus+activation) and the struggle to get this in the kernel for 3 solid years. Once its accepted by Linus, I think it'll take about a year to polish the desktop for it and plumb gnome/polkit/udev.
Is there a roadmap for the kernel dbus module?
It was recently in rawhide but got pulled back out because they are re- thinking a few things.
http://www.phoronix.com/scan.php?page=news_item&px=Fedora-Drops-KDBUS
There was even patches on linux-audit over the last couple weeks to review the LSM/selinux hooks. The work is ongoing. It will not be in RHEL7, though.
That said, you can audit some things by placing a watch on specific helpers in /usr/libexec.
-Steve
On 2015-11-06 1:28 PM, Steve Grubb wrote:
That said, you can audit some things by placing a watch on specific helpers in /usr/libexec. -Steve
Can you expand on that a bit? I have no idea which helpers gnome might use for a reboot operation.
I tried this rule just for fun:
-w /usr/libexec -p rwxa -k libexec
But I didn't see anything related to power when I rebooted the system via Gnome.
On Friday, November 06, 2015 02:39:36 PM Robert Jacobson wrote:
On 2015-11-06 1:28 PM, Steve Grubb wrote:
That said, you can audit some things by placing a watch on specific helpers in /usr/libexec. -Steve
Can you expand on that a bit? I have no idea which helpers gnome might use for a reboot operation.
For reboot on RHEL7, that would go to systemd directly and it would start the process of shutting down. Upstart on RHEL6 might do the same thing.
What might be better to to look on the internet for how to remove shutdown from the menu and then create a new one.
You can add a desktop file in /usr/share/applications/ that runs save session and then runs /sbin/shutdown, call it shutdown.desktop. Next go into /etc/xdg/menus/settings.menu and add
<Include> <Filename>shutdown.desktop</Filename> </Include>
And then I think you are in business. You can then put a watch on /sbin/shutdown and you should get an event. No idea if auid will be -1 or even correct.
This might be a helpful reference in doing the above: http://www.shaunrowland.com/fsync/2011/04/20/removing-shut-down-from-the-gno...
I tried this rule just for fun:
-w /usr/libexec -p rwxa -k libexec
But I didn't see anything related to power when I rebooted the system via Gnome.
That's where the helper apps that are not supposed to be executed directly live. Not all of them matter, You might do something like this:
-a always,exit -F dir=/usr/libexec -F uid=0 -F key=priv-helper
The main issue though is that auid & ses will be -1 so you can't be certain who did it. That is unless you fixed pam_limits to only allow 1 user session. But correlating the event will be challenging due to auid=-1 and ses=-1.
-Steve
On Friday, November 06, 2015 03:38:14 PM Steve Grubb wrote:
On Friday, November 06, 2015 02:39:36 PM Robert Jacobson wrote:
On 2015-11-06 1:28 PM, Steve Grubb wrote:
That said, you can audit some things by placing a watch on specific helpers in /usr/libexec. -Steve
Can you expand on that a bit? I have no idea which helpers gnome might use for a reboot operation.
For reboot on RHEL7, that would go to systemd directly and it would start the process of shutting down. Upstart on RHEL6 might do the same thing.
What might be better to to look on the internet for how to remove shutdown from the menu and then create a new one.
You can add a desktop file in /usr/share/applications/ that runs save session and then runs /sbin/shutdown, call it shutdown.desktop. Next go into /etc/xdg/menus/settings.menu and add
<Include> <Filename>shutdown.desktop</Filename> </Include>
And then I think you are in business. You can then put a watch on /sbin/shutdown and you should get an event. No idea if auid will be -1 or even correct.
This might be a helpful reference in doing the above: http://www.shaunrowland.com/fsync/2011/04/20/removing-shut-down-from-the-gno me-panel-in-rhel-6/comment-page-1/
I tried this rule just for fun:
-w /usr/libexec -p rwxa -k libexec
But I didn't see anything related to power when I rebooted the system via Gnome.
That's where the helper apps that are not supposed to be executed directly live. Not all of them matter, You might do something like this:
-a always,exit -F dir=/usr/libexec -F uid=0 -F key=priv-helper
Forgot one field: -a always,exit -F dir=/usr/libexec -F uid=0 -F perm=x -F key=priv-helper
You could also use euid=0 if that's more fitting.
-Steve
The main issue though is that auid & ses will be -1 so you can't be certain who did it. That is unless you fixed pam_limits to only allow 1 user session. But correlating the event will be challenging due to auid=-1 and ses=-1.
-Steve
Not good. April 22, 2015 https://lwn.net/Articles/641275/
Recent developments indicate that Linus may let it in as early as 4.4 if opponents don't improve their objection. Missed the window for 4.3.
Charlie Todd Ball Aerospace & Technologies Corp.
On Nov 6, 2015, at 1:09 PM, Robert Jacobson Robert.C.Jacobson@nasa.gov wrote:
Thanks for taking the time to write such an informative response.
Is there a roadmap for the kernel dbus module?
--
Robert Jacobson Robert.C.Jacobson@nasa.gov Lead System Admin Solar Dynamics Observatory (SDO) Bldg 14, E222 (301) 286-1591
-- SCAP Security Guide mailing list scap-security-guide@lists.fedorahosted.org https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.fedorahosted.org_... https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_OpenSCAP_sca...
This message and any enclosures are intended only for the addressee. Please notify the sender by email if you are not the intended recipient. If you are not the intended recipient, you may not use, copy, disclose, or distribute this message or its contents or enclosures to any other person and any such actions may be unlawful. Ball reserves the right to monitor and review all messages and enclosures sent to or from this email address.
scap-security-guide@lists.fedorahosted.org