SELinux for auditing
I have a couple of requirements which on the face of it don't seem simple to achieve with auditctl. These are:
* Audit changes to executables
* Audit changes to configuration files
I'll concentrate on the former as it's more obviously problematic. I believe this would require putting a watch explicitly on every executable in the system. If this isn't correct, please correct me and this problem goes away. Assuming it is, though, I don't believe this is a practical solution.
It occurs to me that this might be more easily achieved with SELinux. As a test, I made the following small change to the unconfined domain of the RHEL 4 targeted policy macros/global_macros.te:
define(executable_files', { exec_type sbin_t bin_t lib_t shlib_t ld_so_t }')
#allow $1 file_type:dir_file_class_set *;
allow $1 file_type:dir_file_class_set ~execute;
allow $1 executable_files:dir_file_class_set *;
auditallow $1 executable_files:dir_file_class_set { create write rename setattr append relabelfrom };
This does 2 things. Firstly it enforces that the system won't execute files which aren't labelled with an executable type. This is really just to make sure everything is caught by the second rule, which is to audit changes to executables. To make this thorough, you'd have to go through everywhere else execute is granted in other domains.
However, I'm worried I might be stepping outside design intentions. Is the above a good idea? Is using SELinux for writing auditing rules a good idea in general? uIs there a better way to achieve this and similar requirements which affect a potentially large class of file?
Thanks,
Matt
Signature · 5 lines
Red Hat, Global Professional Services M: +44 (0)7977 267231 GPG ID: D33C3490 GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490
Quoted 9 lines · Matthew Booth
I have a couple of requirements which on the face of it don't seem simple to achieve with auditctl. These are:
* Audit changes to executables
* Audit changes to configuration filesI'll concentrate on the former as it's more obviously problematic. I believe this would require putting a watch explicitly on every executable in the system.
Assuming current generation of audit code...
auditctl -a exit,always -F perm=w -F obj_type=sbin_t -k executables auditctl -a exit,always -F perm=w -F obj_type=bin_t -k executables auditctl -a exit,always -F perm=w -F obj_type=lib_t -k executables auditctl -a exit,always -F perm=w -F obj_type=shlib_t -k executables
Quoted 1 line
If this isn't correct, please correct me and this problem goes away.
Try the above. "ausearch -k executables" would let you find these events.
Quoted 2 lines
This does 2 things. Firstly it enforces that the system won't execute files which aren't labelled with an executable type.
This might not be a bad thing to include even if the audit rules above solve your problem.
Quoted 2 lines
However, I'm worried I might be stepping outside design intentions. Is the above a good idea?
I'm hoping the audit system can meet any audit requirements. If not we need to work some more at it.
Quoted 1 line
Is using SELinux for writing auditing rules a good idea in general?
If there are shortcomings in the audit system that you can solve another way, I guess you have no choice. But we'd like to know that people cannot use the audit system for its intended purpose.
-Steve
Quoted 7 lines · Steve Grubb
Quoted 6 lines · Matthew Booth
I have a couple of requirements which on the face of it don't seem simple to achieve with auditctl. These are:
* Audit changes to executables
* Audit changes to configuration files
Quoted 7 lines
Quoted 3 lines
I'll concentrate on the former as it's more obviously problematic. I believe this would require putting a watch explicitly on every executable in the system.
Assuming current generation of audit code...
auditctl -a exit,always -F perm=w -F obj_type=sbin_t -k executables
Hmmm...on FC6, that yields an error from auditctl:
key option needs a watch or syscall given prior to it
Dropping the -k option avoids the error message, but overwriting a bin_t file doesn't generate any audit message. Similarly, adding a -S open avoids the error message while retaining the -k, but overwriting a bin_t file doesn't generate any audit message. Not sure where the problem lies there.
Also, he mentioned RHEL 4 as his platform, so I would tend to think that his kernel and auditctl wouldn't support this anyway. So he may be limited to using auditallow statements in policy, which is certainly legitimate use of them (although I understand your goal of centralizing audit configuration).
Signature · 2 lines
Stephen Smalley National Security Agency
Quoted 6 lines · Stephen Smalley
Quoted 3 lines
Assuming current generation of audit code...
auditctl -a exit,always -F perm=w -F obj_type=sbin_t -k executables
Hmmm...on FC6, that yields an error from auditctl:
key option needs a watch or syscall given prior to it
Ooops, that should be:
auditctl -a exit,always -F perm=w -F obj_type=bin_t -F key=executable
Quoted 5 lines
Dropping the -k option avoids the error message, but overwriting a
bin_tfile doesn't generate any audit message. Similarly, adding a -S open avoids the error message while retaining the -k, but overwriting abin_tfile doesn't generate any audit message. Not sure where the problem lies there.
OK, we should look into this.
Quoted 2 lines
Also, he mentioned RHEL 4 as his platform, so I would tend to think that his kernel and auditctl wouldn't support this anyway.
If so, it won't.
Quoted 3 lines
So he may be limited to using auditallow statements in policy, which is certainly legitimate use of them (although I understand your goal of centralizing audit configuration).
Well, not just centralizing configuration, but that its actually fit for its purpose. :)
-Steve
Quoted 5 lines · Stephen Smalley
Also, he mentioned RHEL 4 as his platform, so I would tend to think that his kernel and auditctl wouldn't support this anyway. So he may be limited to using auditallow statements in policy, which is certainly legitimate use of them (although I understand your goal of centralizing audit configuration).
It is for RHEL 4, so the above won't work. How much of the functionality is in userspace, and how much requires extra kernel bits? In short, can I recompile the RHEL5 auditd for RHEL4 and expect to get additional functionality?
Matt
Signature · 5 lines
Red Hat, Global Professional Services M: +44 (0)7977 267231 GPG ID: D33C3490 GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490
Quoted 2 lines · Matthew Booth
How much of the functionality is in userspace, and how much requires extra kernel bits?
The identification of syscalls that becomes an event is done by the kernel. Userspace just send rules into the kernel and records what the kernel sees.
Quoted 2 lines
In short, can I recompile the RHEL5 auditd for RHEL4 and expect to get additional functionality?
Not really for 2 reasons. One being that the watch technique is totally different and incompatible between current user space and the old 1.0.x series. The other being that the interesting work is done by the kernel.
That said, there is an update to RHEL4 audit (1.0.15-2) that introduces the realtime interface from RHEL5 that should be part of the U5 update. That could be handy for moving events off the machine in realtime.
-Steve
Quoted 9 lines · On Thursday 01 February 2007 09:59:00 Stephen Smalley wrote:
Quoted 3 lines
Assuming current generation of audit code...
auditctl -a exit,always -F perm=w -F obj_type=sbin_t -k executables
Hmmm...on FC6, that yields an error from auditctl:
key option needs a watch or syscall given prior to itDropping the -k option avoids the error message, but overwriting a
bin_tfile doesn't generate any audit message.
This turned out to be a bug in libaudit which was fixed in 1.4.1. It should work as I stated above when you upgrade. If not, let me know...
-Steve