- Unix Commands Reference
- Unix Commands - Home
auditctl - Unix, Linux Command
NAME
auditctl - a utility to assist controlling the kernels audit systemSYNOPSIS
auditctl [options]DESCRIPTION
The auditctl program is used to control the behavior, get status, and add or delete rules into the 2.6 kernels audit system.OPTIONS
Tag | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
-b backlog | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Set max number of outstanding audit buffers allowed (Kernel Default=64) If all buffers are full, the failure flag is consulted by the kernel for action. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-e [0..2] | Set enabled flag. When 0 is passed, this can be used to temporarily disable auditing. When 1 is passed as an argument, it will enable auditing. To lock the audit configuration so that it cant be changed, pass a 2 as the argument. Locking the configuration is intended to be the last command in audit.rules for anyone wishing this feature to be active. Any attempt to change the configuration in this mode will be audited and denied. The configuration can only be changed by rebooting the machine. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-f [0..2] | Set failure flag 0=silent 1=printk 2=panic. This option lets you determine how you want the kernel to handle critical errors. Example conditions where this flag is consulted includes: transmission errors to userspace audit daemon, backlog limit exceeded, out of kernel memory, and rate limit exceeded. The default value is 1. Secure environments will probably want to set this to 2. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-h | Help | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-i | Ignore errors when reading rules from a file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-l | List all rules 1 per line. This can take a key option (-k), too. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-k key | Set a filter key on an audit rule. The filter key is an arbitrary string of text that can be up to 31 bytes long. It can uniquely identify the audit records produced by a rule. Typical use is for when you have several rules that together satisfy a security requirement. The key value can be searched on with ausearch so that no matter which rule triggered the event, you can find its results. The key can also be used on delete all (-D) and list rules (-l) to select rules with a specific key. You may have more than one key on a rule if you want to be able to search logged events in multiple ways or if you have an audispd plugin that uses a key to aid its analysis. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-m text | Send a user space message into the audit system. This can only be done by the root user. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-p [r|w|x|a] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Set permissions filter for a file system watch. r=read, w=write, x=execute, a=attribute change. These permissions are not the standard file permissions, but rather the kind of syscall that would do this kind of thing. The read & write syscalls are omitted from this set since they would overwhelm the logs. But rather for reads or writes, the open flags are looked at to see what permission was requested. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-q mount-point,subtree | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
If you have an existing directory watch and bind or move mount another subtree in the watched subtree, you need to tell the kernel to make the subtree being mounted equivalent to the directory being watched. If the subtree is already mounted at the time the directory watch is issued, the subtree is automatically tagged for watching. Please note the comma separating the two values. Omitting it will cause errors. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-r rate | Set limit in messages/sec (0=none). If this rate is non-zero and is exceeded, the failure flag is consulted by the kernel for action. The default value is 0. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-R file | Read rules from a file. The rules must be 1 per line and in the order that they are to be executed in. The rule file must be owned by root and not readable by other users or it will be rejected. The rule file may have comments embedded by starting the line with a # character. Rules that are read from a file are identical to what you would type on a command line except they are not preceeded by auditctl (since auditctl is the one executing the file). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-s | Report status. Note that a pid of 0 indicates that the audit daemon is not running. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-t | Trim the subtrees after a mount command. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-a list,action | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Append rule to the end of list with action. Please note the comma separating the two values. Omitting it will cause errors. The following describes the valid list names:
The following describes the valid actions for the rule:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-A list,action | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Add rule to the beginning list with action. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-d list,action | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Delete rule from list with action. The rule is deleted only if it exactly matches syscall name and field names. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-D | Delete all rules and watches. This can take a key option (-k), too. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-S [Syscall name or number|all] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Any syscall name or number may be used. The word all may also be used. If this syscall is made by a program, then start an audit record. If a field rule is given and no syscall is specified, it will default to all syscalls. You may also specify multiple syscalls in the same rule by using multiple -S options in the same rule. Doing so improves performance since fewer rules need to be evaluated. If you are on a bi-arch system, like x86_64, you should be aware that auditctl simply takes the text, looks it up for the native arch (in this case b64) and sends that rule to the kernel. If there are no additional arch directives, IT WILL APPLY TO BOTH 32 & 64 BIT SYSCALLS. This can have undesirable effects since there is no guarantee that, for example, the open syscall has the same number on both 32 and 64 bit interfaces. You may want to control this and write 2 rules, one with arch equal to b32 and one with b64 to make sure the kernel finds the events that you intend. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-F [n=v | n!=v | n<v | n>v | n<=v | n>=v | n&v | n&=v] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Build a rule field: name, operation, value. You may have up to 64 fields passed on a single command line. Each one must start with -F. Each field equation is anded with each other to trigger an audit record. There are 8 operators supported - equal, not equal, less than, greater than, less than or equal, and greater than or equal, bit mask, and bit test respectively. Bit test will "and" the values and check that they are equal, bit mask just "ands" the values. Fields that take a user ID may instead have the users name; the program will convert the name to user ID. The same is true of group names. Valid fields are:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-w path | Insert a watch for the file system object at path. You cannot insert a watch to the top level directory. This is prohibited by the kernel. Wildcards are not supported either and will generate a warning. The way that watches work is by tracking the inode internally. If you place a watch on a file, its the same as using the -F path option on a syscall rule. If you place a watch on a directory, its the same as using the -F dir option on a syscall rule. The -w form of writing watches is for backwards compatibility and the syscall based form is more expressive. Unlike most syscall auditing rules, watches do not impact performance based on the number of rules sent to the kernel. The only valid options when using a watch are the -p and -k. If you need to anything fancy like audit a specific user accessing a file, then use the syscall auditing form with the path or dir fields. See the EXAMPLES section for an example of converting one form to another. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-W path | Remove a watch for the file system object at path. |
PERFORMANCE TIPS
Syscall rules get evaluated for each syscall for each program. If you have 10 syscall rules, every program on your system will delay during a syscall while the audit system evaulates each one. Too many syscall rules will hurt performance. Try to combine as many as you can whenever the filter, action, key, and fields are identical. For example:
auditctl -a exit,always -S open -F success=0 |
auditctl -a exit,always -S truncate -F success=0 |
could be re-written as one rule:
auditctl -a exit,always -S open -S truncate -F success=0 |
Also, try to use file system auditing wherever practical. This improves performance. For example, if you were wanting to capture all failed opens & truncates like above, but were only concerned about files in /etc and didnt care about /usr or /sbin, its possible to use this rule:
auditctl -a exit,always -S open -S truncate -F dir=/etc -F success=0 |
This will be higher performance since the kernel will not evaluate it each and every syscall. It will be handled by the filesystem auditing code and only checked on filesystem related syscalls.
EXAMPLES
To see all syscalls made by a specific program:
auditctl -a entry,always -S all -F pid=1005 |
To see files opened by a specific user:
auditctl -a exit,always -S open -F auid=510 |
To see unsuccessful open calls:
auditctl -a exit,always -S open -F success=0 |
To watch a file for changes (2 ways to express):
auditctl -w /etc/shadow -p wa auditctl -a exit,always -F path=/etc/shadow -F perm=wa |
To recursively watch a directory for changes (2 ways to express):
auditctl -w /etc/ -p wa auditctl -a exit,always -F dir=/etc/ -F perm=wa |
FILES
Tag | Description |
---|---|
/etc/audit/audit.rules | |
|