1AUDITCTL:(8)            System Administration Utilities           AUDITCTL:(8)
2
3
4

NAME

6       auditctl - a utility to assist controlling the kernel's audit system
7

SYNOPSIS

9       auditctl [options]
10

DESCRIPTION

12       The  auditctl  program  is  used to configure kernel options related to
13       auditing, to see status of the configuration, and to load discretionary
14       audit rules.
15

CONFIGURATION OPTIONS

17       -b backlog
18              Set  max  number  (limit)  of  outstanding audit buffers allowed
19              (Kernel Default=64) If all buffers are full, the failure flag is
20              consulted by the kernel for action.
21
22       --backlog_wait_time wait_time
23              Set  the time for the kernel to wait (Kernel Default 60*HZ) when
24              the backlog limit is reached before queuing more audit events to
25              be  transferred  to  auditd.  The number must be greater than or
26              equal to zero and less that 10 times the default value.
27
28       -c     Continue loading rules in spite of an error. This summarizes the
29              results  of loading the rules. The exit code will not be success
30              if any rule fails to load.
31
32       -D     Delete all rules and watches. This can take a key  option  (-k),
33              too.
34
35       -e [0..2]
36              Set  enabled  flag. When 0 is passed, this can be used to tempo‐
37              rarily disable auditing. When 1 is passed  as  an  argument,  it
38              will enable auditing. To lock the audit configuration so that it
39              can't be changed, pass a 2 as the argument. Locking the configu‐
40              ration  is  intended  to  be the last command in audit.rules for
41              anyone wishing this feature to be active. Any attempt to  change
42              the  configuration  in this mode will be audited and denied. The
43              configuration can only be changed by rebooting the machine.
44
45       -f [0..2]
46              Set failure mode 0=silent 1=printk 2=panic. This option lets you
47              determine  how  you  want  the kernel to handle critical errors.
48              Example conditions where this mode may have an effect  includes:
49              transmission  errors  to  userspace  audit daemon, backlog limit
50              exceeded, out of kernel memory, and  rate  limit  exceeded.  The
51              default  value  is  1. Secure environments will probably want to
52              set this to 2.
53
54       -h     Help
55
56       -i     When given by itself, ignore errors when reading  rules  from  a
57              file. This causes auditctl to always return a success exit code.
58              If passed as an argument to -s then it gives  an  interpretation
59              of the numbers to human readable words if possible.
60
61       --loginuid-immutable
62              This option tells the kernel to make loginuids unchangeable once
63              they are set. Changing loginuids requires CAP_AUDIT_CONTROL. So,
64              its  not  something that can be done by unprivileged users. Set‐
65              ting this makes loginuid tamper-proof, but can cause some  prob‐
66              lems in certain kinds of containers.
67
68       -q mount-point,subtree
69              If  you  have an existing directory watch and bind or move mount
70              another subtree in the watched subtree, you  need  to  tell  the
71              kernel  to  make  the  subtree  being  mounted equivalent to the
72              directory being watched. If the subtree is  already  mounted  at
73              the time the directory watch is issued, the subtree is automati‐
74              cally tagged for watching. Please note the comma separating  the
75              two values. Omitting it will cause errors.
76
77       -r rate
78              Set limit in messages/sec (0=none). If this rate is non-zero and
79              is exceeded, the failure flag is consulted  by  the  kernel  for
80              action. The default value is 0.
81
82       --reset-lost
83              Reset the lost record counter shown by the status command.
84
85       -R file
86              Read  rules from a file. The rules must be 1 per line and in the
87              order that they are to be executed in. The  rule  file  must  be
88              owned  by  root  and  not  readable by other users or it will be
89              rejected. The rule file may have comments embedded  by  starting
90              the  line  with a '#' character. Rules that are read from a file
91              are identical to what you would type on a  command  line  except
92              they  are  not  preceded  by auditctl (since auditctl is the one
93              executing the file) and you would not use shell  escaping  since
94              auditctl is reading the file instead of bash.
95
96       -t     Trim the subtrees after a mount command.
97

STATUS OPTIONS

99       -l     List all rules 1 per line. Two more options may be given to this
100              command. You can give either a key option  (-k)  to  list  rules
101              that  match a key or a (-i) to have a0 through a3 interpreted to
102              help determine the syscall argument values are correct .
103
104       -m text
105              Send a user space message into the audit system. This  can  only
106              be  done  if  you  have CAP_AUDIT_WRITE capability (normally the
107              root user has this). The resulting event will be the USER type.
108
109       -s     Report the kernel's audit subsystem status. It will tell you the
110              in-kernel  values that can be set by -e, -f, -r, and -b options.
111              The pid value is the process number of the  audit  daemon.  Note
112              that  a pid of 0 indicates that the audit daemon is not running.
113              The lost entry will tell you how many event  records  that  have
114              been  discarded  due  to the kernel audit queue overflowing. The
115              backlog field tells how many event records are currently  queued
116              waiting  for auditd to read them. This option can be followed by
117              the -i to get a couple fields interpreted.
118
119       -v     Print the version of auditctl.
120
121

RULE OPTIONS

123       -a [list,action|action,list]
124              Append rule to the end of list  with  action.  Please  note  the
125              comma  separating the two values. Omitting it will cause errors.
126              The fields may be in either order. It could  be  list,action  or
127              action,list. The following describes the valid list names:
128
129              task        Add  a  rule to the per task list. This rule list is
130                          used only at the time a  task  is  created  --  when
131                          fork()  or  clone()  are  called by the parent task.
132                          When using this list, you  should  only  use  fields
133                          that  are  known  at task creation time, such as the
134                          uid, gid, etc.
135
136              exit        Add a rule to the syscall exit list.  This  list  is
137                          used upon exit from a system call to determine if an
138                          audit event should be created.
139
140              user        Add a rule to the user  message  filter  list.  This
141                          list  is  used by the kernel to filter events origi‐
142                          nating in user space before  relaying  them  to  the
143                          audit  daemon.  It  should  be  noted  that the only
144                          fields that are valid  are:  uid,  auid,  gid,  pid,
145                          subj_user, subj_role, subj_type, subj_sen, subj_clr,
146                          msgtype, and executable name. All other fields  will
147                          be  treated as non-matching. It should be understood
148                          that any event originating from user  space  from  a
149                          process  that  has  CAP_AUDIT_WRITE will be recorded
150                          into the audit  trail.  This  means  that  the  most
151                          likely  use  for this filter is with rules that have
152                          an action of never since nothing has to be  done  to
153                          allow events to be recorded.
154
155              exclude     Add  a rule to the event type exclusion filter list.
156                          This list is used to filter events that you  do  not
157                          want  to see. For example, if you do not want to see
158                          any avc messages,  you  would  using  this  list  to
159                          record  that.  Events can be excluded by process ID,
160                          user ID, group ID, login user ID, message type, sub‐
161                          ject  context,  or  executable  name.  The action is
162                          ignored and uses its default of "never".
163
164              filesystem  Add a rule that will be applied to a whole  filesys‐
165                          tem. The filesystem must be identified with a fstype
166                          field. Normally this filter is used to  exclude  any
167                          events  for  a  whole  filesystem such as tracefs or
168                          debugfs.
169
170       The following describes the valid actions for the rule:
171
172              never       No audit records will be generated. This can be used
173                          to  suppress  event generation. In general, you want
174                          suppressions at the top of the list instead  of  the
175                          bottom.  This  is  because the event triggers on the
176                          first matching rule.
177
178              always      Allocate an audit context,  always  fill  it  in  at
179                          syscall entry time, and always write out a record at
180                          syscall exit time.
181
182       -A list,action
183              Add rule to the beginning list with action.
184
185       -C [f=f | f!=f]
186              Build an inter-field comparison rule: field,  operation,  field.
187              You may pass multiple comparisons on a single command line. Each
188              one must start with -C. Each inter-field equation is anded  with
189              each  other  as well as equations starting with -F to trigger an
190              audit record. There are 2 operators supported - equal,  and  not
191              equal. Valid fields are:
192
193              auid,  uid,  euid,  suid,  fsuid,  obj_uid; and gid, egid, sgid,
194              fsgid, obj_gid
195
196              The two groups of uid and gid cannot be mixed. But any  compari‐
197              son  within  the  group  can be made. The obj_uid/gid fields are
198              collected from the object of the event such as a file or  direc‐
199              tory.
200
201
202       -d list,action
203              Delete  rule  from list with action. The rule is deleted only if
204              it exactly matches syscall name(s)  and  every  field  name  and
205              value.
206
207       -F [n=v | n!=v | n<v | n>v | n<=v | n>=v | n&v | n&=v]
208              Build  a  rule field: name, operation, value. You may have up to
209              64 fields passed on a single command line. Each one  must  start
210              with  -F.  Each field equation is anded with each other (as well
211              as equations starting with -C) to trigger an audit record. There
212              are 8 operators supported - equal, not equal, less than, greater
213              than, less than or equal, and greater than or equal,  bit  mask,
214              and  bit  test  respectively. Bit test will "and" the values and
215              check that they are equal, bit  mask  just  "ands"  the  values.
216              Fields that take a user ID may instead have the user's name; the
217              program will convert the name to user ID. The same  is  true  of
218              group names. Valid fields are:
219
220              a0, a1, a2, a3
221                          Respectively,  the  first  4 arguments to a syscall.
222                          Note that string arguments are not  supported.  This
223                          is  because  the  kernel  is passed a pointer to the
224                          string. Triggering on a pointer address value is not
225                          likely to work. So, when using this, you should only
226                          use on numeric values. This is  most  likely  to  be
227                          used on platforms that multiplex socket or IPC oper‐
228                          ations.
229
230              arch        The CPU architecture of the syscall. The arch can be
231                          found  doing 'uname -m'. If you do not know the arch
232                          of your machine but you  want  to  use  the  32  bit
233                          syscall  table and your machine supports 32 bit, you
234                          can also use b32 for the arch. The same  applies  to
235                          the  64 bit syscall table, you can use b64.  In this
236                          way, you can write  rules  that  are  somewhat  arch
237                          independent  because  the  family  type will be auto
238                          detected. However, syscalls can be arch specific and
239                          what is available on x86_64, may not be available on
240                          ppc. The arch directive should precede the -S option
241                          so  that  auditctl knows which internal table to use
242                          to look up the syscall numbers.
243
244              auid        The original ID the user  logged  in  with.  Its  an
245                          abbreviation of audit uid. Sometimes its referred to
246                          as loginuid. Either the user account text or  number
247                          may be used.
248
249              devmajor    Device Major Number
250
251              devminor    Device Minor Number
252
253              dir         Full  Path  of Directory to watch. This will place a
254                          recursive watch on the directory and its whole  sub‐
255                          tree. It can only be used on exit list. See "-w".
256
257              egid        Effective  Group  ID.  May  be numeric or the groups
258                          name.
259
260              euid        Effective User  ID.  May  be  numeric  or  the  user
261                          account name.
262
263              exe         Absolute  path  to  application that while executing
264                          this rule will apply to. It supports = and != opera‐
265                          tors.  Note that you can only use this once for each
266                          rule.
267
268              exit        Exit value from a syscall. If the exit  code  is  an
269                          errno, you may use the text representation, too.
270
271              fsgid       Filesystem  Group  ID.  May be numeric or the groups
272                          name.
273
274              fsuid       Filesystem User ID.  May  be  numeric  or  the  user
275                          account name.
276
277              filetype    The  target  file's  type.  Can be either file, dir,
278                          socket, link, character, block, or fifo.
279
280              gid         Group ID. May be numeric or the groups name.
281
282              inode       Inode Number
283
284              key         This is another way of setting  a  filter  key.  See
285                          discussion above for -k option.
286
287              msgtype     This  is  used  to match the event's record type. It
288                          should only be used on the exclude  or  user  filter
289                          lists.
290
291              obj_uid     Object's UID
292
293              obj_gid     Object's GID
294
295              obj_user    Resource's SE Linux User
296
297              obj_role    Resource's SE Linux Role
298
299              obj_type    Resource's SE Linux Type
300
301              obj_lev_low Resource's SE Linux Low Level
302
303              obj_lev_high
304                          Resource's SE Linux High Level
305
306              path        Full  Path  of File to watch. It can only be used on
307                          exit list.
308
309              perm        Permission filter for file operations. See "-p".  It
310                          can  only  be  used  on  exit list. You can use this
311                          without specifying a syscall  and  the  kernel  will
312                          select  the  syscalls  that  satisfy the permissions
313                          being requested.
314
315              pers        OS Personality Number
316
317              pid         Process ID
318
319              ppid        Parent's Process ID
320
321              saddr_fam   Address    family     number     as     found     in
322                          /usr/include/bits/socket.h.  For example, IPv4 would
323                          be 2 and IPv6 would be 10.
324
325              sessionid   User's login session ID
326
327              subj_user   Program's SE Linux User
328
329              subj_role   Program's SE Linux Role
330
331              subj_type   Program's SE Linux Type
332
333              subj_sen    Program's SE Linux Sensitivity
334
335              subj_clr    Program's SE Linux Clearance
336
337              sgid        Saved Group ID. See getresgid(2) man page.
338
339              success     If the exit value is >= 0 this is true/yes otherwise
340                          its  false/no.  When  writing  a  rule,  use a 1 for
341                          true/yes and a 0 for false/no
342
343              suid        Saved User ID. See getresuid(2) man page.
344
345              uid         User ID. May be numeric or the user account name.
346
347       -k key Set a filter key on an audit rule. The filter key  is  an  arbi‐
348              trary  string  of  text  that can be up to 31 bytes long. It can
349              uniquely identify the audit records produced by a rule.  Typical
350              use  is  for when you have several rules that together satisfy a
351              security requirement. The key value  can  be  searched  on  with
352              ausearch  so  that no matter which rule triggered the event, you
353              can find its results. The key can also be  used  on  delete  all
354              (-D)  and  list  rules (-l) to select rules with a specific key.
355              You may have more than one key on a rule if you want to be  able
356              to  search  logged  events  in  multiple  ways or if you have an
357              auditd plugin that uses a key to aid its analysis.
358
359       -p [r|w|x|a]
360              Describe the permission access type that  a  file  system  watch
361              will trigger on. r=read, w=write, x=execute, a=attribute change.
362              These permissions are not the  standard  file  permissions,  but
363              rather the kind of syscall that would do this kind of thing. The
364              read & write syscalls are omitted from this set since they would
365              overwhelm  the  logs.  But  rather for reads or writes, the open
366              flags are looked at to see what permission was requested.
367
368       -S [Syscall name or number|all]
369              Any syscall name or number may be used. The word 'all' may  also
370              be  used.  If the given syscall is made by a program, then start
371              an audit record. If a field rule is  given  and  no  syscall  is
372              specified, it will default to all syscalls. You may also specify
373              multiple syscalls in the same rule by using multiple -S  options
374              in  the  same  rule.  Doing  so improves performance since fewer
375              rules need to be evaluated. Alternatively, you may pass a  comma
376              separated list of syscall names. If you are on a bi-arch system,
377              like x86_64, you should be aware that auditctl simply takes  the
378              text,  looks  it  up  for the native arch (in this case b64) and
379              sends that rule to the kernel. If there are no  additional  arch
380              directives, IT WILL APPLY TO BOTH 32 & 64 BIT SYSCALLS. This can
381              have undesirable effects since there is no  guarantee  that  any
382              syscall  has  the  same number on both 32 and 64 bit interfaces.
383              You will likely want to control this and write 2 rules, one with
384              arch equal to b32 and one with b64 to make sure the kernel finds
385              the events that you intend. See the arch  field  discussion  for
386              more info.
387
388       -w path
389              Insert  a  watch  for the file system object at path. You cannot
390              insert a watch to the top level directory. This is prohibited by
391              the kernel. Wildcards are not supported either and will generate
392              a warning. The way that watches work is by  tracking  the  inode
393              internally.  If  you  place  a  watch on a file, its the same as
394              using the -F path option on a syscall rule. If you place a watch
395              on  a  directory,  its  the same as using the -F dir option on a
396              syscall rule. The -w form of writing watches  is  for  backwards
397              compatibility  and  the  syscall  based form is more expressive.
398              Unlike most syscall auditing rules, watches do not  impact  per‐
399              formance  based  on  the number of rules sent to the kernel. The
400              only valid options when using a watch are the -p and -k. If  you
401              need  to  anything  fancy like audit a specific user accessing a
402              file, then use the syscall auditing form with the  path  or  dir
403              fields.  See  the  EXAMPLES section for an example of converting
404              one form to another.
405
406       -W path
407              Remove a watch for the file system object at path. The rule must
408              match exactly. See -d discussion for more info.
409

PERFORMANCE TIPS

411       Syscall  rules get evaluated for each syscall for every program. If you
412       have 10 syscall rules, every program on your system will delay during a
413       syscall  while  the  audit system evaluates each rule. Too many syscall
414       rules will hurt performance. Try to combine as many as you can whenever
415       the filter, action, key, and fields are identical. For example:
416
417       auditctl -a always,exit -S openat -F success=0
418       auditctl -a always,exit -S truncate -F success=0
419
420       could be re-written as one rule:
421
422       auditctl -a always,exit -S openat -S truncate -F success=0
423
424       Also, try to use file system auditing wherever practical. This improves
425       performance. For example, if you were wanting  to  capture  all  failed
426       opens  &  truncates  like above, but were only concerned about files in
427       /etc and didn't care about /usr or /sbin,  its  possible  to  use  this
428       rule:
429
430       auditctl -a always,exit -S openat -S truncate -F dir=/etc -F success=0
431
432       This  will  be higher performance since the kernel will not evaluate it
433       each and every syscall. It will be handled by the  filesystem  auditing
434       code and only checked on filesystem related syscalls.
435

EXAMPLES

437       To see all syscalls made by a specific program:
438
439       auditctl -a always,exit -S all -F pid=1005
440
441       To see files opened by a specific user:
442
443       auditctl -a always,exit -S openat -F auid=510
444
445       To see unsuccessful openat calls:
446
447       auditctl -a always,exit -S openat -F success=0
448
449       To watch a file for changes (2 ways to express):
450
451       auditctl -w /etc/shadow -p wa
452       auditctl -a always,exit -F path=/etc/shadow -F perm=wa
453
454       To recursively watch a directory for changes (2 ways to express):
455
456       auditctl -w /etc/ -p wa
457       auditctl -a always,exit -F dir=/etc/ -F perm=wa
458
459       To see if an admin is accessing other user's files:
460
461       auditctl -a always,exit -F dir=/home/ -F uid=0 -C auid!=obj_uid
462
463

FILES

465       /etc/audit/audit.rules /etc/audit/audit-stop.rules
466
467

SEE ALSO

469       audit.rules(7), auditd(8).
470
471

AUTHOR

473       Steve Grubb
474
475
476
477Red Hat                            Aug 2018                       AUDITCTL:(8)
Impressum