My server is centos7.6 with auditd 2.8.5
In audit rule, I set:
-a always,exit -F arch=b32 -S adjtimex,settimeofday -F key=time-change
But this rule also record normal ntpd
activities,then I tried to revise this rule to:
-a always,exit -F arch=b32 -S adjtimex,settimeofday,stime -F subj_type!=ntpd_t -F auid!=chrony -F auid!=ntp -F auid!=chrony -F auid!=ntp -F key=time-change
Should use auid!=ntp
or uid!=ntp
? I checked the manual:
Each inter-field equation is anded with each other as well as equations starting with -F to trigger an audit record. There are 2 operators supported - equal, and not equal. Valid fields are: auid, uid, euid, suid, fsuid, obj_uid, gid, egid, sgid, fsgid, obj_gid
I am confused, what's the difference between auid, uid, euid, suid, fsuid, obj_uid, gid, egid, sgid, fsgid, obj_gid in auditctl
?
The audit manual assumes you are familiar with a POSIX security model and the many types of uids. Read man credentials to get more familiar with that. However, that is incomplete, reference a security guide (such as the RHEL Audit System Reference) for the rest. Notably:
A rule and its exceptions could be written on one line for efficiency. However, I sometimes start with more simpler rules. Easier to understand, and piece together examples.
auditd ships with example rules for auditing time change and ignoring chronyd. Look at
/usr/share/doc/audit*/rules/22-ignore-chrony.rules
:"On a 64 bit platform, for the adjtimex call, when audit UID does not exist (not a login shell), and user name is chrony, and SELinux context is chronyd_t, never log."
Actually, that example may have a bug. With chronyd running under systemd, and the example rules from
30-pci-dss-v31.rules
, I found audit events as uid 0.ps reports it running as user chrony, and in the chronyd_t context. So it is confined, but auditd reflects how systemd started it as root.
Try the condition
-F auid=unset -F subj_type=chronyd_t
. Not from a login shell and in the correct context is good enough for me.(This subsystem has its quirks. The only place I was able to translate auid=4294967295 to unset is the mailing list.)