<div dir="ltr"><div dir="auto">So,</div><div dir="auto"><br></div><div dir="auto">Based on this and some experiments I have been performing, I would suggest changing how a lot of the FileSystem rules are written and illustrated.</div><div>Ex - <a href="https://github.com/linux-audit/audit-userspace/blob/master/rules/30-pci-dss-v31.rules#L34-L35">https://github.com/linux-audit/audit-userspace/blob/master/rules/30-pci-dss-v31.rules#L34-L35</a></div><div><br></div><div>The rule in the repository is</div><div>-a always,exit -F path=/etc/sudoers -F perm=wa -F key=10.2.2-priv-config-changes<br></div><div><br></div><div>My suggestion is to instead change the rule based on the permissions defined. The above rule would change to the following based on the kernel being used.</div><div>-a always,exit -S <list of syscalls in audit_write.h and audit_read.h +open,openat> -F path=/etc/sudoers -F perm=wa -F key=10.2.2-priv-config-changes<br></div><div><br></div><div>This is higher performance because we are limiting the syscalls instead of making use of -S all which has more paths of evaluation for each and every syscall.</div><div><br></div><div>Same thing for watches. Watches are inherently -S all rules which are very performance intensive.</div><div><a href="https://github.com/linux-audit/audit-userspace/blob/1482cec74f2d9472f81dd4f0533484bd0c26decd/lib/libaudit.c#L805">https://github.com/linux-audit/audit-userspace/blob/1482cec74f2d9472f81dd4f0533484bd0c26decd/lib/libaudit.c#L805</a><br></div><div><br></div><div>Ideally we should limit the syscalls based on the permissions being used. </div><div><br></div><div>I have implemented the same in my environment rules and have noticed a massive performance difference with no difference in the events being logged since we anyways filter eventually based on the permissions.</div><div><br></div><div>Let me know what you all think.</div><div><br></div><div>Ali Adnan.</div><div><br></div><div><br></div><div><br></div><div><br></div></div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Sep 6, 2023 at 2:58 PM Richard Guy Briggs <<a href="mailto:rgb@redhat.com" target="_blank">rgb@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 2023-09-06 10:56, Amjad Gabbar wrote:<br>
> Hi,<br>
> <br>
> I have done some analysis and digging into how both the watch rules and<br>
> syscall rules are translated.<br>
> <br>
> From my understanding, in terms of logging, both the below rules are<br>
> similar. There is no difference in either of the rules.<br>
> <br>
> 1. -w /etc -p wa -k ETC_WATCH<br>
<br>
They are similar in this case.<br>
-w behaves differently depending on the existance of the watched entity<br>
and the presence of a trailing "/".  This is why the form above is<br>
deprecated.<br>
<br>
> 2. -a always,exit -F arch=b64 -S <all syscalls part of the write and attr<br>
> classes> -F dir=/etc  -F perm=wa -k ETC_WATCH<br>
> <br>
> The write and attr classes consist of syscalls in<br>
> “include/asm-generic/audit_*.h“.<br>
> <br>
>  The perm flag is needed in the second case for including open/openat<br>
> syscalls which are not a part of the write and attr syscall list.<br>
> <br>
> I'd like to verify if what I mentioned earlier is accurate, and I have an<br>
> additional point but depends on whether this is accurate.<br>
> <br>
> Ali<br>
<br>
- RGB<br>
<br>
--<br>
Richard Guy Briggs <<a href="mailto:rgb@redhat.com" target="_blank">rgb@redhat.com</a>><br>
Sr. S/W Engineer, Kernel Security, Base Operating Systems<br>
Remote, Ottawa, Red Hat Canada<br>
Upstream IRC: SunRaycer<br>
Voice: +1.613.860 2354 SMS: +1.613.518.6570<br>
<br>
</blockquote></div></div>