1AUDITCTL:(8) System Administration Utilities AUDITCTL:(8)
2
3
4
6 auditctl - a utility to assist controlling the kernel's audit system
7
9 auditctl [options]
10
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
17 -b backlog
18 Set max number of outstanding audit buffers allowed (Kernel
19 Default=64) If all buffers are full, the failure flag is con‐
20 sulted 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
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
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 and msgtype. All other fields will be treated as
147 non-matching. It should be understood that any event
148 originating from user space from a process that has
149 CAP_AUDIT_WRITE will be recorded into the audit
150 trail. This means that the most likely use for this
151 filter is with rules that have an action of never
152 since nothing has to be done to allow events to be
153 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 or
161 subject context. The action is ignored and uses its
162 default of "never".
163
164 The following describes the valid actions for the rule:
165
166 never No audit records will be generated. This can be used
167 to suppress event generation. In general, you want
168 suppressions at the top of the list instead of the
169 bottom. This is because the event triggers on the
170 first matching rule.
171
172 always Allocate an audit context, always fill it in at
173 syscall entry time, and always write out a record at
174 syscall exit time.
175
176 -A list,action
177 Add rule to the beginning list with action.
178
179 -C [f=f | f!=f]
180 Build an inter-field comparison rule: field, operation, field.
181 You may pass multiple comparisons on a single command line. Each
182 one must start with -C. Each inter-field equation is anded with
183 each other as well as equations starting with -F to trigger an
184 audit record. There are 2 operators supported - equal, and not
185 equal. Valid fields are:
186
187 auid, uid, euid, suid, fsuid, obj_uid; and gid, egid, sgid,
188 fsgid, obj_gid
189
190 The two groups of uid and gid cannot be mixed. But any compari‐
191 son within the group can be made. The obj_uid/gid fields are
192 collected from the object of the event such as a file or direc‐
193 tory.
194
195
196 -d list,action
197 Delete rule from list with action. The rule is deleted only if
198 it exactly matches syscall name(s) and every field name and
199 value.
200
201 -F [n=v | n!=v | n<v | n>v | n<=v | n>=v | n&v | n&=v]
202 Build a rule field: name, operation, value. You may have up to
203 64 fields passed on a single command line. Each one must start
204 with -F. Each field equation is anded with each other (as well
205 as equations starting with -C) to trigger an audit record. There
206 are 8 operators supported - equal, not equal, less than, greater
207 than, less than or equal, and greater than or equal, bit mask,
208 and bit test respectively. Bit test will "and" the values and
209 check that they are equal, bit mask just "ands" the values.
210 Fields that take a user ID may instead have the user's name; the
211 program will convert the name to user ID. The same is true of
212 group names. Valid fields are:
213
214 a0, a1, a2, a3
215 Respectively, the first 4 arguments to a syscall.
216 Note that string arguments are not supported. This
217 is because the kernel is passed a pointer to the
218 string. Triggering on a pointer address value is not
219 likely to work. So, when using this, you should only
220 use on numeric values. This is most likely to be
221 used on platforms that multiplex socket or IPC oper‐
222 ations.
223
224 arch The CPU architecture of the syscall. The arch can be
225 found doing 'uname -m'. If you do not know the arch
226 of your machine but you want to use the 32 bit
227 syscall table and your machine supports 32 bit, you
228 can also use b32 for the arch. The same applies to
229 the 64 bit syscall table, you can use b64. In this
230 way, you can write rules that are somewhat arch
231 independent because the family type will be auto
232 detected. However, syscalls can be arch specific and
233 what is available on x86_64, may not be available on
234 ppc. The arch directive should precede the -S option
235 so that auditctl knows which internal table to use
236 to look up the syscall numbers.
237
238 auid The original ID the user logged in with. Its an
239 abbreviation of audit uid. Sometimes its referred to
240 as loginuid. Either the user account text or number
241 may be used.
242
243 devmajor Device Major Number
244
245 devminor Device Minor Number
246
247 dir Full Path of Directory to watch. This will place a
248 recursive watch on the directory and its whole sub‐
249 tree. It can only be used on exit list. See "-w".
250
251 egid Effective Group ID. May be numeric or the groups
252 name.
253
254 euid Effective User ID. May be numeric or the user
255 account name.
256
257 exe Absolute path to application that while executing
258 this rule will apply to. This can only be used on
259 the exit list. It supports = and != operators. Note
260 that you can only use this once for each rule.
261
262 exit Exit value from a syscall. If the exit code is an
263 errno, you may use the text representation, too.
264
265 fsgid Filesystem Group ID. May be numeric or the groups
266 name.
267
268 fsuid Filesystem User ID. May be numeric or the user
269 account name.
270
271 filetype The target file's type. Can be either file, dir,
272 socket, link, character, block, or fifo.
273
274 gid Group ID. May be numeric or the groups name.
275
276 inode Inode Number
277
278 key This is another way of setting a filter key. See
279 discussion above for -k option.
280
281 msgtype This is used to match the event's record type. It
282 should only be used on the exclude or user filter
283 lists.
284
285 obj_uid Object's UID
286
287 obj_gid Object's GID
288
289 obj_user Resource's SE Linux User
290
291 obj_role Resource's SE Linux Role
292
293 obj_type Resource's SE Linux Type
294
295 obj_lev_low Resource's SE Linux Low Level
296
297 obj_lev_high
298 Resource's SE Linux High Level
299
300 path Full Path of File to watch. It can only be used on
301 exit list.
302
303 perm Permission filter for file operations. See "-p". It
304 can only be used on exit list. You can use this
305 without specifying a syscall and the kernel will
306 select the syscalls that satisfy the permissions
307 being requested.
308
309 pers OS Personality Number
310
311 pid Process ID
312
313 ppid Parent's Process ID
314
315 sessionid User's login session ID
316
317 subj_user Program's SE Linux User
318
319 subj_role Program's SE Linux Role
320
321 subj_type Program's SE Linux Type
322
323 subj_sen Program's SE Linux Sensitivity
324
325 subj_clr Program's SE Linux Clearance
326
327 sgid Saved Group ID. See getresgid(2) man page.
328
329 success If the exit value is >= 0 this is true/yes otherwise
330 its false/no. When writing a rule, use a 1 for
331 true/yes and a 0 for false/no
332
333 suid Saved User ID. See getresuid(2) man page.
334
335 uid User ID. May be numeric or the user account name.
336
337 -k key Set a filter key on an audit rule. The filter key is an arbi‐
338 trary string of text that can be up to 31 bytes long. It can
339 uniquely identify the audit records produced by a rule. Typical
340 use is for when you have several rules that together satisfy a
341 security requirement. The key value can be searched on with
342 ausearch so that no matter which rule triggered the event, you
343 can find its results. The key can also be used on delete all
344 (-D) and list rules (-l) to select rules with a specific key.
345 You may have more than one key on a rule if you want to be able
346 to search logged events in multiple ways or if you have an
347 auditd plugin that uses a key to aid its analysis.
348
349 -p [r|w|x|a]
350 Describe the permission access type that a file system watch
351 will trigger on. r=read, w=write, x=execute, a=attribute change.
352 These permissions are not the standard file permissions, but
353 rather the kind of syscall that would do this kind of thing. The
354 read & write syscalls are omitted from this set since they would
355 overwhelm the logs. But rather for reads or writes, the open
356 flags are looked at to see what permission was requested.
357
358 -S [Syscall name or number|all]
359 Any syscall name or number may be used. The word 'all' may also
360 be used. If the given syscall is made by a program, then start
361 an audit record. If a field rule is given and no syscall is
362 specified, it will default to all syscalls. You may also specify
363 multiple syscalls in the same rule by using multiple -S options
364 in the same rule. Doing so improves performance since fewer
365 rules need to be evaluated. Alternatively, you may pass a comma
366 separated list of syscall names. If you are on a bi-arch system,
367 like x86_64, you should be aware that auditctl simply takes the
368 text, looks it up for the native arch (in this case b64) and
369 sends that rule to the kernel. If there are no additional arch
370 directives, IT WILL APPLY TO BOTH 32 & 64 BIT SYSCALLS. This can
371 have undesirable effects since there is no guarantee that any
372 syscall has the same number on both 32 and 64 bit interfaces.
373 You will likely want to control this and write 2 rules, one with
374 arch equal to b32 and one with b64 to make sure the kernel finds
375 the events that you intend. See the arch field discussion for
376 more info.
377
378 -w path
379 Insert a watch for the file system object at path. You cannot
380 insert a watch to the top level directory. This is prohibited by
381 the kernel. Wildcards are not supported either and will generate
382 a warning. The way that watches work is by tracking the inode
383 internally. If you place a watch on a file, its the same as
384 using the -F path option on a syscall rule. If you place a watch
385 on a directory, its the same as using the -F dir option on a
386 syscall rule. The -w form of writing watches is for backwards
387 compatibility and the syscall based form is more expressive.
388 Unlike most syscall auditing rules, watches do not impact per‐
389 formance based on the number of rules sent to the kernel. The
390 only valid options when using a watch are the -p and -k. If you
391 need to anything fancy like audit a specific user accessing a
392 file, then use the syscall auditing form with the path or dir
393 fields. See the EXAMPLES section for an example of converting
394 one form to another.
395
396 -W path
397 Remove a watch for the file system object at path. The rule must
398 match exactly. See -d discussion for more info.
399
401 Syscall rules get evaluated for each syscall for every program. If you
402 have 10 syscall rules, every program on your system will delay during a
403 syscall while the audit system evaluates each rule. Too many syscall
404 rules will hurt performance. Try to combine as many as you can whenever
405 the filter, action, key, and fields are identical. For example:
406
407 auditctl -a always,exit -S openat -F success=0
408 auditctl -a always,exit -S truncate -F success=0
409
410 could be re-written as one rule:
411
412 auditctl -a always,exit -S openat -S truncate -F success=0
413
414 Also, try to use file system auditing wherever practical. This improves
415 performance. For example, if you were wanting to capture all failed
416 opens & truncates like above, but were only concerned about files in
417 /etc and didn't care about /usr or /sbin, its possible to use this
418 rule:
419
420 auditctl -a always,exit -S openat -S truncate -F dir=/etc -F success=0
421
422 This will be higher performance since the kernel will not evaluate it
423 each and every syscall. It will be handled by the filesystem auditing
424 code and only checked on filesystem related syscalls.
425
427 To see all syscalls made by a specific program:
428
429 auditctl -a always,exit -S all -F pid=1005
430
431 To see files opened by a specific user:
432
433 auditctl -a always,exit -S openat -F auid=510
434
435 To see unsuccessful openat calls:
436
437 auditctl -a always,exit -S openat -F success=0
438
439 To watch a file for changes (2 ways to express):
440
441 auditctl -w /etc/shadow -p wa
442 auditctl -a always,exit -F path=/etc/shadow -F perm=wa
443
444 To recursively watch a directory for changes (2 ways to express):
445
446 auditctl -w /etc/ -p wa
447 auditctl -a always,exit -F dir=/etc/ -F perm=wa
448
449 To see if an admin is accessing other user's files:
450
451 auditctl -a always,exit -F dir=/home/ -F uid=0 -C auid!=obj_uid
452
453
455 /etc/audit/audit.rules /etc/audit/audit-stop.rules
456
457
459 audit.rules(7), auditd(8).
460
461
463 Steve Grubb
464
465
466
467Red Hat Aug 2018 AUDITCTL:(8)